@@ -24,30 +24,40 @@ def test_split_into_instance_and_solution(self):
24
24
# Input of wrong length are discarded
25
25
self .assertEqual (self .parser .split_into_instance_and_solution (['1' , '2' , '3' ]), ('' , ['' ]))
26
26
27
- def test_parse_instance (self ):
27
+ def test_parse_instance_ints (self ):
28
28
# Entries should be ints
29
29
raw_instance = '1 2 3 4 a'
30
30
self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [1 , 2 , 3 , 4 ])
31
31
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 ])
34
40
41
+ def test_parse_instance_huge_entry (self ):
35
42
# entries should not exceed 2**63
36
- raw_instance = '1 2 3 4 100000000000000000000000000000000000000000000'
43
+ raw_instance = '1 2 3 4 {}' . format ( 2 ** 64 )
37
44
self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 10 ), [1 , 2 , 3 , 4 ])
38
45
46
+ def test_parse_instance_prune (self ):
39
47
# Instance should be cut down to instance_size number of entries
40
48
raw_instance = '1 2 3 4 5 6'
41
49
self .assertEqual (self .parser .parse_instance (raw_instance , instance_size = 5 ), [1 , 2 , 3 , 4 , 5 ])
42
50
51
+ def test_parse_instance_empty (self ):
43
52
# empty inputs should be handled
44
53
self .assertEqual (self .parser .parse_instance ([], instance_size = 3 ), [])
45
54
46
- def test_parse_solution (self ):
55
+ def test_parse_solution_ints (self ):
47
56
# Entries should be ints
48
57
raw_solution = ['0 3 1 2 a' ]
49
58
self .assertEqual (self .parser .parse_solution (raw_solution , instance_size = 10 ), [0 , 3 , 1 , 2 ])
50
59
60
+ def test_parse_solution_size (self ):
51
61
# Entries should not exceed instance_size
52
62
raw_solution = ['0 3 1 2 4' ]
53
63
self .assertEqual (self .parser .parse_solution (raw_solution , instance_size = 3 ), [0 , 3 , 1 , 2 ])
@@ -69,21 +79,30 @@ def setUp(self) -> None:
69
79
70
80
def test_verify_semantics_of_instance (self ):
71
81
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 ):
72
84
self .assertFalse (self .verifier .verify_semantics_of_instance ([], instance_size = 10 ))
73
85
74
- def test_verify_semantics_of_solution (self ):
86
+ def test_verify_semantics_of_solution_empty (self ):
75
87
self .assertFalse (self .verifier .verify_semantics_of_solution ([], 10 , solution_type = False ))
88
+
89
+ def test_verify_semantics_of_solution_too_short (self ):
76
90
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 ):
77
93
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 ):
78
96
self .assertTrue (self .verifier .verify_semantics_of_solution ([0 , 3 , 1 , 2 ], 10 , solution_type = False ))
79
97
80
- def test_verify_solution_against_instance (self ):
98
+ def test_verify_solution_against_instance_normal (self ):
81
99
# Valid solutions should be accepted
82
100
instance = [1 , 2 , 3 , 4 ]
83
101
solution = [0 , 3 , 1 , 2 ]
84
102
self .assertTrue (self .verifier .verify_solution_against_instance (instance ,
85
103
solution , instance_size = 10 , solution_type = False ))
86
104
105
+ def test_verify_solution_against_instance_wrong (self ):
87
106
# Invalid solutions should not be accepted
88
107
instance = [1 , 2 , 3 , 4 ]
89
108
solution = [0 , 1 , 2 , 3 ]
0 commit comments