aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
diff options
context:
space:
mode:
authorZoltán Kéri <z@zolk3ri.name>2024-12-30 03:03:50 +0100
committerZoltán Kéri <z@zolk3ri.name>2024-12-30 03:03:50 +0100
commit0d4c0064d961d8a50901afd8c359962b687d1cbd (patch)
tree99ef8631904c2d47a3bb066eae14be4a86d4b630 /core/encoding
parentc9c59edc646082ad9a687a80ccfd4e421d7e15d4 (diff)
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.
Diffstat (limited to 'core/encoding')
-rw-r--r--core/encoding/base32/base32_test.odin23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/encoding/base32/base32_test.odin b/core/encoding/base32/base32_test.odin
index e492f9a85..6589abc42 100644
--- a/core/encoding/base32/base32_test.odin
+++ b/core/encoding/base32/base32_test.odin
@@ -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))
+ }
+}