#![cfg(feature = "text-encode")]
use vsf::types::VsfType;
#[test]
fn frozen_x_huffman_v8() {
let bytes = VsfType::x("octopus".to_string()).flatten();
assert_eq!(
bytes, X_OCTOPUS_V8,
"x wire encoding shifted — this is a format break, see module docs"
);
}
#[test]
fn frozen_x_nfc_equivalence_v8() {
let precomposed = VsfType::x("café".to_string()).flatten();
let decomposed = VsfType::x("cafe\u{0301}".to_string()).flatten();
assert_eq!(precomposed, decomposed, "NFC canonicalization broke");
assert_eq!(precomposed, X_CAFE_V8, "x wire encoding for café shifted");
}
#[test]
fn frozen_a_ascii_v8() {
let bytes = VsfType::a("octopus".to_string()).flatten();
assert_eq!(
bytes, A_OCTOPUS_V8,
"a wire encoding shifted — this is a format break, see module docs"
);
}
#[test]
fn frozen_d_dict_key_v8() {
let bytes = VsfType::d("octopus".to_string()).flatten();
assert_eq!(
bytes, D_OCTOPUS_V8,
"d wire encoding shifted — this is a format break, see module docs"
);
}
const X_OCTOPUS_V8: &[u8] = &[120, 51, 7, 180, 84, 182, 169, 160];
const X_CAFE_V8: &[u8] = &[120, 51, 4, 139, 168, 103, 240];
const A_OCTOPUS_V8: &[u8] = &[97, 51, 7, 111, 99, 116, 111, 112, 117, 115];
const D_OCTOPUS_V8: &[u8] = &[100, 51, 7, 111, 99, 116, 111, 112, 117, 115];
#[test]
#[ignore = "generator — run with --ignored --nocapture to print current wire bytes"]
fn print_current_wire_bytes() {
for (label, bytes) in [
("X_OCTOPUS_V8", VsfType::x("octopus".to_string()).flatten()),
("X_CAFE_V8", VsfType::x("café".to_string()).flatten()),
("A_OCTOPUS_V8", VsfType::a("octopus".to_string()).flatten()),
("D_OCTOPUS_V8", VsfType::d("octopus".to_string()).flatten()),
] {
println!("const {}: &[u8] = &{:?};", label, bytes);
}
}