MCPcopy Index your code
hub / github.com/cpplint/cpplint / testExplicitSingleArgumentConstructors

Method testExplicitSingleArgumentConstructors

cpplint_unittest.py:1579–2056  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1577
1578 # Test non-explicit single-argument constructors
1579 def testExplicitSingleArgumentConstructors(self):
1580 old_verbose_level = cpplint._cpplint_state.verbose_level
1581 cpplint._cpplint_state.verbose_level = 0
1582
1583 try:
1584 # missing explicit is bad
1585 self.TestMultiLineLint(
1586 """
1587 class Foo {
1588 Foo(int f);
1589 };""",
1590 "Single-parameter constructors should be marked explicit. [runtime/explicit] [4]",
1591 )
1592 # missing explicit is bad, even with whitespace
1593 self.TestMultiLineLint(
1594 """
1595 class Foo {
1596 Foo (int f);
1597 };""",
1598 [
1599 "Extra space before ( in function call [whitespace/parens] [4]",
1600 "Single-parameter constructors should be marked explicit."
1601 " [runtime/explicit] [4]",
1602 ],
1603 )
1604 # missing explicit, with distracting comment, is still bad
1605 self.TestMultiLineLint(
1606 """
1607 class Foo {
1608 Foo(int f); // simpler than Foo(blargh, blarg)
1609 };""",
1610 "Single-parameter constructors should be marked explicit. [runtime/explicit] [4]",
1611 )
1612 # missing explicit, with qualified classname
1613 self.TestMultiLineLint(
1614 """
1615 class Qualifier::AnotherOne::Foo {
1616 Foo(int f);
1617 };""",
1618 "Single-parameter constructors should be marked explicit. [runtime/explicit] [4]",
1619 )
1620 # missing explicit for inline constructors is bad as well
1621 self.TestMultiLineLint(
1622 """
1623 class Foo {
1624 inline Foo(int f);
1625 };""",
1626 "Single-parameter constructors should be marked explicit. [runtime/explicit] [4]",
1627 )
1628 # missing explicit for constexpr constructors is bad as well
1629 self.TestMultiLineLint(
1630 """
1631 class Foo {
1632 constexpr Foo(int f);
1633 };""",
1634 "Single-parameter constructors should be marked explicit. [runtime/explicit] [4]",
1635 )
1636 # missing explicit for constexpr+inline constructors is bad as well

Callers

nothing calls this directly

Calls 3

ResultListMethod · 0.95
ErrorCollectorClass · 0.85
TestMultiLineLintMethod · 0.80

Tested by

no test coverage detected