projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Same header and footer for all files. Header includes copyright +
[metaproxy-moved-to-github.git]
/
src
/
test_filter2.cpp
diff --git
a/src/test_filter2.cpp
b/src/test_filter2.cpp
index
e5aa309
..
4b70368
100644
(file)
--- a/
src/test_filter2.cpp
+++ b/
src/test_filter2.cpp
@@
-1,28
+1,42
@@
+/* $Id: test_filter2.cpp,v 1.9 2005-10-15 14:09:09 adam Exp $
+ Copyright (c) 2005, Index Data.
+
+%LICENSE%
+ */
+
+
+#include "config.hpp"
+#include "filter.hpp"
+#include "router.hpp"
+#include "package.hpp"
#include <iostream>
#include <iostream>
-#include "design.h"
-class FilterConstant: public yp2::Filter {
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+
+using namespace boost::unit_test;
+
+
+class FilterConstant: public yp2::filter::Base {
public:
public:
- yp2::Package & process(yp2::Package & package) const {
- std::cout << name() + ".process()" << std::endl;
+ void process(yp2::Package & package) const {
package.data() = 1234;
package.data() = 1234;
- return package.move();
+ package.move();
};
};
};
};
-class FilterDouble: public yp2::Filter {
+class FilterDouble: public yp2::filter::Base {
public:
public:
- yp2::Package & process(yp2::Package & package) const {
- std::cout << name() + ".process()" << std::endl;
+ void process(yp2::Package & package) const {
package.data() = package.data() * 2;
package.data() = package.data() * 2;
- return package.move();
+ package.move();
};
};
};
};
-int main(int argc, char **argv)
+BOOST_AUTO_TEST_CASE( testfilter2 )
{
try {
FilterConstant fc;
{
try {
FilterConstant fc;
@@
-37,48
+51,49
@@
int main(int argc, char **argv)
router1.rule(fc);
router1.rule(fd);
router1.rule(fc);
router1.rule(fd);
+
+ yp2::Session session;
+ yp2::Origin origin;
+ yp2::Package pack(session, origin);
- yp2::Package pack_in;
-
- yp2::Package pack_out;
-
- pack_out = pack_in.router(router1).move();
-
- if (pack_out.data() != 2468)
- {
- exit(1);
- }
- }
- {
- yp2::RouterChain router1;
-
- router1.rule(fd);
- router1.rule(fc);
-
- yp2::Package pack_in;
+ pack.router(router1).move();
- yp2::Package pack_out;
+ BOOST_CHECK (pack.data() == 2468);
+
+ }
+
+ {
+ yp2::RouterChain router2;
- pack_out = pack_in.router(router1).move();
+ router2.rule(fd);
+ router2.rule(fc);
- if (pack_out.data() != 1234)
- {
- exit(1);
- }
+ yp2::Session session;
+ yp2::Origin origin;
+ yp2::Package pack(session, origin);
+
+ pack.router(router2).move();
+
+ BOOST_CHECK (pack.data() == 1234);
+
}
}
catch (std::exception &e) {
std::cout << e.what() << "\n";
}
}
catch (std::exception &e) {
std::cout << e.what() << "\n";
- exit(1);
+ BOOST_CHECK (false);
}
}
- exit(0);
+ catch ( ...) {
+ BOOST_CHECK (false);
+ }
+
}
/*
* Local variables:
* c-basic-offset: 4
* indent-tabs-mode: nil
}
/*
* Local variables:
* c-basic-offset: 4
* indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/