1 /* Test Polyhedron::minimized_generators().
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
26 namespace {
27
28 bool
test01()29 test01() {
30 Variable A(0);
31 Variable B(1);
32
33 Generator_System gs1;
34 gs1.insert(point());
35 gs1.insert(point(B));
36 gs1.insert(line(A));
37 gs1.insert(ray(B));
38 gs1.insert(ray(A + B));
39 gs1.insert(ray(-A + B));
40
41 C_Polyhedron ph1(gs1);
42
43 const Generator_System gs2 = ph1.minimized_generators();
44
45 print_generators(gs2, "*** gs2 ***");
46
47 C_Polyhedron ph2(gs2);
48 Generator_System known_gs;
49 known_gs.insert(point());
50 known_gs.insert(line(A));
51 known_gs.insert(ray(B));
52 C_Polyhedron known_result(known_gs);
53
54 bool ok = (ph2 == known_result);
55
56 print_generators(ph2, "*** ph2 ***");
57
58 return ok;
59 }
60
61 bool
test02()62 test02() {
63 C_Polyhedron ph1(2, EMPTY);
64
65 print_generators(ph1, "*** ph1 ***");
66
67 C_Polyhedron known_result = ph1;
68
69 Generator_System gs = ph1.minimized_generators();
70
71 C_Polyhedron ph2(2, EMPTY);
72 ph2.add_generators(gs);
73
74 bool ok = (ph2 == known_result);
75
76 print_generators(gs, "*** gs ***");
77
78 return ok;
79 }
80
81 } // namespace
82
83 BEGIN_MAIN
84 DO_TEST(test01);
85 DO_TEST(test02);
86 END_MAIN
87