Skip to content

Commit 8291cd3

Browse files
committed
Removed methos compareS / compare N / compareB from unit-tests
1 parent 576a998 commit 8291cd3

16 files changed

+26
-62
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ project(wsjcpp-core)
55
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
66

77
#### BEGIN_WSJCPP_APPEND
8-
list (APPEND WSJCPP_SOURCES "./src/some.h")
9-
list (APPEND WSJCPP_SOURCES "./src/some.cpp")
108
#### END_WSJCPP_APPEND
119

1210
set(CMAKE_CXX_STANDARD 11)

src/wsjcpp_unit_tests.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,6 @@ bool WsjcppUnitTestBase::runTest() {
6363

6464
// ---------------------------------------------------------------------
6565

66-
bool WsjcppUnitTestBase::compareS(const std::string &sMark,
67-
const std::string &sValue, const std::string &sExpected) {
68-
if (sValue != sExpected) {
69-
fail(" {" + sMark + "} Expected '" + sExpected + "', but got '" + sValue + "'");
70-
return false;
71-
}
72-
return true;
73-
}
74-
75-
// ---------------------------------------------------------------------
76-
77-
bool WsjcppUnitTestBase::compareN(const std::string &sMark, int nValue, int nExpected) {
78-
if (nValue != nExpected) {
79-
fail(" {" + sMark + "} Expected '" + std::to_string(nExpected) + "', but got '" + std::to_string(nValue) + "'");
80-
return false;
81-
}
82-
return true;
83-
}
84-
85-
// ---------------------------------------------------------------------
86-
8766
bool WsjcppUnitTestBase::compareD(const std::string &sMark, double nValue, double nExpected) {
8867
if (abs(nValue - nExpected) > std::numeric_limits<double>::epsilon()) {
8968
fail(" {" + sMark + "} Expected '" + std::to_string(nExpected) + "', but got '" + std::to_string(nValue) + "'");
@@ -94,16 +73,6 @@ bool WsjcppUnitTestBase::compareD(const std::string &sMark, double nValue, doubl
9473

9574
// ---------------------------------------------------------------------
9675

97-
bool WsjcppUnitTestBase::compareB(const std::string &sMark, bool bValue, bool bExpected) {
98-
if (bValue != bExpected) {
99-
fail(" {" + sMark + "} Expected '" + (bExpected ? "true" : "false") + "', but got '" + (bValue ? "true" : "false") + "'");
100-
return false;
101-
}
102-
return true;
103-
}
104-
105-
// ---------------------------------------------------------------------
106-
10776
std::vector<WsjcppUnitTestBase*> *g_pWsjcppUnitTests = nullptr;
10877

10978
void WsjcppUnitTests::initGlobalVariables() {

src/wsjcpp_unit_tests.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ class WsjcppUnitTestBase {
1717
virtual bool doAfterTest() = 0;
1818
protected:
1919
std::string TAG;
20-
21-
bool compareS(const std::string &sMark, const std::string &sValue, const std::string &sExpected);
22-
bool compareN(const std::string &sMark, int nValue, int nExpected);
20+
2321
bool compareD(const std::string &sMark, double nValue, double nExpected);
24-
bool compareB(const std::string &sMark, bool bValue, bool bExpected);
2522
template<typename T1, typename T2> bool compare(const std::string &sMark, T1 tGotValue, T2 tExpectedValue) {
2623
if (tGotValue != tExpectedValue) {
2724
std::stringstream ss;

unit-tests.wsjcpp/src/unit_test_create_empty_file.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ bool UnitTestCreateEmptyFile::doBeforeTest() {
1818
// ---------------------------------------------------------------------
1919

2020
void UnitTestCreateEmptyFile::executeTest() {
21-
compareB("./data/", WsjcppCore::dirExists("./data/"), true);
21+
compare("./data/", WsjcppCore::dirExists("./data/"), true);
2222
std::string sFilename = "./data/empty.txt";
2323
if (WsjcppCore::fileExists(sFilename)) {
2424
WsjcppCore::removeFile(sFilename);
2525
}
26-
compareB("fileExists 1: " + sFilename, WsjcppCore::fileExists(sFilename), false);
27-
compareB("createEmptyFile 1: " + sFilename, WsjcppCore::createEmptyFile(sFilename), true);
28-
compareB("createEmptyFile 2: " + sFilename, WsjcppCore::createEmptyFile(sFilename), false);
29-
compareB("fileExists 2: " + sFilename, WsjcppCore::fileExists(sFilename), true);
26+
compare("fileExists 1: " + sFilename, WsjcppCore::fileExists(sFilename), false);
27+
compare("createEmptyFile 1: " + sFilename, WsjcppCore::createEmptyFile(sFilename), true);
28+
compare("createEmptyFile 2: " + sFilename, WsjcppCore::createEmptyFile(sFilename), false);
29+
compare("fileExists 2: " + sFilename, WsjcppCore::fileExists(sFilename), true);
3030
}
3131

3232
// ---------------------------------------------------------------------

unit-tests.wsjcpp/src/unit_test_decode_uri_component.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void UnitTestDecodeUriComponent::executeTest() {
3737
for (int i = 0; i < tests.size(); i++) {
3838
LTest test = tests[i];
3939
std::string sStr = WsjcppCore::decodeUriComponent(test.sStr);
40-
compareS("test" + std::to_string(i), sStr, test.sExpectedStr);
40+
compare("test" + std::to_string(i), sStr, test.sExpectedStr);
4141
}
4242
}
4343

unit-tests.wsjcpp/src/unit_test_encode_uri_component.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void UnitTestEncodeUriComponent::executeTest() {
3737
for (int i = 0; i < tests.size(); i++) {
3838
LTest test = tests[i];
3939
std::string sStr = WsjcppCore::encodeUriComponent(test.sStr);
40-
compareS("test" + std::to_string(i), sStr, test.sExpectedStr);
40+
compare("test" + std::to_string(i), sStr, test.sExpectedStr);
4141
}
4242
}
4343

unit-tests.wsjcpp/src/unit_test_get_env.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void UnitTestGetEnv::executeTest() {
4040
std::string sValue;
4141
bool bResult = WsjcppCore::getEnv(test.sName, sValue);
4242
std::string testBaseName = "test#" + std::to_string(i) + " (" + test.sName + ")";
43-
compareB(testBaseName + "-result", bResult, test.bExpectedResult);
44-
compareS(testBaseName + "-value", sValue, test.sExpectedValue);
43+
compare(testBaseName + "-result", bResult, test.bExpectedResult);
44+
compare(testBaseName + "-value", sValue, test.sExpectedValue);
4545
}
4646
}
4747

unit-tests.wsjcpp/src/unit_test_get_human_size_bytes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void UnitTestgetHumanSizeBytes::executeTest() {
5555
long nValue = tests[i].nValue;
5656
std::string sExpectedStr = tests[i].sExpectedStr;
5757
std::string sGotStr = WsjcppCore::getHumanSizeBytes(nValue);
58-
compareS("value=" + std::to_string(nValue), sGotStr, sExpectedStr);
58+
compare("value=" + std::to_string(nValue), sGotStr, sExpectedStr);
5959
}
6060
}
6161

unit-tests.wsjcpp/src/unit_test_join.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void UnitTestJoin::executeTest() {
2424
vTest.push_back("2");
2525
vTest.push_back("abc");
2626
std::string sRet = WsjcppCore::join(vTest, ", ");
27-
compareS("join", sRet, ", 1, 2, abc");
27+
compare("join", sRet, ", 1, 2, abc");
2828
}
2929

3030
// ---------------------------------------------------------------------

unit-tests.wsjcpp/src/unit_test_list_of_dirs.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ bool UnitTestListOfDirs::doBeforeTest() {
2121
void UnitTestListOfDirs::executeTest() {
2222
std::vector<std::string> vDirs = WsjcppCore::getListOfDirs("./data/list_of_dirs");
2323

24-
compareN("size", vDirs.size(), 4);
24+
compare("size", vDirs.size(), 4);
2525
if (vDirs.size() == 4) {
26-
compareS("name of dir1", vDirs[0], "a1");
27-
compareS("name of dir2", vDirs[1], "b2");
28-
compareS("name of dir3", vDirs[2], "c3");
29-
compareS("name of dir4", vDirs[3], "d4");
26+
compare("name of dir1", vDirs[0], "a1");
27+
compare("name of dir2", vDirs[1], "b2");
28+
compare("name of dir3", vDirs[2], "c3");
29+
compare("name of dir4", vDirs[3], "d4");
3030
}
3131
}
3232

0 commit comments

Comments
 (0)