std::string type() function taken out of all filter classes again
[metaproxy-moved-to-github.git] / src / test_filter_factory.cpp
1 /* $Id: test_filter_factory.cpp,v 1.4 2005-10-31 09:40:18 marc Exp $
2    Copyright (c) 2005, Index Data.
3
4 %LICENSE%
5
6 */
7
8
9 #include <iostream>
10 #include <stdexcept>
11
12 #include "config.hpp"
13 #include "filter.hpp"
14 #include "filter_factory.hpp"
15
16
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
19
20 using namespace boost::unit_test;
21
22 class XFilter: public yp2::filter::Base {
23 public:
24     void process(yp2::Package & package) const {};
25 };
26
27
28 yp2::filter::Base* xfilter_creator(){
29     return new XFilter;
30 }
31
32 class YFilter: public yp2::filter::Base {
33 public:
34     void process(yp2::Package & package) const {};
35 };
36
37 yp2::filter::Base* yfilter_creator(){
38     return new YFilter;
39 }
40
41
42
43 //int main(int argc, char **argv)
44 BOOST_AUTO_TEST_CASE( test_filter_factory_1 )
45 {
46     try {
47         
48         yp2::filter::FilterFactory  ffactory;
49         
50         XFilter xf;
51         YFilter yf;
52
53         const std::string xfid = "XFilter";
54         const std::string yfid = "YFilter";
55         
56         //std::cout << "Xfilter name: " << xfid << std::endl;
57         //std::cout << "Yfilter name: " << yfid << std::endl;
58
59         BOOST_CHECK_EQUAL(ffactory.add_creator(xfid, xfilter_creator),
60                           true);
61         BOOST_CHECK_EQUAL(ffactory.drop_creator(xfid),
62                           true);
63         BOOST_CHECK_EQUAL(ffactory.add_creator(xfid, xfilter_creator),
64                           true);
65         BOOST_CHECK_EQUAL(ffactory.add_creator(yfid, yfilter_creator),
66                           true);
67         
68         yp2::filter::Base* xfilter = 0;
69         xfilter = ffactory.create(xfid);
70         yp2::filter::Base* yfilter = 0;
71         yfilter = ffactory.create(yfid);
72
73         //BOOST_CHECK_EQUAL(sizeof(xf), sizeof(*xfilter));
74         //BOOST_CHECK_EQUAL(sizeof(yf), sizeof(*yfilter));
75
76         BOOST_CHECK(0 != xfilter);
77         BOOST_CHECK(0 != yfilter);
78
79         }
80     catch ( ... ) {
81         throw;
82         BOOST_CHECK (false);
83     }
84         
85     std::exit(0);
86 }
87
88
89
90
91
92             // get function - right val in assignment
93             //std::string name() const {
94                 //return m_name;
95             //  return "Base";
96             //}
97             
98             // set function - left val in assignment
99             //std::string & name() {
100             //    return m_name;
101             //}
102             
103             // set function - can be chained
104             //Base & name(const std::string & name){
105             //  m_name = name;
106             //  return *this;
107             //}
108             
109
110 /*
111  * Local variables:
112  * c-basic-offset: 4
113  * indent-tabs-mode: nil
114  * c-file-style: "stroustrup"
115  * End:
116  * vim: shiftwidth=4 tabstop=8 expandtab
117  */