Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlalbers committed Sep 28, 2024
1 parent d2c94b2 commit cda746e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,31 @@ def test_add_constraint(self):
self.assertTrue(c_iter.state(0))
self.assertTrue(c_direct.state(0))

def test_feasible(self):
model = Model()
i = model.integer()
c = model.constant(5)
model.add_constraint(i <= c)

# Check expected exception if no states initialize
with self.assertRaises(ValueError):
model.feasible(0)

model.states.resize(1)
i.set_state(0, 1)

# Check that True is returned for feasible state
self.assertTrue(model.feasible(0))

# Check expected exception for index out of range with initialized state
with self.assertRaises(ValueError):
model.feasible(1)

i.set_state(0, 6)

# Check that False is returned for infeasible state
self.assertFalse(model.feasible(0))

def test_lock(self):
model = Model()

Expand Down

0 comments on commit cda746e

Please sign in to comment.