X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ftest_filter2.cpp;h=f4a9b3e12cba7f99f99cb575049fdfd647f7da05;hb=cba94f69f50a7789d498212dd59938087e8cbf9f;hp=f7db7fe1d06140e6fe373f48bdecfa9970963893;hpb=bf8d8e49d8c9a4713b4c56b668846ccd733f136d;p=metaproxy-moved-to-github.git diff --git a/src/test_filter2.cpp b/src/test_filter2.cpp index f7db7fe..f4a9b3e 100644 --- a/src/test_filter2.cpp +++ b/src/test_filter2.cpp @@ -1,6 +1,17 @@ + +#include "config.hpp" +#include "filter.hpp" +#include "router.hpp" +#include "package.hpp" + #include -#include "design.h" + +#define BOOST_AUTO_TEST_MAIN +#include + +using namespace boost::unit_test; + class FilterConstant: public yp2::Filter { public: @@ -20,14 +31,16 @@ public: }; -int main(int argc, char **argv) +BOOST_AUTO_TEST_CASE( testfilter2 ) { try { FilterConstant fc; + fc.name() = "FilterConstant"; FilterDouble fd; + fd.name() = "FilterDouble"; { - yp2::Router router1; + yp2::RouterChain router1; // test filter set/get/exception router1.rule(fc); @@ -40,35 +53,36 @@ int main(int argc, char **argv) pack_out = pack_in.router(router1).move(); - if (pack_out.data() != 2468) - { - exit(1); - } - } - { - yp2::Router 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); + } + catch ( ...) { + BOOST_CHECK (false); } - exit(0); + } /*