Skip to content

Commit

Permalink
Add a hard-coded test vector for compatibility with ports to other la…
Browse files Browse the repository at this point in the history
…nguages
  • Loading branch information
jbearer committed Jan 22, 2024
1 parent 93be6f0 commit aec12c3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,19 @@ fn test_serde_compressed_checked() {
BlobCompressed(vec![1])
);
}

#[test]
fn test_compat() {
// A hard-coded example, for easily checking compatibility with ports to other languages.
let tag = "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
let data = "~Yeah, we can have spaces and odd stuff—😀 here. ¯⧵_(ツ)_/¯".as_bytes();
let expected = "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789~flllYWgsIHdlIGNhbiBoYXZlIHNwYWNlcyBhbmQgb2RkIHN0dWZm4oCU8J-YgCBoZXJlLiDCr-KntV8o44OEKV8vwq_6";

let tb64 = TaggedBase64::new(tag, data).unwrap();
let s = tb64.to_string();
assert_eq!(
s, expected,
"actual string {s} does not match expected {expected}"
);
assert_eq!(tb64, expected.parse().unwrap());
}

0 comments on commit aec12c3

Please sign in to comment.