11package anagram
22
3- import " core:slice "
3+ import " core:fmt "
44import " core:testing"
55
6+ expect_slices_match :: proc (t: ^testing.T, actual, expected: []$E , loc := #caller_location ) {
7+ result := fmt.aprintf (" %v" , actual)
8+ exp_str := fmt.aprintf (" %v" , expected)
9+ defer {
10+ delete (result)
11+ delete (exp_str)
12+ }
13+ testing.expect_value (t, result, exp_str, loc = loc)
14+ }
15+
616@(test)
717// / description = no matches
818test_no_matches :: proc (t: ^testing.T) {
@@ -13,7 +23,7 @@ test_no_matches :: proc(t: ^testing.T) {
1323 result := find_anagrams (word, candidates[:])
1424 defer delete (result)
1525
16- testing. expect (t, slice. equal ( result, expected[:]) )
26+ expect_slices_match (t, result, expected[:])
1727}
1828
1929@(test)
@@ -26,7 +36,7 @@ test_detects_two_anagrams :: proc(t: ^testing.T) {
2636 result := find_anagrams (word, candidates[:])
2737 defer delete (result)
2838
29- testing. expect (t, slice. equal ( result, expected[:]) )
39+ expect_slices_match (t, result, expected[:])
3040}
3141
3242@(test)
@@ -39,7 +49,7 @@ test_does_not_detect_anagram_subsets :: proc(t: ^testing.T) {
3949 result := find_anagrams (word, candidates[:])
4050 defer delete (result)
4151
42- testing. expect (t, slice. equal ( result, expected[:]) )
52+ expect_slices_match (t, result, expected[:])
4353}
4454
4555@(test)
@@ -52,7 +62,7 @@ test_detects_anagram :: proc(t: ^testing.T) {
5262 result := find_anagrams (word, candidates[:])
5363 defer delete (result)
5464
55- testing. expect (t, slice. equal ( result, expected[:]) )
65+ expect_slices_match (t, result, expected[:])
5666}
5767
5868@(test)
@@ -65,7 +75,7 @@ test_detects_three_anagrams :: proc(t: ^testing.T) {
6575 result := find_anagrams (word, candidates[:])
6676 defer delete (result)
6777
68- testing. expect (t, slice. equal ( result, expected[:]) )
78+ expect_slices_match (t, result, expected[:])
6979}
7080
7181@(test)
@@ -78,7 +88,7 @@ test_detects_multiple_anagrams_with_different_case :: proc(t: ^testing.T) {
7888 result := find_anagrams (word, candidates[:])
7989 defer delete (result)
8090
81- testing. expect (t, slice. equal ( result, expected[:]) )
91+ expect_slices_match (t, result, expected[:])
8292}
8393
8494@(test)
@@ -91,7 +101,7 @@ test_does_not_detect_non_anagrams_with_identical_checksum :: proc(t: ^testing.T)
91101 result := find_anagrams (word, candidates[:])
92102 defer delete (result)
93103
94- testing. expect (t, slice. equal ( result, expected[:]) )
104+ expect_slices_match (t, result, expected[:])
95105}
96106
97107@(test)
@@ -104,7 +114,7 @@ test_detects_anagrams_case_insensitively :: proc(t: ^testing.T) {
104114 result := find_anagrams (word, candidates[:])
105115 defer delete (result)
106116
107- testing. expect (t, slice. equal ( result, expected[:]) )
117+ expect_slices_match (t, result, expected[:])
108118}
109119
110120@(test)
@@ -117,7 +127,7 @@ test_detects_anagrams_using_case_insensitive_subject :: proc(t: ^testing.T) {
117127 result := find_anagrams (word, candidates[:])
118128 defer delete (result)
119129
120- testing. expect (t, slice. equal ( result, expected[:]) )
130+ expect_slices_match (t, result, expected[:])
121131}
122132
123133@(test)
@@ -130,7 +140,7 @@ test_detects_anagrams_using_case_insensitive_possible_matches :: proc(t: ^testin
130140 result := find_anagrams (word, candidates[:])
131141 defer delete (result)
132142
133- testing. expect (t, slice. equal ( result, expected[:]) )
143+ expect_slices_match (t, result, expected[:])
134144}
135145
136146@(test)
@@ -143,7 +153,7 @@ test_does_not_detect_an_anagram_if_the_original_word_is_repeated :: proc(t: ^tes
143153 result := find_anagrams (word, candidates[:])
144154 defer delete (result)
145155
146- testing. expect (t, slice. equal ( result, expected[:]) )
156+ expect_slices_match (t, result, expected[:])
147157}
148158
149159@(test)
@@ -156,7 +166,7 @@ test_anagrams_must_use_all_letters_exactly_once :: proc(t: ^testing.T) {
156166 result := find_anagrams (word, candidates[:])
157167 defer delete (result)
158168
159- testing. expect (t, slice. equal ( result, expected[:]) )
169+ expect_slices_match (t, result, expected[:])
160170}
161171
162172@(test)
@@ -169,7 +179,7 @@ test_words_are_not_anagrams_of_themselves :: proc(t: ^testing.T) {
169179 result := find_anagrams (word, candidates[:])
170180 defer delete (result)
171181
172- testing. expect (t, slice. equal ( result, expected[:]) )
182+ expect_slices_match (t, result, expected[:])
173183}
174184
175185@(test)
@@ -184,7 +194,7 @@ test_words_are_not_anagrams_of_themselves_even_if_letter_case_is_partially_diffe
184194 result := find_anagrams (word, candidates[:])
185195 defer delete (result)
186196
187- testing. expect (t, slice. equal ( result, expected[:]) )
197+ expect_slices_match (t, result, expected[:])
188198}
189199
190200@(test)
@@ -199,7 +209,7 @@ test_words_are_not_anagrams_of_themselves_even_if_letter_case_is_completely_diff
199209 result := find_anagrams (word, candidates[:])
200210 defer delete (result)
201211
202- testing. expect (t, slice. equal ( result, expected[:]) )
212+ expect_slices_match (t, result, expected[:])
203213}
204214
205215@(test)
@@ -212,7 +222,7 @@ test_words_other_than_themselves_can_be_anagrams :: proc(t: ^testing.T) {
212222 result := find_anagrams (word, candidates[:])
213223 defer delete (result)
214224
215- testing. expect (t, slice. equal ( result, expected[:]) )
225+ expect_slices_match (t, result, expected[:])
216226}
217227
218228@(test)
@@ -225,7 +235,7 @@ test_handles_case_of_greek_letters :: proc(t: ^testing.T) {
225235 result := find_anagrams (word, candidates[:])
226236 defer delete (result)
227237
228- testing. expect (t, slice. equal ( result, expected[:]) )
238+ expect_slices_match (t, result, expected[:])
229239}
230240
231241@(test)
@@ -238,5 +248,5 @@ test_different_characters_may_have_the_same_bytes :: proc(t: ^testing.T) {
238248 result := find_anagrams (word, candidates[:])
239249 defer delete (result)
240250
241- testing. expect (t, slice. equal ( result, expected[:]) )
251+ expect_slices_match (t, result, expected[:])
242252}
0 commit comments