Skip to content

Commit 42966d8

Browse files
authored
Remove using namespace declarations (#35)
1 parent a9f9b7d commit 42966d8

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

tests/cppunit.h

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212

1313
#include <iostream>
1414

15-
using namespace std;
1615
using namespace CppUtilities;
17-
using namespace CPPUNIT_NS;
1816

1917
/*!
2018
* \brief Prints the names of all child tests of the specified \a test.
2119
*/
22-
void printTestNames(Test *test, Indentation indentation)
20+
void printTestNames(CPPUNIT_NS::Test *test, Indentation indentation)
2321
{
2422
for (int index = 0, count = test->getChildTestCount(); index != count; ++index) {
2523
const auto childTest = test->getChildTestAt(index);
26-
cerr << '\n' << indentation << " - " << childTest->getName();
24+
std::cerr << '\n' << indentation << " - " << childTest->getName();
2725
printTestNames(childTest, indentation + 4);
2826
}
2927
}
@@ -39,44 +37,44 @@ int main(int argc, char **argv)
3937
}
4038

4139
// list tests
42-
TestFactoryRegistry &registry = TestFactoryRegistry::getRegistry();
40+
CPPUNIT_NS::TestFactoryRegistry &registry = CPPUNIT_NS::TestFactoryRegistry::getRegistry();
4341
if (testApp.onlyListUnits()) {
44-
cerr << "Available tests:";
42+
std::cerr << "Available tests:";
4543
printTestNames(registry.makeTest(), Indentation(0));
46-
cerr << '\n';
44+
std::cerr << '\n';
4745
return 0;
4846
}
4947

5048
// run tests
51-
TextUi::TestRunner runner;
49+
CPPUNIT_NS::TextUi::TestRunner runner;
5250
if (!testApp.unitsSpecified() || testApp.units().empty()) {
5351
// no units specified -> test all
5452
runner.addTest(registry.makeTest());
5553
} else {
5654
// pick specified units from overall test
57-
Test *overallTest = registry.makeTest();
58-
vector<const char *> unavailableUnits;
55+
CPPUNIT_NS::Test *overallTest = registry.makeTest();
56+
std::vector<const char *> unavailableUnits;
5957
for (const char *unit : testApp.units()) {
6058
try {
6159
runner.addTest(overallTest->findTest(unit));
62-
} catch (const invalid_argument &) {
60+
} catch (const std::invalid_argument &) {
6361
unavailableUnits.emplace_back(unit);
6462
}
6563
}
6664
if (!unavailableUnits.empty()) {
67-
cerr << "The following tests specified via --unit are not available:";
65+
std::cerr << "The following tests specified via --unit are not available:";
6866
for (const char *unitName : unavailableUnits) {
69-
cerr << "\n - " << unitName;
67+
std::cerr << "\n - " << unitName;
7068
}
71-
cerr << "\nAvailable tests:";
69+
std::cerr << "\nAvailable tests:";
7270
printTestNames(overallTest, Indentation(0));
73-
cerr << '\n';
71+
std::cerr << '\n';
7472
return -1;
7573
}
7674
}
77-
cerr << EscapeCodes::TextAttribute::Bold << "Executing test cases ..." << EscapeCodes::Phrases::EndFlush;
78-
const auto ok = runner.run(string(), false);
79-
cerr << (ok ? "Tests successful\n" : "Tests failed\n");
75+
std::cerr << EscapeCodes::TextAttribute::Bold << "Executing test cases ..." << EscapeCodes::Phrases::EndFlush;
76+
const auto ok = runner.run(std::string(), false);
77+
std::cerr << (ok ? "Tests successful\n" : "Tests failed\n");
8078
return !ok;
8179
}
8280

0 commit comments

Comments
 (0)