1 // -*- c++ -*-
2 //*****************************************************************************
3 /** @file VariableFactoryTest.cc
4 *
5 * @author Alexander Dreyer
6 * @date 2011-05-05
7 *
8 * boost/test-driven unit test
9 *
10 * @par Copyright:
11 * (c) 2011 by The PolyBoRi Team
12 *
13 **/
14 //*****************************************************************************
15
16
17 #include <boost/test/unit_test.hpp>
18 #include <boost/version.hpp>
19 #if BOOST_VERSION < 107100
20 #include <boost/test/output_test_stream.hpp>
21 #else
22 #include <boost/test/tools/output_test_stream.hpp>
23 #endif
24
25 using boost::test_tools::output_test_stream;
26
27 #include <polybori/pbori_defs.h>
28 #include <polybori/factories/VariableFactory.h>
29 #include <polybori/BoolePolyRing.h>
30
31 USING_NAMESPACE_PBORI
32
33 struct Fvarfac {
FvarfacFvarfac34 Fvarfac(const BoolePolyRing& input_ring = BoolePolyRing(50)):
35 ring(input_ring),
36 x(0, input_ring), y(1, input_ring), z(2, input_ring),
37 v(3, input_ring), w(4, input_ring) {
38
39 BOOST_TEST_MESSAGE( "setup fixture" );
40
41 ring.setVariableName(0, "x");
42 ring.setVariableName(1, "y");
43 ring.setVariableName(2, "z");
44 ring.setVariableName(3, "v");
45 ring.setVariableName(4, "w");
46 }
47
~FvarfacFvarfac48 ~Fvarfac() { BOOST_TEST_MESSAGE( "teardown fixture" ); }
49
50 BoolePolyRing ring;
51 BooleVariable x, y, z, v, w;
52 };
53
54
BOOST_FIXTURE_TEST_SUITE(VariableFactoryTest,Fvarfac)55 BOOST_FIXTURE_TEST_SUITE(VariableFactoryTest, Fvarfac )
56
57 BOOST_AUTO_TEST_CASE(test_constructors) {
58
59 VariableFactory factory(ring);
60 VariableFactory factory_copy(factory);
61
62 BOOST_CHECK_EQUAL(factory.parent().hash(), ring.hash());
63 BOOST_CHECK_EQUAL(factory_copy.parent().hash(), ring.hash());
64 }
65
BOOST_AUTO_TEST_CASE(test_pseudo_constructors)66 BOOST_AUTO_TEST_CASE(test_pseudo_constructors) {
67
68 VariableFactory factory(ring);
69
70 BOOST_TEST_MESSAGE( "Default Variables..." );
71 BOOST_CHECK_EQUAL(factory(), BooleVariable(0, ring));
72 BOOST_CHECK_EQUAL(factory(ring), BooleVariable(0, ring));
73
74 BOOST_TEST_MESSAGE( "i-th Variable..." );
75
76 for (int idx = 0; idx != 17; ++idx) {
77 BOOST_CHECK_EQUAL(factory(idx), BooleVariable(idx, ring));
78 BOOST_CHECK_EQUAL(factory(idx, ring), BooleVariable(idx, ring));
79 }
80 }
81
82 BOOST_AUTO_TEST_SUITE_END()
83