Author: baby-guest
Date: 2008-02-19 13:21:48 +0000 (Tue, 19 Feb 2008)
New Revision: 5848

Modified:
   software/ui/src/CuTest.h
   software/ui/src/CuTest.sh
   software/ui/src/taghandler.cpp
Log:
Unit tests seem to work properly:

sh CuTest.sh > runtests.c
g++ runtests.c CuTest.c taghandler.cpp -o runtests -DUNIT_TEST
./runtests



Modified: software/ui/src/CuTest.h
===================================================================
--- software/ui/src/CuTest.h    2008-02-19 13:00:47 UTC (rev 5847)
+++ software/ui/src/CuTest.h    2008-02-19 13:21:48 UTC (rev 5848)
@@ -24,6 +24,10 @@
 #ifndef CU_TEST_H
 #define CU_TEST_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #include <setjmp.h>
 #include <stdarg.h>
 
@@ -131,4 +135,8 @@
 void CuSuiteSummary(CuSuite* testSuite, CuString* summary);
 void CuSuiteDetails(CuSuite* testSuite, CuString* details);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* CU_TEST_H */

Modified: software/ui/src/CuTest.sh
===================================================================
--- software/ui/src/CuTest.sh   2008-02-19 13:00:47 UTC (rev 5847)
+++ software/ui/src/CuTest.sh   2008-02-19 13:21:48 UTC (rev 5848)
@@ -31,6 +31,7 @@
 /* Do not edit this code directly. It has been auto-generated by CuTest.sh */
 
 #include "CuTest.h"
+#include <stdio.h>
 
 '
 

Modified: software/ui/src/taghandler.cpp
===================================================================
--- software/ui/src/taghandler.cpp      2008-02-19 13:00:47 UTC (rev 5847)
+++ software/ui/src/taghandler.cpp      2008-02-19 13:21:48 UTC (rev 5848)
@@ -18,6 +18,10 @@
 
 #include "taghandler.h"
 
+#ifdef UNIT_TEST
+#include "CuTest.h"
+#endif
+
 #include <iostream>
 
 FilterTagHandler::FilterTagHandler() : current_position(0), current_flag(1)
@@ -76,3 +80,65 @@
        }
        std::cerr << std::endl;
 }
+
+#ifdef UNIT_TEST
+void TestCuFilterTagHandler(CuTest* tc)
+{
+       FilterTagHandler tags;
+       for (unsigned int i=0; i<70; i++)
+       {
+               tags.AddTag("A");
+               tags.AddTag("B");
+               tags.AddTag("C");
+               tags.AddTag("D");
+               tags.AddTag("E");
+               tags.AddTag("F");
+               tags.AddTag("G");
+               tags.AddTag("H");
+               tags.AddTag("I");
+               tags.AddTag("J");
+               tags.AddTag("K");
+               tags.AddTag("L");
+               tags.AddTag("LL");
+               tags.AddTag("M");
+               tags.AddTag("N");
+               tags.AddTag("O");
+               tags.AddTag("P");
+               tags.AddTag("Q");
+               tags.AddTag("R");
+               tags.AddTag("S");
+               tags.AddTag("T");
+               tags.AddTag("U");
+               tags.AddTag("V");
+               tags.AddTag("W");
+               tags.AddTag("X");
+               tags.AddTag("Y");
+               tags.AddTag("Z");
+               tags.AddTag("0");
+               tags.AddTag("1");
+               tags.AddTag("2");
+               tags.AddTag("3");
+               tags.AddTag("4");
+               tags.AddTag("5");
+               tags.AddTag("6");
+               tags.AddTag("7");
+               tags.AddTag("8");
+               tags.AddTag("9");
+               tags.AddTag("10");
+       }
+
+       FilterTagHandler::Result t1, t2, t3, t4;
+
+       tags.SetTag(&t1, "A"); tags.SetTag(&t1, "7"); tags.SetTag(&t1, "MIRY");
+       tags.SetTag(&t2, "A"); tags.SetTag(&t2, "7"); tags.SetTag(&t2, "MIRY");
+       tags.SetTag(&t3, "A"); tags.SetTag(&t3, "8"); tags.SetTag(&t3, "MIRY");
+       tags.SetTag(&t4, "B"); tags.SetTag(&t4, "C");
+
+       CuAssertTrue(tc, t1.CompareAny(t2) == true );
+       CuAssertTrue(tc, t1.CompareAny(t3) == true );
+       CuAssertTrue(tc, t1.CompareAny(t4) != true );
+       CuAssertTrue(tc, t1.CompareAll(t2) == true );
+       CuAssertTrue(tc, t1.CompareAll(t3) != true );
+       CuAssertTrue(tc, t1.CompareAll(t4) != true );
+}
+#endif


_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-games-commits

Reply via email to