11#include " wsjcpp_unit_tests.h"
22
3- UnitTestBase::UnitTestBase (const std::string &sTestName ) {
3+ WSJCppUnitTestBase::WSJCppUnitTestBase (const std::string &sTestName ) {
44 m_sTestName = sTestName ;
55 TAG = m_sTestName;
6- UnitTests ::addUnitTest (sTestName , this );
6+ WSJCppUnitTests ::addUnitTest (sTestName , this );
77}
88
99// ---------------------------------------------------------------------
1010
11- std::string UnitTestBase ::name () {
11+ std::string WSJCppUnitTestBase ::name () {
1212 return m_sTestName;
1313}
1414
1515// ---------------------------------------------------------------------
1616
17- void UnitTestBase ::compareS (bool &bTestSuccess, const std::string &sPoint ,
17+ void WSJCppUnitTestBase ::compareS (bool &bTestSuccess, const std::string &sPoint ,
1818 const std::string &sValue , const std::string &sExpected ) {
1919 if (sValue != sExpected ) {
2020 WSJCppLog::err (TAG, " {" + sPoint + " } Expected '" + sExpected + " ', but got '" + sValue + " '" );
@@ -24,7 +24,7 @@ void UnitTestBase::compareS(bool &bTestSuccess, const std::string &sPoint,
2424
2525// ---------------------------------------------------------------------
2626
27- bool UnitTestBase ::compareN (bool &bTestSuccess, const std::string &sPoint , int nValue, int nExpected) {
27+ bool WSJCppUnitTestBase ::compareN (bool &bTestSuccess, const std::string &sPoint , int nValue, int nExpected) {
2828 if (nValue != nExpected) {
2929 WSJCppLog::err (TAG, " {" + sPoint + " } Expected '" + std::to_string (nExpected) + " ', but got '" + std::to_string (nValue) + " '" );
3030 bTestSuccess = false ;
@@ -35,7 +35,7 @@ bool UnitTestBase::compareN(bool &bTestSuccess, const std::string &sPoint, int n
3535
3636// ---------------------------------------------------------------------
3737
38- bool UnitTestBase ::compareD (bool &bTestSuccess, const std::string &sPoint , double nValue, double nExpected) {
38+ bool WSJCppUnitTestBase ::compareD (bool &bTestSuccess, const std::string &sPoint , double nValue, double nExpected) {
3939 if (nValue != nExpected) {
4040 WSJCppLog::err (TAG, " {" + sPoint + " } Expected '" + std::to_string (nExpected) + " ', but got '" + std::to_string (nValue) + " '" );
4141 bTestSuccess = false ;
@@ -46,7 +46,7 @@ bool UnitTestBase::compareD(bool &bTestSuccess, const std::string &sPoint, doubl
4646
4747// ---------------------------------------------------------------------
4848
49- void UnitTestBase ::compareB (bool &bTestSuccess, const std::string &sPoint , bool bValue, bool bExpected) {
49+ void WSJCppUnitTestBase ::compareB (bool &bTestSuccess, const std::string &sPoint , bool bValue, bool bExpected) {
5050 if (bValue != bExpected) {
5151 WSJCppLog::err (TAG, " {" + sPoint + " } Expected '" + (bExpected ? " true" : " false" ) + " ', but got '" + (bValue ? " true" : " false" ) + " '" );
5252 bTestSuccess = false ;
@@ -55,22 +55,22 @@ void UnitTestBase::compareB(bool &bTestSuccess, const std::string &sPoint, bool
5555
5656// ---------------------------------------------------------------------
5757
58- std::vector<UnitTestBase *> *g_pUnitTests = NULL ;
58+ std::vector<WSJCppUnitTestBase *> *g_pUnitTests = NULL ;
5959
60- void UnitTests ::initGlobalVariables () {
60+ void WSJCppUnitTests ::initGlobalVariables () {
6161 if (g_pUnitTests == NULL ) {
6262 // Log::info(std::string(), "Create handlers map");
63- g_pUnitTests = new std::vector<UnitTestBase *>();
63+ g_pUnitTests = new std::vector<WSJCppUnitTestBase *>();
6464 }
6565}
6666
6767// ---------------------------------------------------------------------
6868
69- void UnitTests ::addUnitTest (const std::string &sTestName , UnitTestBase * pUnitTest) {
70- UnitTests ::initGlobalVariables ();
69+ void WSJCppUnitTests ::addUnitTest (const std::string &sTestName , WSJCppUnitTestBase * pUnitTest) {
70+ WSJCppUnitTests ::initGlobalVariables ();
7171 bool bFound = false ;
7272 for (int i = 0 ; i < g_pUnitTests->size (); i++) {
73- UnitTestBase * p = g_pUnitTests->at (i);
73+ WSJCppUnitTestBase * p = g_pUnitTests->at (i);
7474 if (p->name () == sTestName ) {
7575 bFound = true ;
7676 }
@@ -86,13 +86,13 @@ void UnitTests::addUnitTest(const std::string &sTestName, UnitTestBase* pUnitTes
8686
8787// ---------------------------------------------------------------------
8888
89- bool UnitTests ::runUnitTests () {
90- UnitTests ::initGlobalVariables ();
89+ bool WSJCppUnitTests ::runUnitTests () {
90+ WSJCppUnitTests ::initGlobalVariables ();
9191 int nAll = g_pUnitTests->size ();
9292 WSJCppLog::info (" runUnitTests" , " All tests count " + std::to_string (nAll));
9393 int nSuccess = 0 ;
9494 for (int i = 0 ; i < g_pUnitTests->size (); i++) {
95- UnitTestBase * pUnitTest = g_pUnitTests->at (i);
95+ WSJCppUnitTestBase * pUnitTest = g_pUnitTests->at (i);
9696 std::string sTestName = pUnitTest->name ();
9797 WSJCppLog::info (" runUnitTests" , " Run test " + sTestName );
9898 if (pUnitTest->run ()) {
@@ -102,7 +102,7 @@ bool UnitTests::runUnitTests() {
102102 WSJCppLog::err (sTestName , " Test failed" );
103103 }
104104 }
105- WSJCppLog::info (" runUnitTests" , " Passed tests " + std::to_string (nSuccess) + " / " + std::to_string (nAll));
105+ WSJCppLog::info (" WSJCpp:: runUnitTests" , " Passed tests " + std::to_string (nSuccess) + " / " + std::to_string (nAll));
106106 return nSuccess == nAll;
107107}
108108
0 commit comments