mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-23 16:07:52 +00:00
encoding/base32: Add encode->decode roundtrip test
Add test_base32_roundtrip() to verify the encode->decode roundtrip preserves data integrity. This test helps ensure our base32 implementation correctly handles the full encode->decode cycle without data loss or corruption.
This commit is contained in:
@@ -125,3 +125,26 @@ test_base32_decode_invalid :: proc(t: ^testing.T) {
|
||||
testing.expect_value(t, err, Error.Invalid_Length)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_base32_roundtrip :: proc(t: ^testing.T) {
|
||||
cases := [?]string{
|
||||
"",
|
||||
"f",
|
||||
"fo",
|
||||
"foo",
|
||||
"foob",
|
||||
"fooba",
|
||||
"foobar",
|
||||
}
|
||||
|
||||
for input in cases {
|
||||
encoded := encode(transmute([]byte)input)
|
||||
decoded, err := decode(encoded)
|
||||
if decoded != nil {
|
||||
defer delete(decoded)
|
||||
}
|
||||
testing.expect_value(t, err, Error.None)
|
||||
testing.expect(t, bytes.equal(decoded, transmute([]byte)input))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user