File: FGLMStrategyTest.cc

package info (click to toggle)
brial 1.2.12-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,404 kB
  • sloc: cpp: 219,610; ansic: 43,783; python: 4,172; makefile: 336; sh: 5
file content (123 lines) | stat: -rw-r--r-- 2,954 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// -*- c++ -*-
//*****************************************************************************
/** @file FGLMStrategyTest.cc
 *
 * @author Alexander Dreyer
 * @date 2011-08-08
 *
 * boost/test-driven unit test
 * 
 * @par Copyright:
 *   (c) 2011 by The PolyBoRi Team
 *
 **/
//*****************************************************************************


#include <boost/test/unit_test.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION < 107100
#include <boost/test/output_test_stream.hpp>
#else
#include <boost/test/tools/output_test_stream.hpp>
#endif

using boost::test_tools::output_test_stream;

#include <polybori/pbori_defs.h>
#include <polybori/groebner/FGLMStrategy.h>
#include <polybori/BoolePolyRing.h>

USING_NAMESPACE_PBORI
USING_NAMESPACE_PBORIGB

struct Ffglm {
  Ffglm(const BoolePolyRing& input_ring = BoolePolyRing(50)):
    ring(input_ring),
    x(0, input_ring), y(1, input_ring), z(2, input_ring),
    v(3, input_ring), w(4, input_ring) {

    BOOST_TEST_MESSAGE( "setup fixture" );

    ring.setVariableName(0, "x");
    ring.setVariableName(1, "y");
    ring.setVariableName(2, "z");
    ring.setVariableName(3, "v");
    ring.setVariableName(4, "w");
  }

  ~Ffglm() { BOOST_TEST_MESSAGE( "teardown fixture" ); }

  BoolePolyRing ring;
  BooleVariable x, y, z, v, w;
};


BOOST_FIXTURE_TEST_SUITE(FGLMStrategyTest, Ffglm)

BOOST_AUTO_TEST_CASE(test_constructors) {

  BoolePolyRing other(ring.clone());
  other.changeOrdering(CTypes::dp_asc);

  PolynomialVector ideal;
  ideal.push_back(x+z);
  ideal.push_back(y+z);

  FGLMStrategy strat(ring, other, ideal);

  ideal = strat.main();

  output_test_stream output;

  std::copy(ideal.begin(), ideal.end(), 
	    std::ostream_iterator<BoolePolynomial>(output, ", ") );
  BOOST_CHECK(output.is_equal("y + x, z + x, "));

}

/// @note It is intended, that the following two tests do not compile!
#ifdef FGLMStrategyTest_compile_all_
BOOST_AUTO_TEST_CASE(test_copy_constructor) {
  BoolePolyRing other(ring.clone());
  other.changeOrdering(CTypes::dp_asc);

  PolynomialVector ideal;
  ideal.push_back(x+z);
  ideal.push_back(y+z);

  FGLMStrategy strat0(ring, other, ideal);
  FGLMStrategy strat(strat0);
  ideal = strat.main();

  output_test_stream output;

  std::copy(ideal.begin(), ideal.end(), 
	    std::ostream_iterator<BoolePolynomial>(output, ", ") );
  BOOST_CHECK(output.is_equal("y + x, z + x, "));
}

BOOST_AUTO_TEST_CASE(test_assign) {
  BoolePolyRing empty(1);
  FGLMStrategy strat(empty, empty, PolynomialVector());

  BoolePolyRing other(ring.clone());
  other.changeOrdering(CTypes::dp_asc);

  PolynomialVector ideal;
  ideal.push_back(x+z);
  ideal.push_back(y+z);

  strat = FGLMStrategy(ring, other, ideal);

  ideal = strat.main();

  output_test_stream output;

  std::copy(ideal.begin(), ideal.end(), 
	    std::ostream_iterator<BoolePolynomial>(output, ", ") );
  BOOST_CHECK(output.is_equal("y + x, z + x, "));
}
#endif

BOOST_AUTO_TEST_SUITE_END()