@@ -24,30 +24,40 @@ def test_split_into_instance_and_solution(self):
2424 # Input of wrong length are discarded
2525 self .assertEqual (self .parser .split_into_instance_and_solution (['1' , '2' , '3' ]), ('' , ['' ]))
2626
27- def test_parse_instance (self ):
27+ def test_parse_instance_ints (self ):
2828 # Entries should be ints
2929 raw_instance = '1 2 3 4 a'
3030 self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [1 , 2 , 3 , 4 ])
3131
32- raw_instance = '1 a 3 4 -10'
33- self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [1 , 3 , 4 ])
32+ def test_parse_instance_too_short (self ):
33+ # Entries should be ints
34+ raw_instance = '1 2 3'
35+ self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [])
36+
37+ def test_parse_instance_negative (self ):
38+ raw_instance = '1 7 3 4 -10'
39+ self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [1 , 7 , 3 , 4 ])
3440
41+ def test_parse_instance_huge_entry (self ):
3542 # entries should not exceed 2**63
36- raw_instance = '1 2 3 4 100000000000000000000000000000000000000000000'
43+ raw_instance = '1 2 3 4 {}' . format ( 2 ** 64 )
3744 self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [1 , 2 , 3 , 4 ])
3845
46+ def test_parse_instance_prune (self ):
3947 # Instance should be cut down to instance_size number of entries
4048 raw_instance = '1 2 3 4 5 6'
4149 self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 5 ), [1 , 2 , 3 , 4 , 5 ])
4250
51+ def test_parse_instance_empty (self ):
4352 # empty inputs should be handled
4453 self .assertEqual (self .parser .parse_instance ([], instance_size = 3 ), [])
4554
46- def test_parse_solution (self ):
55+ def test_parse_solution_ints (self ):
4756 # Entries should be ints
4857 raw_solution = ['0 3 1 2 a' ]
4958 self .assertEqual (self .parser .parse_solution (raw_solution , instance_size = 10 ), [0 , 3 , 1 , 2 ])
5059
60+ def test_parse_solution_size (self ):
5161 # Entries should not exceed instance_size
5262 raw_solution = ['0 3 1 2 4' ]
5363 self .assertEqual (self .parser .parse_solution (raw_solution , instance_size = 3 ), [0 , 3 , 1 , 2 ])
@@ -69,21 +79,30 @@ def setUp(self) -> None:
6979
7080 def test_verify_semantics_of_instance (self ):
7181 self .assertTrue (self .verifier .verify_semantics_of_instance ([1 , 2 , 3 , 4 ], instance_size = 10 ))
82+
83+ def test_verify_semantics_of_instance_empty (self ):
7284 self .assertFalse (self .verifier .verify_semantics_of_instance ([], instance_size = 10 ))
7385
74- def test_verify_semantics_of_solution (self ):
86+ def test_verify_semantics_of_solution_empty (self ):
7587 self .assertFalse (self .verifier .verify_semantics_of_solution ([], 10 , solution_type = False ))
88+
89+ def test_verify_semantics_of_solution_too_short (self ):
7690 self .assertFalse (self .verifier .verify_semantics_of_solution ([0 , 3 , 1 ], 10 , solution_type = False ))
91+
92+ def test_verify_semantics_of_solution_duplicates (self ):
7793 self .assertFalse (self .verifier .verify_semantics_of_solution ([0 , 3 , 1 , 1 ], 10 , solution_type = False ))
94+
95+ def test_verify_semantics_of_solution_normal (self ):
7896 self .assertTrue (self .verifier .verify_semantics_of_solution ([0 , 3 , 1 , 2 ], 10 , solution_type = False ))
7997
80- def test_verify_solution_against_instance (self ):
98+ def test_verify_solution_against_instance_normal (self ):
8199 # Valid solutions should be accepted
82100 instance = [1 , 2 , 3 , 4 ]
83101 solution = [0 , 3 , 1 , 2 ]
84102 self .assertTrue (self .verifier .verify_solution_against_instance (instance ,
85103 solution , instance_size = 10 , solution_type = False ))
86104
105+ def test_verify_solution_against_instance_wrong (self ):
87106 # Invalid solutions should not be accepted
88107 instance = [1 , 2 , 3 , 4 ]
89108 solution = [0 , 1 , 2 , 3 ]
0 commit comments