| 1 | import encoding.base32 |
| 2 | |
| 3 | // TODO: add more tests |
| 4 | |
| 5 | fn test_encode_and_decode() { |
| 6 | input := 'hello v' |
| 7 | |
| 8 | encoded := base32.encode_string_to_string(input) |
| 9 | assert encoded == 'NBSWY3DPEB3A====' |
| 10 | |
| 11 | decoded := base32.decode_string_to_string(encoded) or { panic('error decoding: ${err}') } |
| 12 | assert decoded == input |
| 13 | |
| 14 | encoder_no_padding := base32.new_std_encoding_with_padding(base32.no_padding) |
| 15 | encoded2 := encoder_no_padding.encode_string_to_string(input) |
| 16 | assert encoded2 == 'NBSWY3DPEB3A' |
| 17 | |
| 18 | decoded2 := encoder_no_padding.decode_string_to_string(encoded2) or { |
| 19 | panic('error decoding: ${err}') |
| 20 | } |
| 21 | assert decoded2 == input |
| 22 | } |
| 23 | |