Commit e92f1e4a authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib][test] Add some new asserts; fix typos

parent c5a67f5b
......@@ -143,7 +143,7 @@ def model4():
root.add_transition(node_3, node_4)
node_5 = root.add_simple_node('n5', 0, 0)
tr1 = root.add_transition(node_4, node_5)
tr2 = root.add_transition(node_5, node_3)
root.add_transition(node_5, node_3)
tr1.set_event("hh2")
tr1.set_condition("n1 and n3")
node_i = root.add_input_node('in1', 0, 0)
......@@ -196,6 +196,12 @@ class TestCLUnfolder(unittest.TestCase):
"""
model = model1()
unfolder = create_unfolder(model)
# Test unfolder init and internal dynamic system
assert unfolder._CLUnfolder__shift_step == 2
assert unfolder.shift_step_init == 2
assert unfolder.get_var_number() == 2
# naming and coding variables
cn1 = unfolder.var_dimacs_code('n1')
cn2 = unfolder.var_dimacs_code('n2')
......@@ -214,6 +220,8 @@ class TestCLUnfolder(unittest.TestCase):
res = unfolder.get_var_indexed_name(8) == 'n2_3'
self.assert_(res,'Error in variable name 5')
# Test number of variables
assert unfolder.get_system_var_number() == unfolder.get_var_number()
def test_frontier(self):
......@@ -224,8 +232,8 @@ class TestCLUnfolder(unittest.TestCase):
model = model1()
unfolder = create_unfolder(model)
# test frontier: should be n1
cfr = unfolder.frontier_values[0]
res = unfolder.get_var_name(cfr) == 'n1'
frontier_value = unfolder.frontier_values[0]
res = unfolder.get_var_name(frontier_value) == 'n1'
res = res and (len(unfolder.frontier_values) == 1)
self.assert_(res,'Error in frontier: model1')
......@@ -234,8 +242,8 @@ class TestCLUnfolder(unittest.TestCase):
unfolder = create_unfolder(model)
# test frontier: should be n1
cfr = unfolder.frontier_values[0]
res = unfolder.get_var_name(cfr) == 'n1'
frontier_value = unfolder.frontier_values[0]
res = unfolder.get_var_name(frontier_value) == 'n1'
res = res and (len(unfolder.frontier_values) == 1)
self.assert_(res,'Error in frontier: model2')
......@@ -244,18 +252,17 @@ class TestCLUnfolder(unittest.TestCase):
unfolder = create_unfolder(model)
# test frontier - should be {n1, n3}
cfr = unfolder.frontier_values
res = len(cfr) == 2
res = res and unfolder.get_var_name(cfr[0]) == 'n1'
res = res and unfolder.get_var_name(cfr[1]) == 'n3'
frontier_values = unfolder.frontier_values
res = len(frontier_values) == 2
res = res and unfolder.get_var_name(frontier_values[0]) == 'n1'
res = res and unfolder.get_var_name(frontier_values[1]) == 'n3'
self.assert_(res,'Error in frontier: model3')
# model4
model = model4()
unfolder = create_unfolder(model)
cfr = unfolder.frontier_values
res = len(cfr) == 0
# res = res and unfolder.get_var_name(cfr[0]) == 'n3'
frontier_values = unfolder.frontier_values
res = len(frontier_values) == 0
self.assert_(res,'Error in frontier: model4')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment