Skip to content

Commit

Permalink
chore(tests): use %q for printing
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Feb 7, 2024
1 parent 5fd6e9b commit ef23f3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/anonymize/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ func TestHashToSHA256B64(t *testing.T) {
// original string, expected hash (sha256 returns binary and is encoded to base64)
tests := []testPair{
{"", "47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU="},
{"a", "ypeBEsobvcr6wjGzmiPcTaeG7_gUfE5yuYB3ha_uSLs="},
{"ab", "-44g_C5MPySMYMOb1lLzwTRymLuXe4tNWQO4UFViBgM="},
{"abc", "ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0="},
{"banana death", "e8kN64XJ4Icr6Tl9VYrBRj50UJCPlyillODm3vVNk2g="},
{"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", "LYwvbZeMohcStfbeNsnTH6jpak-l2P-LAYjfuefBcbs="},
{"Ćao hrčko!! 🐹", "_Y3KWzrx2UkeTp8b--48L6OFgv51JWPlZArjoFOrmbw="},
}

for _, test := range tests {
hash := anonymize.HashToSHA256B64(test.orig)
if hash != test.expected {
t.Errorf("HashToSHA256B64(\"%v\") = \"%v\", want \"%v\"", test.orig, hash, test.expected)
t.Errorf("HashToSHA256B64(%q) = %q, want %q", test.orig, hash, test.expected)
}
}
}
6 changes: 3 additions & 3 deletions src/anonymize/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestDeduplicate(t *testing.T) {
for _, test := range tests {
deduplicated := anonymize.Deduplicate(test.orig)
if deduplicated != test.expected {
t.Errorf("deduplicate(\"%v\") = \"%v\", want \"%v\"", test.orig, deduplicated, test.expected)
t.Errorf("deduplicate(%q) = %q, want %q", test.orig, deduplicated, test.expected)
}
}
}
Expand All @@ -39,7 +39,7 @@ func TestSortString(t *testing.T) {
sorted := anonymize.SortString(test.orig)

if sorted != test.expected {
t.Errorf("SortString(\"%v\") = \"%v\", want \"%v\"", test.orig, sorted, test.expected)
t.Errorf("SortString(%q) = %q, want %q", test.orig, sorted, test.expected)
}
}
}
Expand All @@ -61,7 +61,7 @@ func TestShuffle(t *testing.T) {
shuffledSorted := anonymize.SortString(shuffled)

if shuffledSorted != test.expected {
t.Errorf("SortString(Shuffle(\"%v\")) = \"%v\", want \"%v\"", test.orig, shuffledSorted, test.expected)
t.Errorf("SortString(Shuffle(%q)) = %q, want %q", test.orig, shuffledSorted, test.expected)
}
}
}

0 comments on commit ef23f3c

Please sign in to comment.