Skip to content

Commit 7d33181

Browse files
committed
Refactorizations in testrunner:
- Avoid creation of std::string instances of static strings where possible in testrunner. - Removed unnecessary include of tinyxml.h in testcppcheck.cpp
1 parent 37820af commit 7d33181

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

test/testboost.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TestBoost : public TestFixture {
3535
TEST_CASE(BoostForeachContainerModification)
3636
}
3737

38-
void check(const std::string &code) {
38+
void check(const char code[]) {
3939
// Clear the error buffer..
4040
errout.str("");
4141

@@ -45,7 +45,7 @@ class TestBoost : public TestFixture {
4545

4646
// Tokenize..
4747
Tokenizer tokenizer(&settings, this);
48-
std::istringstream istr(code.c_str());
48+
std::istringstream istr(code);
4949
tokenizer.tokenize(istr, "test.cpp");
5050
tokenizer.simplifyTokenList();
5151

test/testcppcheck.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
#include <list>
3131
#include <string>
3232

33-
// use tinyxml with STL
34-
#include <tinyxml.h>
35-
3633
extern std::ostringstream errout;
3734
extern std::ostringstream output;
3835

test/testexceptionsafety.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TestExceptionSafety : public TestFixture {
4444
TEST_CASE(catchExceptionByValue);
4545
}
4646

47-
void check(const std::string &code, bool inconclusive = false) {
47+
void check(const char code[], bool inconclusive = false) {
4848
// Clear the error buffer..
4949
errout.str("");
5050

test/testinternal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TestInternal : public TestFixture {
4141
TEST_CASE(internalError)
4242
}
4343

44-
void check(const std::string &code) {
44+
void check(const char code[]) {
4545
// Clear the error buffer..
4646
errout.str("");
4747

@@ -50,7 +50,7 @@ class TestInternal : public TestFixture {
5050

5151
// Tokenize..
5252
Tokenizer tokenizer(&settings, this);
53-
std::istringstream istr(code.c_str());
53+
std::istringstream istr(code);
5454
tokenizer.tokenize(istr, "test.cpp");
5555
tokenizer.simplifyTokenList();
5656

test/teststl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TestStl : public TestFixture {
118118

119119
}
120120

121-
void check(const std::string &code, const bool inconclusive=false) {
121+
void check(const char code[], const bool inconclusive=false) {
122122
// Clear the error buffer..
123123
errout.str("");
124124

@@ -137,6 +137,9 @@ class TestStl : public TestFixture {
137137
CheckStl checkStl;
138138
checkStl.runSimplifiedChecks(&tokenizer, &settings, this);
139139
}
140+
void check(const std::string &code, const bool inconclusive=false) {
141+
check(code.c_str(), inconclusive);
142+
}
140143

141144

142145
void iterator1() {

0 commit comments

Comments
 (0)