1 /* Test Grid_Generator_System IO operators.
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 #include "ppl_test.hh"
25 #include <sstream>
26
27 using namespace Parma_Polyhedra_Library::IO_Operators;
28
29 namespace {
30
31 // Single point.
32 bool
test01()33 test01() {
34 Variable A(0);
35 Variable B(1);
36
37 Grid_Generator_System gs1(grid_point(A + 7*B));
38
39 std::stringstream ss1;
40 ss1 << gs1;
41
42 print_generators(gs1, "*** gs1 ***");
43
44 Grid_Generator_System gs2;
45 gs2.insert(grid_point(A + 7*B));
46
47 std::stringstream ss2;
48 ss2 << gs2;
49
50 print_generators(gs2, "*** gs2 ***");
51
52 bool ok = (!ss2.str().compare(ss1.str()));
53
54 return ok;
55 }
56
57 // Many generators.
58 bool
test02()59 test02() {
60 Variable A(0);
61 Variable B(1);
62 Variable C(2);
63
64 Grid_Generator_System gs1(grid_point(A + 7*B));
65 gs1.insert(parameter(2*C));
66
67 std::stringstream ss1;
68 ss1 << gs1;
69
70 print_generators(gs1, "*** gs1 ***");
71
72 Grid_Generator_System gs2;
73 gs2.insert(grid_point(A + 7*B));
74 gs2.insert(parameter(2*C));
75
76 std::stringstream ss2;
77 ss2 << gs2;
78
79 print_generators(gs2, "*** gs2 ***");
80
81 bool ok = (!ss2.str().compare(ss1.str()));
82
83 return ok;
84 }
85
86 } // namespace
87
88 BEGIN_MAIN
89 DO_TEST(test01);
90 DO_TEST(test02);
91 END_MAIN
92