
Module: ppl/ppl Branch: devel Commit: f45c2558c69e3e906ac214b9f33c10813250d664 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=f45c2558c69e3...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Thu Nov 19 16:42:50 2015 +0100
In Java, throw an exception when trying to build a disequality.
---
.../Java/parma_polyhedra_library/Constraint.java | 2 + .../Java/tests/Parma_Polyhedra_Library_test2.java | 22 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/interfaces/Java/parma_polyhedra_library/Constraint.java b/interfaces/Java/parma_polyhedra_library/Constraint.java index fbcc9c6..9df78c5 100644 --- a/interfaces/Java/parma_polyhedra_library/Constraint.java +++ b/interfaces/Java/parma_polyhedra_library/Constraint.java @@ -47,6 +47,8 @@ public class Constraint { */ public Constraint(Linear_Expression le1, Relation_Symbol rel_sym, Linear_Expression le2) { + if (rel_sym == Relation_Symbol.NOT_EQUAL) + throw new Invalid_Argument_Exception("Invalid relation symbol"); lhs = le1.clone(); rhs = le2.clone(); kind = rel_sym; diff --git a/interfaces/Java/tests/Parma_Polyhedra_Library_test2.java b/interfaces/Java/tests/Parma_Polyhedra_Library_test2.java index 6e11183..a040e16 100644 --- a/interfaces/Java/tests/Parma_Polyhedra_Library_test2.java +++ b/interfaces/Java/tests/Parma_Polyhedra_Library_test2.java @@ -51,6 +51,28 @@ public class Parma_Polyhedra_Library_test2 { max_dimension); }
+ public static boolean test03() { + Linear_Expression_Variable le_a + = new Linear_Expression_Variable(new Variable(0)); + Linear_Expression le_zero + = new Linear_Expression_Coefficient(new Coefficient("0")); + try { + Constraint c = new Constraint(le_a, + Relation_Symbol.NOT_EQUAL, + le_zero); + } + catch (Invalid_Argument_Exception e) { + PPL_Test.println_if_noisy("Expected invalid argument exception" + + " caught!"); + PPL_Test.println_if_noisy(e.getMessage()); + return true; + } + PPL_Test.println_if_noisy("Expected invalid argument exception" + + " NOT caught!"); + return false; + } + + public static void main(String[] args) { Parma_Polyhedra_Library.initialize_library(); boolean test_result_ok =