added doxygen make target
authorMarc Cromme <marc@indexdata.dk>
Fri, 7 Oct 2005 22:46:16 +0000 (22:46 +0000)
committerMarc Cromme <marc@indexdata.dk>
Fri, 7 Oct 2005 22:46:16 +0000 (22:46 +0000)
unit tests ported to boost test framework

Makefile.am
src/Makefile.am
src/test_filter1.cpp
src/test_filter2.cpp
src/test_session1.cpp

index 6ff4987..f718183 100644 (file)
@@ -7,5 +7,6 @@ EXTRA_DIST= m4/yazpp.m4 m4/yaz.m4  buildconf.sh
 MAINTAINERCLEANFILES    = Makefile.in aclocal.m4 configure 
 
 # doxygen target
+.PHONY:dox
 dox:
        doxygen
index 23198ab..7ebc614 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.10 2005-10-07 21:38:24 marc Exp $
+## $Id: Makefile.am,v 1.11 2005-10-07 22:46:16 marc Exp $
 
 MAINTAINERCLEANFILES    = Makefile.in config.in config.hpp
 
@@ -32,6 +32,8 @@ p2_SOURCES=p2_frontend.cpp p2_msg.cpp p2.cpp p2_frontend.h \
 LDADD= $(YAZPPLALIB) $(XSLT_LIBS)
 
 test_filter1_LDADD = $(LDADD) -lboost_unit_test_framework
+test_filter2_LDADD = $(LDADD) -lboost_unit_test_framework
+test_session1_LDADD = $(LDADD) -lboost_unit_test_framework
 test_boost_threads_LDADD = $(LDADD) -lboost_unit_test_framework
 
 
index 1d1b02b..d1142a2 100644 (file)
@@ -1,16 +1,12 @@
 
 #include <iostream>
 #include <stdexcept>
+
 #include "filter.hpp"
-//#include "router.hpp"
-//#include "package.hpp"
 
 #define BOOST_AUTO_TEST_MAIN
 #include <boost/test/auto_unit_test.hpp>
 
-//#include <boost/test/unit_test.hpp>
-//#include <boost/test/unit_test_monitor.hpp>
-
 using namespace boost::unit_test;
 
 class TFilter: public yp2::Filter {
@@ -21,7 +17,7 @@ public:
 };
     
 
-BOOST_AUTO_TEST_CASE( test1 )
+BOOST_AUTO_TEST_CASE( test_filter1 )
 {
     try{
         TFilter filter;
@@ -34,10 +30,10 @@ BOOST_AUTO_TEST_CASE( test1 )
         
         BOOST_CHECK(filter.name() == "filter1 rename");
     }
-    catch(std::runtime_error &e ){
-        BOOST_CHECK (true);
-    }
-    catch ( ...) {
+    //catch(std::runtime_error &e ){
+    //    BOOST_CHECK (true);
+    //}
+    catch ( ... ) {
         BOOST_CHECK (false);
     }
 }
index ff98627..f26e6e6 100644 (file)
@@ -1,14 +1,21 @@
 
-#include <iostream>
-//#include "design.h"
+
+
 #include "filter.hpp"
 #include "router.hpp"
 #include "package.hpp"
 
+#include <iostream>
+
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+
+using namespace boost::unit_test;
+
+
 class FilterConstant: public yp2::Filter {
 public:
     yp2::Package & process(yp2::Package & package) const {
-        std::cout << name() + ".process()" << std::endl;
        package.data() = 1234;
        return package.move();
     };
@@ -18,14 +25,13 @@ public:
 class FilterDouble: public yp2::Filter {
 public:
     yp2::Package & process(yp2::Package & package) const {
-        std::cout <<  name() + ".process()" << std::endl;
        package.data() = package.data() * 2;
        return package.move();
     };
 };
     
     
-int main(int argc, char **argv)
+BOOST_AUTO_TEST_CASE( testfilter2 ) 
 {
     try {
        FilterConstant fc;
@@ -47,35 +53,36 @@ int main(int argc, char **argv)
            
            pack_out = pack_in.router(router1).move(); 
            
-           if (pack_out.data() != 2468)
-           {
-               exit(1);
-           }
-       }
-       {
-           yp2::RouterChain router1;
+            BOOST_CHECK (pack_out.data() == 2468);
+            
+        }
+        
+        {
+            
+           yp2::RouterChain router2;
            
-           router1.rule(fd);
-           router1.rule(fc);
+           router2.rule(fd);
+           router2.rule(fc);
            
            yp2::Package pack_in;
            
            yp2::Package pack_out;
            
-           pack_out = pack_in.router(router1).move(); 
-           
-           if (pack_out.data() != 1234)
-           {
-               exit(1);
-           }
+           pack_out = pack_in.router(router2).move();
+     
+            BOOST_CHECK (pack_out.data() == 1234);
+            
        }
 
     }
     catch (std::exception &e) {
         std::cout << e.what() << "\n";
-       exit(1);
+        BOOST_CHECK (false);
     }
-    exit(0);
+    catch ( ...) {
+        BOOST_CHECK (false);
+    }
+
 }
 
 /*
index 47b4d01..58ec655 100644 (file)
@@ -1,37 +1,40 @@
+#include "session.hpp"
 
 #include <iostream>
 
-//#include "filter.hpp"
-//#include "router.hpp"
-//#include "package.hpp"
-#include "session.hpp"
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
 
-  
-int main(int argc, char **argv)
+using namespace boost::unit_test;
+
+BOOST_AUTO_TEST_CASE( testsession1 ) 
 {
+
     // test session 
     try {
         yp2::Session session;
         unsigned long int id;
         id = session.id();
-        std::cout <<  "Session.id() == " << id << std::endl;
         id = session.id();
-        std::cout <<  "Session.id() == " << id << std::endl;
         id = session.id();
-        std::cout <<  "Session.id() == " << id << std::endl;
+        id = session.id();
+        id = session.id();
+        id = session.id();
+        id = session.id();
+        id = session.id();
+        id = session.id();
+        id = session.id();
 
-       if (id != 3)
-       {
-           std::cout << "Fail: Session.id() != 3\n";
-           exit(1);
-       }
+        BOOST_CHECK (id == 10);
+        
     }
-
     catch (std::exception &e) {
         std::cout << e.what() << "\n";
-       exit(1);
+        BOOST_CHECK (false);
+    }
+    catch (...) {
+        BOOST_CHECK (false);
     }
-    exit(0);
 }
 
 /*