Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimosts committed May 10, 2024
1 parent 1bc926a commit ca87df9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_globalconstraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,50 @@ def test_allEqual(self):
self.assertTrue(cp.Model([cp.AllEqual(a,b,False, a | b)]).solve())
#self.assertTrue(cp.Model([cp.AllEqual(x,y,b)]).solve())

def test_increasing(self):
x = cp.intvar(-8, 8)
y = cp.intvar(-7, -1)
b = cp.boolvar()
a = cp.boolvar()
self.assertTrue(cp.Model([cp.Increasing(x,y)]).solve())
self.assertTrue(cp.Model([cp.Increasing(a,b)]).solve())
self.assertTrue(cp.Model([cp.Increasing(x,y,b)]).solve())
z = cp.intvar(2,5)
self.assertFalse(cp.Model([cp.Increasing(z,b)]).solve())

def test_decreasing(self):
x = cp.intvar(-8, 8)
y = cp.intvar(-7, -1)
b = cp.boolvar()
a = cp.boolvar()
self.assertTrue(cp.Model([cp.Decreasing(x,y)]).solve())
self.assertTrue(cp.Model([cp.Decreasing(a,b)]).solve())
self.assertFalse(cp.Model([cp.Decreasing(x,y,b)]).solve())
z = cp.intvar(2,5)
self.assertTrue(cp.Model([cp.Decreasing(z,b)]).solve())

def test_increasing_strict(self):
x = cp.intvar(-8, 8)
y = cp.intvar(-7, -1)
b = cp.boolvar()
a = cp.boolvar()
self.assertTrue(cp.Model([cp.IncreasingStrict(x,y)]).solve())
self.assertTrue(cp.Model([cp.IncreasingStrict(a,b)]).solve())
self.assertTrue(cp.Model([cp.IncreasingStrict(x,y,b)]).solve())
z = cp.intvar(1,5)
self.assertFalse(cp.Model([cp.IncreasingStrict(z,b)]).solve())

def test_decreasing_strict(self):
x = cp.intvar(-8, 8)
y = cp.intvar(-7, 0)
b = cp.boolvar()
a = cp.boolvar()
self.assertTrue(cp.Model([cp.DecreasingStrict(x,y)]).solve())
self.assertTrue(cp.Model([cp.DecreasingStrict(a,b)]).solve())
self.assertFalse(cp.Model([cp.DecreasingStrict(x,y,b)]).solve())
z = cp.intvar(1,5)
self.assertTrue(cp.Model([cp.DecreasingStrict(z,b)]).solve())

def test_circuit(self):
x = cp.intvar(-8, 8)
y = cp.intvar(-7, -1)
Expand Down

0 comments on commit ca87df9

Please sign in to comment.