nrtb-core team mailing list archive
-
nrtb-core team
-
Mailing list archive
-
Message #00146
[Branch ~fpstovall/nrtb/cpp_common] Rev 30: Started work on the unit test for common_rl. Basic structure of the test program and two tests ar...
------------------------------------------------------------
revno: 30
committer: fpstovall@xxxxxxxxx
branch nick: dev
timestamp: Wed 2011-07-20 22:16:12 -0400
message:
Started work on the unit test for common_rl. Basic structure of the test program and two tests are complete and the Makefile was updated to force the unit test and place the build products only if the test completes cleanly.
Need to complete the tests for all the other functions in common.h.
added:
common/common_rl/common_rl_test.cpp
modified:
common/common_rl/Makefile
--
lp:~fpstovall/nrtb/cpp_common
https://code.launchpad.net/~fpstovall/nrtb/cpp_common
Your team NRTB Core is subscribed to branch lp:~fpstovall/nrtb/cpp_common.
To unsubscribe from this branch go to https://code.launchpad.net/~fpstovall/nrtb/cpp_common/+edit-subscription
=== modified file 'common/common_rl/Makefile'
--- common/common_rl/Makefile 2010-12-25 22:44:22 +0000
+++ common/common_rl/Makefile 2011-07-21 02:16:12 +0000
@@ -16,7 +16,8 @@
#
#***********************************************
-lib: common.o
+lib: common_rl_test
+ @./common_rl_test
@cp -v common.h ../include
@cp -v common.o ../obj
@echo build complete
@@ -24,7 +25,12 @@
common.o: common.h common.cpp Makefile
@rm -f common.o
g++ -c -O3 common.cpp
+
+common_rl_test: common.o common_rl_test.cpp
+ @rm -f common_rl_test
+ g++ -c common_rl_test.cpp
+ g++ -o common_rl_test common_rl_test.o common.o
clean:
- @rm -rvf *.o ../include/common.h ../obj/common.o
+ @rm -rvf *.o ../include/common.h ../obj/common.o common_rl_test
@echo all objects and executables have been erased.
=== added file 'common/common_rl/common_rl_test.cpp'
--- common/common_rl/common_rl_test.cpp 1970-01-01 00:00:00 +0000
+++ common/common_rl/common_rl_test.cpp 2011-07-21 02:16:12 +0000
@@ -0,0 +1,57 @@
+/***********************************************
+ T his file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NRTB is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NRTB. If not, see <http://www.gnu.org/licenses/>.
+
+ **********************************************/
+
+#include "common.h"
+#include <iostream>
+
+using namespace std;
+
+int report_test(const string banner, bool test)
+{
+ string result;
+ int returnme = 0;
+ if (test)
+ {
+ result = "PASSED";
+ }
+ else
+ {
+ result = "FAILED";
+ returnme = 1;
+ };
+ cout << "\t" << banner << ": " << result << endl;
+ return returnme;
+};
+
+int main()
+{
+ cout << "=== Starting nrtb::common_rl unit test ===" << endl;
+ int returnme = 0;
+ string tstr = "MiXeDcAsE";
+
+ returnme += report_test(
+ "nrtb::upcase()",
+ nrtb::upcase(tstr) == "MIXEDCASE");
+
+ returnme += report_test(
+ "nrtb::downcase()",
+ nrtb::downcase(tstr) == "mixedcase");
+
+ cout << "=== nrtb::common_rl unit test complete ===" << endl;
+ return returnme;
+};
\ No newline at end of file