1 /* Test Box::is_bounded().
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 x(0);
31 
32   // This is a non-bounded box.
33   TBox box(2);
34   box.add_constraint(x >= 0);
35 
36   print_constraints(box, "*** box ***");
37 
38   return !box.is_bounded();
39 }
40 
41 bool
test02()42 test02() {
43   Variable x(0);
44   Variable y(1);
45 
46   // This is a bounded box (it is a square);
47   TBox box(2);
48   box.add_constraint(x >= 2);
49   box.add_constraint(y >= 2);
50   box.add_constraint(x <= 4);
51   box.add_constraint(y <= 4);
52 
53   print_constraints(box, "*** box ***");
54 
55   return box.is_bounded();
56 }
57 
58 bool
test03()59 test03() {
60   // This is a universal, zero-dimensional box.
61   TBox box;
62 
63   print_constraints(box, "*** box ***");
64 
65   return box.is_bounded();
66 }
67 
68 bool
test04()69 test04() {
70   // This is an empty, zero-dimensional box.
71   TBox box;
72   box.add_constraint(Linear_Expression(-3) >= 0);
73 
74   print_constraints(box, "*** box ***");
75 
76   return box.is_bounded();
77 }
78 
79 bool
test05()80 test05() {
81   // This is an empty box.
82   TBox box(4, EMPTY);
83 
84   print_constraints(box, "*** box ***");
85 
86   return box.is_bounded();
87 }
88 
89 } // namespace
90 
91 BEGIN_MAIN
92   DO_TEST(test01);
93   DO_TEST(test02);
94   DO_TEST(test03);
95   DO_TEST(test04);
96   DO_TEST(test05);
97 END_MAIN
98