use atproto::base32::{LOWER, decode, encode}; #[test] fn reads_only_what_it_writes() { // RFC 4648's vectors, lower case and unpadded. for (bytes, text) in [ (&b""[..], ""), (b"f", "my"), (b"fo", "mzxq"), (b"foo", "mzxw6"), (b"foobar", "mzxw6ytboi"), ] { assert_eq!(encode(LOWER, bytes), text); assert_eq!(decode(LOWER, text).as_deref(), Some(bytes)); } // Not of the alphabet, bits left over set, or a character too many. for bad in ["m1", "mz", "mzx", "maa", "MY"] { assert_eq!(decode(LOWER, bad), None, "{bad}"); } }