diff options
-rw-r--r-- | src/base32.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/base32.zig b/src/base32.zig index c92545b..d8adfd5 100644 --- a/src/base32.zig +++ b/src/base32.zig | |||
@@ -248,17 +248,27 @@ test { | |||
248 | const decoded = "this is a test"; | 248 | const decoded = "this is a test"; |
249 | 249 | ||
250 | var decode_buf: [Decoder.calcSize(encoded.len)]u8 = undefined; | 250 | var decode_buf: [Decoder.calcSize(encoded.len)]u8 = undefined; |
251 | _ = try Decoder.decode(&decode_buf, encoded); | 251 | var decode_res = try Decoder.decode(&decode_buf, encoded); |
252 | 252 | ||
253 | try testing.expectEqualStrings(decoded, &decode_buf); | 253 | try testing.expectEqualStrings(decoded, decode_res); |
254 | |||
255 | var encode_buf: [Encoder.calcSize(decoded.len)]u8 = undefined; | ||
256 | var encode_res = Encoder.encode(&encode_buf, decoded); | ||
257 | |||
258 | try testing.expectEqualStrings(encoded, encode_res); | ||
254 | } | 259 | } |
255 | 260 | ||
256 | test { | 261 | test { |
257 | const encoded = "SNAH7EH5X4P5R2M2RGF3LVAL6NRFIXLN2E67O6FNRUQ4JCQBPL64GEBPLY"; | 262 | const encoded = "SNAH7EH5X4P5R2M2RGF3LVAL6NRFIXLN2E67O6FNRUQ4JCQBPL64GEBPLY"; |
258 | const decoded = [_]u8{ 0x93, 0x40, 0x7f, 0x90, 0xfd, 0xbf, 0x1f, 0xd8, 0xe9, 0x9a, 0x89, 0x8b, 0xb5, 0xd4, 0x0b, 0xf3, 0x62, 0x54, 0x5d, 0x6d, 0xd1, 0x3d, 0xf7, 0x78, 0xad, 0x8d, 0x21, 0xc4, 0x8a, 0x01, 0x7a, 0xfd, 0xc3, 0x10, 0x2f, 0x5e }; | 263 | const decoded = &[_]u8{ 0x93, 0x40, 0x7f, 0x90, 0xfd, 0xbf, 0x1f, 0xd8, 0xe9, 0x9a, 0x89, 0x8b, 0xb5, 0xd4, 0x0b, 0xf3, 0x62, 0x54, 0x5d, 0x6d, 0xd1, 0x3d, 0xf7, 0x78, 0xad, 0x8d, 0x21, 0xc4, 0x8a, 0x01, 0x7a, 0xfd, 0xc3, 0x10, 0x2f, 0x5e }; |
259 | 264 | ||
260 | var decode_buf: [Decoder.calcSize(encoded.len)]u8 = undefined; | 265 | var decode_buf: [Decoder.calcSize(encoded.len)]u8 = undefined; |
261 | _ = try Decoder.decode(&decode_buf, encoded); | 266 | var decode_res = try Decoder.decode(&decode_buf, encoded); |
267 | |||
268 | try testing.expectEqualSlices(u8, decoded, decode_res); | ||
269 | |||
270 | var encode_buf: [Encoder.calcSize(decoded.len)]u8 = undefined; | ||
271 | var encode_res = Encoder.encode(&encode_buf, decoded); | ||
262 | 272 | ||
263 | try testing.expectEqualSlices(u8, &decoded, &decode_buf); | 273 | try testing.expectEqualSlices(u8, encoded, encode_res); |
264 | } | 274 | } |