From: tho Date: Fri, 28 Aug 2009 11:35:31 +0000 (+0000) Subject: PPI/MultiConnectorMixin: added test to demonstrate bug when connection multiple multi... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=3f3220b768a376bb67495cc3905b0b06b9ef61e2;p=senf.git PPI/MultiConnectorMixin: added test to demonstrate bug when connection multiple multi-connector-modules git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1351 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/MultiConnectorMixin.test.cc b/senf/PPI/MultiConnectorMixin.test.cc index 34a8b47..83f6532 100644 --- a/senf/PPI/MultiConnectorMixin.test.cc +++ b/senf/PPI/MultiConnectorMixin.test.cc @@ -35,63 +35,73 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// +namespace ppi = senf::ppi; +namespace connector = ppi::connector; +namespace module = ppi::module; +namespace debug = module::debug; + namespace { // We only test the user-collection case, all other cases are already handled by // existing modules // Primitive duplicator class MyModule - : public senf::ppi::module::Module, - public senf::ppi::module::MultiConnectorMixin, - void, void> + : public module::Module, + public module::MultiConnectorMixin, void, void> { SENF_PPI_MODULE(MyModule); public: - senf::ppi::connector::PassiveInput<> input; + connector::PassiveInput<> input; MyModule() - { - noroute(input); - input.onRequest(&MyModule::request); - } + { + noroute(input); + input.onRequest(&MyModule::request); + } private: void connectorSetup(std::auto_ptr c) - { - route(input, *c); - connectors_.push_back(boost::shared_ptr(c)); - } + { + route(input, *c); + connectors_.push_back(boost::shared_ptr(c)); + } void request() - { - senf::Packet p (input()); - for (Connectors::iterator i (connectors_.begin()), i_end (connectors_.end()); - i != i_end; ++i) - (**i)(p); - } + { + senf::Packet p (input()); + for (Connectors::iterator i (connectors_.begin()), i_end (connectors_.end()); + i != i_end; ++i) + (**i)(p); + } typedef std::vector< boost::shared_ptr > Connectors; Connectors connectors_; - friend class senf::ppi::module::MultiConnectorMixin, - void, void>; - + friend class module::MultiConnectorMixin, void, void>; + }; + + struct IntAnnotation { + int value; + bool operator<(IntAnnotation const & other) const { return value < other.value; } + IntAnnotation() {} + IntAnnotation(int v) : value(v) {} }; + + std::ostream & operator<<(std::ostream & os, IntAnnotation const & value) + { os << value.value; return os; } } BOOST_AUTO_UNIT_TEST(multiConnectorMixin_userContainer) { - senf::ppi::module::debug::ActiveSource source; + debug::ActiveSource source; MyModule module; - senf::ppi::module::debug::PassiveSink sink1; - senf::ppi::module::debug::PassiveSink sink2; + debug::PassiveSink sink1; + debug::PassiveSink sink2; - senf::ppi::connect(source, module); - senf::ppi::connect(module, sink1); - senf::ppi::connect(module, sink2); - senf::ppi::init(); + ppi::connect(source, module); + ppi::connect(module, sink1); + ppi::connect(module, sink2); + ppi::init(); senf::Packet p (senf::DataPacket::create()); @@ -100,7 +110,32 @@ BOOST_AUTO_UNIT_TEST(multiConnectorMixin_userContainer) BOOST_CHECK_EQUAL( sink2.size(), 1u ); BOOST_CHECK( sink1.pop_front() == p ); BOOST_CHECK( sink2.pop_front() == p ); +} + +BOOST_AUTO_UNIT_TEST(multiConnectorMixin_multipleModules) +{ + // This test fails! + /* + debug::ActiveSource source; + debug::PassiveSink sink; + module::PassiveJoin join1; + module::PassiveJoin join2; + module::AnnotationRouter router; + MyModule module; + + ppi::connect(source, join1); + ppi::connect(join1, router); + ppi::connect(router, join2, 1); + ppi::connect(join2, module); + ppi::connect(module, sink); + senf::Packet p (senf::DataPacket::create()); + p.annotation().value = 1; + + source.submit(p); + BOOST_CHECK_EQUAL( sink.size(), 1u ); + BOOST_CHECK( sink.pop_front() == p ); + */ } ///////////////////////////////cc.e////////////////////////////////////////