1 /* Test Polyhedron::is_topologically_closed().
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
32 C_Polyhedron ph1(1);
33 ph1.add_constraint(A >= 0);
34
35 NNC_Polyhedron ph2(2, EMPTY);
36
37 NNC_Polyhedron ph3;
38
39 bool ok = ph1.is_topologically_closed()
40 && ph2.is_topologically_closed()
41 && ph3.is_topologically_closed();
42
43 print_constraints(ph1, "*** ph1 ***");
44 print_constraints(ph2, "*** ph2 ***");
45 print_constraints(ph3, "*** ph3 ***");
46
47 return ok;
48 }
49
50 bool
test02()51 test02() {
52 Variable A(0);
53
54 NNC_Polyhedron ph1(1, EMPTY);
55
56 Generator_System gs1;
57 gs1.insert(point(A));
58 gs1.insert(closure_point());
59 gs1.insert(closure_point(A));
60 ph1.add_generators(gs1);
61
62 bool ok = !ph1.is_topologically_closed();
63
64 print_generators(ph1, "*** ph1 ***");
65
66 return ok;
67 }
68
69 bool
test03()70 test03() {
71 Variable A(0);
72 Variable B(1);
73
74 Generator_System gs;
75 gs.insert(point(0*B));
76 gs.insert(closure_point(-A));
77 gs.insert(closure_point(A));
78 gs.insert(line(A));
79
80 NNC_Polyhedron ph(gs);
81
82 bool ok = ph.is_topologically_closed();
83
84 print_constraints(ph, "*** ph ***");
85 print_generators(ph, "*** ph ***");
86
87 return ok;
88 }
89
90 } // namespace
91
92 BEGIN_MAIN
93 DO_TEST(test01);
94 DO_TEST(test02);
95 DO_TEST(test03);
96 END_MAIN
97