File: ppl_java_tests_common

package info (click to toggle)
ppl 1%3A1.2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 44,328 kB
  • sloc: cpp: 212,085; sh: 12,176; makefile: 7,192; perl: 6,333; java: 2,220; ansic: 1,842; ml: 1,132; sed: 80
file content (197 lines) | stat: -rw-r--r-- 7,437 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/* Common code for the PPL Java interface tests.
   Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
   Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)

This file is part of the Parma Polyhedra Library (PPL).

The PPL is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

The PPL is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.

For the most up-to-date information see the Parma Polyhedra Library
site: http://bugseng.com/products/ppl/ . */

import parma_polyhedra_library.*;

public class ppl_java_generated_tests {
    static {
        try {
            System.loadLibrary("ppl_java");
        }
        catch (UnsatisfiedLinkError  e) {
            System.out.println("Unable to load the library");
            System.out.println(e.getMessage());
            System.exit(-1);
        }
    }

    // Success state.
    static boolean globally_ok;

    // Common stuff. We can add other objects if we need them later.
    static Coefficient coeff_0;
    static Coefficient coeff_5;
    static Variable var_C;
    static Variables_Set var_set_A;
    static Linear_Expression le_A;

    static Constraint constraint1;
    static Constraint constraint2;
    static Congruence congruence1;
    static Generator generator1;
    static Grid_Generator grid_generator1;

    static Constraint_System constraints1;
    static Constraint_System constraints2;
    static Congruence_System congruences1;
    static Congruence_System congruences2;
    static Generator_System generators1;
    static Grid_Generator_System grid_generators1;

    static By_Reference<Boolean> bool_by_ref1;
    static By_Reference<Boolean> bool_by_ref2;
    static By_Reference<Integer> int_by_ref1;
    static By_Reference<Integer> zero_by_ref1;

    static Partial_Function partial_function;

    // Common initialization.
    public static void initialize() {

        // Initialize output variables.
        PPL_Test.initialize();

        // Coefficient declaration.
        coeff_0 = new Coefficient("0");
        Coefficient coeff_1 = new Coefficient(1);
        Coefficient coeff_2 = new Coefficient(2);
        Coefficient coeff_4 = new Coefficient(4);
        coeff_5 = new Coefficient("5");
        Coefficient coeff_10 = new Coefficient("10");

        // Variable declarations.
        Variable A = new Variable(0);
        Variable C = new Variable(2);
        var_C = C;
        var_set_A = new Variables_Set();
        var_set_A.add(A);

        // Linear_Expression declarations.
        Linear_Expression le_0 = new Linear_Expression_Coefficient(coeff_0);
        Linear_Expression le_5 = new Linear_Expression_Coefficient(coeff_5);
        le_A = new Linear_Expression_Variable(A);
        Linear_Expression le_2A = le_A.times(coeff_2);
        Linear_Expression le_C = new Linear_Expression_Variable(C);
        Linear_Expression le_2A_plus_C = le_2A.sum(le_C);
        Linear_Expression le_40A_plus_10C = le_2A_plus_C.times(coeff_10);

        PPL_Test.print_if_noisy("Printing a linear expression (2A + C): ");
        PPL_Test.println_if_noisy(le_2A_plus_C.toString());

        // Constraint declarations.
        Constraint c_5_geq_0
          = new Constraint(le_5, Relation_Symbol.GREATER_OR_EQUAL, le_0);
        constraint1 = c_5_geq_0;
        Constraint c_C_eq_5
          = new Constraint(le_C, Relation_Symbol.EQUAL, le_5);
        Constraint c_2A_eq_5
          = new Constraint(le_2A, Relation_Symbol.EQUAL, le_5);
        Constraint c_2A_plus_C_eq_2A
          = new Constraint(le_2A_plus_C, Relation_Symbol.EQUAL, le_2A);
        Constraint c_2A_plus_C_geq_5
          = new Constraint(le_2A_plus_C,
                           Relation_Symbol.GREATER_OR_EQUAL,
                           le_5);
        PPL_Test.print_if_noisy("Printing a constraint (2A + C >= 5): ");
        PPL_Test.println_if_noisy(c_2A_plus_C_geq_5.toString());

        Congruence cg_2A_eq_5 = new Congruence(le_2A, le_5, coeff_0);
        Congruence cg_C_eq_5 = new Congruence(le_C, le_5, coeff_0);
        Congruence cg_C_int = new Congruence(le_C, le_0, coeff_1);
        congruence1 = cg_2A_eq_5;
        PPL_Test.print_if_noisy("Printing a congruence (2A == 5): ");
        PPL_Test.println_if_noisy(cg_2A_eq_5.toString());

        // Constraint_System declarations.
        constraints1 = new Constraint_System();
        constraints1.add(c_5_geq_0);
        constraints1.add(c_C_eq_5);
        PPL_Test.print_if_noisy("Printing a constraint system (C == 5):");
        PPL_Test.println_if_noisy(constraints1.toString());

        constraints2 = new Constraint_System();
        constraints2.add(c_2A_plus_C_eq_2A);
        constraints2.add(c_2A_eq_5);

        congruences1 = new Congruence_System();
        congruences1.add(cg_2A_eq_5);
        congruences1.add(cg_C_eq_5);
        PPL_Test.print_if_noisy("Printing a congruence system: ");
        PPL_Test.println_if_noisy(congruences1.toString());

        congruences2 = new Congruence_System();
        congruences2.add(cg_C_int);

        // Generator declarations.
        Generator g1 = Generator.point(le_40A_plus_10C, coeff_1);
        generator1 = g1;
        Generator g2 = Generator.point(le_40A_plus_10C, coeff_2);
        Generator g4 = Generator.point(le_A, coeff_4);
        PPL_Test.print_if_noisy("Printing a generator (p(40A + 10C)):");
        PPL_Test.println_if_noisy(g1.toString());

        // Generator_System declaration.
        generators1 = new Generator_System();
        generators1.add(g1);
        generators1.add(g2);
        generators1.add(g4);
        PPL_Test.print_if_noisy("Printing a generator system: ");
        PPL_Test.println_if_noisy(generators1.toString());

        // Grid_Generator declarations.
        Grid_Generator gg1
          = Grid_Generator.grid_point(le_40A_plus_10C, coeff_1);
        grid_generator1 = gg1;
        Grid_Generator gg2
          = Grid_Generator.grid_point(le_40A_plus_10C, coeff_2);
        Grid_Generator gg4
          = Grid_Generator.grid_point(le_A, coeff_4);

        // Grid_Generator_System declaration.
        grid_generators1 = new Grid_Generator_System();
        grid_generators1.add(gg1);
        grid_generators1.add(gg2);
        grid_generators1.add(gg4);

        bool_by_ref1 = new By_Reference<Boolean>(true);
        bool_by_ref2 = new By_Reference<Boolean>(true);

        int_by_ref1 = new By_Reference<Integer>(1);
        zero_by_ref1 = new By_Reference<Integer>(0);

        partial_function = new Partial_Function();
        partial_function.insert(0, 2);
        partial_function.insert(2, 0);
        partial_function.insert(1, 1);
    }

    // Helper method.
    static void report_success_or_failure(boolean locally_ok) {
        if (locally_ok)
            PPL_Test.println_if_noisy("Success");
        else {
            PPL_Test.println_if_noisy("Failure");
            globally_ok = false;
        }
    }