* first shot at unit testing of il_* protocol suite
authorMichal Voců <michal@ruk.cuni.cz>
Tue, 31 Aug 2004 15:44:39 +0000 (15:44 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Tue, 31 Aug 2004 15:44:39 +0000 (15:44 +0000)
org.glite.lb.common/test/il_int_test.cpp [new file with mode: 0644]
org.glite.lb.common/test/il_string_test.cpp [new file with mode: 0644]
org.glite.lb.common/test/il_test.cpp [new file with mode: 0644]

diff --git a/org.glite.lb.common/test/il_int_test.cpp b/org.glite.lb.common/test/il_int_test.cpp
new file mode 100644 (file)
index 0000000..af486f4
--- /dev/null
@@ -0,0 +1,43 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+
+extern "C" {
+#include "edg/workload/logging/common/il_string.h"
+}
+
+class IlIntTest: public CppUnit::TestFixture
+{
+       CPPUNIT_TEST_SUITE( IlIntTest );
+       CPPUNIT_TEST( testPutInt );
+       CPPUNIT_TEST( testGetInt );
+       CPPUNIT_TEST( testLenInt );
+       CPPUNIT_TEST_SUITE_END();
+
+public:
+       void setUp() {
+       }
+
+       void tearDown() {
+       }
+
+       void testPutInt() {
+               put_int(buffer, 17);
+               CPPUNIT_ASSERT(!strcmp(buffer, "17\n"));
+       }
+
+       void testGetInt() {
+               int d;
+               get_int("17\n", &d);
+               CPPUNIT_ASSERT(d == 17);
+       }
+
+       void testLenInt() {
+               CPPUNIT_ASSERT(3 == len_int(17));
+       }
+
+protected:
+       char buffer[255];
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( IlIntTest ) ;
+
diff --git a/org.glite.lb.common/test/il_string_test.cpp b/org.glite.lb.common/test/il_string_test.cpp
new file mode 100644 (file)
index 0000000..3220726
--- /dev/null
@@ -0,0 +1,45 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+
+extern "C" {
+#include "edg/workload/logging/common/il_string.h"
+}
+
+class IlStringTest : public CppUnit::TestFixture 
+{
+       CPPUNIT_TEST_SUITE( IlStringTest );
+       CPPUNIT_TEST( testPutString );
+       CPPUNIT_TEST( testGetString );
+       CPPUNIT_TEST( testLenString );
+       CPPUNIT_TEST_SUITE_END();
+
+public:
+       void setUp() {
+       }
+
+       void tearDown() {
+       }
+
+       void testPutString() {
+               put_string(buffer, "ahoj");
+               CPPUNIT_ASSERT( !strcmp(buffer, "4 ahoj\n") );
+       }
+
+       void testGetString() {
+               char *s;
+               get_string("4 ahoj\n", &s);
+               CPPUNIT_ASSERT( s != NULL );
+               CPPUNIT_ASSERT( !strcmp(s, "ahoj") );
+               free(s);
+       }
+
+       void testLenString() {
+               int d = len_string("ahoj");
+               CPPUNIT_ASSERT( d == 7);
+       }
+
+private:
+       char buffer[255];
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( IlStringTest );
diff --git a/org.glite.lb.common/test/il_test.cpp b/org.glite.lb.common/test/il_test.cpp
new file mode 100644 (file)
index 0000000..794c0a0
--- /dev/null
@@ -0,0 +1,15 @@
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TextTestRunner.h>
+
+
+int main(int argc, char *argv[])
+{
+       CppUnit::Test  *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+       CppUnit::TextTestRunner runner;
+
+       runner.addTest(suite);
+       runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr));
+
+       return runner.run() ? 0 : 1;
+}