1 /* $Id: test_filter_factory.cpp,v 1.3 2005-10-29 22:23:36 marc Exp $
2 Copyright (c) 2005, Index Data.
14 #include "filter_factory.hpp"
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
20 using namespace boost::unit_test;
22 class XFilter: public yp2::filter::Base {
24 void process(yp2::Package & package) const {};
25 const std::string type() const{
31 yp2::filter::Base* xfilter_creator(){
35 class YFilter: public yp2::filter::Base {
37 void process(yp2::Package & package) const {};
38 const std::string type() const{
43 yp2::filter::Base* yfilter_creator(){
49 //int main(int argc, char **argv)
50 BOOST_AUTO_TEST_CASE( test_filter_factory_1 )
54 yp2::filter::FilterFactory ffactory;
59 const std::string xfid = xf.type();
60 const std::string yfid = yf.type();
62 //std::cout << "Xfilter name: " << xfid << std::endl;
63 //std::cout << "Yfilter name: " << yfid << std::endl;
65 BOOST_CHECK_EQUAL(ffactory.add_creator(xfid, xfilter_creator),
67 BOOST_CHECK_EQUAL(ffactory.drop_creator(xfid),
69 BOOST_CHECK_EQUAL(ffactory.add_creator(xfid, xfilter_creator),
71 BOOST_CHECK_EQUAL(ffactory.add_creator(yfid, yfilter_creator),
74 yp2::filter::Base* xfilter = ffactory.create(xfid);
75 yp2::filter::Base* yfilter = ffactory.create(yfid);
77 BOOST_CHECK_EQUAL(xf.type(), xfilter->type());
78 BOOST_CHECK_EQUAL(yf.type(), yfilter->type());
80 //std::cout << "Xfilter pointer name: " << xfilter->type() << std::endl;
81 //std::cout << "Yfilter pointer name: " << yfilter->type() << std::endl;
97 // get function - right val in assignment
98 //std::string name() const {
103 // set function - left val in assignment
104 //std::string & name() {
108 // set function - can be chained
109 //Base & name(const std::string & name){
118 * indent-tabs-mode: nil
119 * c-file-style: "stroustrup"
121 * vim: shiftwidth=4 tabstop=8 expandtab