use nu_test_support::prelude::*;
#[test]
fn canonical() -> Result {
super::test_canonical("hex")?;
Ok(())
}
#[test]
fn const_() -> Result {
super::test_const("hex")?;
Ok(())
}
#[test]
fn encode() -> Result {
let text = "Ș̗͙̂̏o̲̲̗͗̌͊m̝̊̓́͂ë̡̦̞̤́̌̈́̀ ̥̝̪̎̿ͅf̧̪̻͉͗̈́̍̆u̮̝͌̈́ͅn̹̞̈́̊k̮͇̟͎̂͘y̧̲̠̾̆̕ͅ ̙͖̭͔̂̐t̞́́͘e̢̨͕̽x̥͋t͍̑̔͝";
let encoded = "53CC82CC8FCCA6CC97CD996FCD97CC8CCD8ACCB2CCB2CC976DCC8ACC93CC81CD82CC9D65CD84CC8CCD84CC80CCA6CCA1CC9ECCA420CC8ECCBFCD85CCA5CC9DCCAA66CD97CD84CC8DCC86CCAACCBBCCA7CD8975CD8CCD84CCAECC9DCD856ECD84CC8ACCB9CC9E6BCD98CC82CCAECD87CC9FCD8E79CCBECC95CC86CD85CCB2CCA7CCA020CC82CC90CC99CD96CCADCD9474CC81CD98CC81CC9E65CCBDCCA2CD95CCA878CD8BCCA574CC91CC94CD9DCD8D";
let code = format!("'{text}' | encode hex");
test().run(code).expect_value_eq(encoded)
}
#[test]
fn decode_string() -> Result {
let text = "Very important data";
let encoded = "5665727920696D706F7274616E742064617461";
let code = format!("'{encoded}' | decode hex | decode");
test().run(code).expect_value_eq(text)
}
#[test]
fn decode_case_mixing() -> Result {
let text = "®lnnE¾ˆë";
let mixed_encoded = "c2aE6c6e6E45C2BeCB86c3ab";
let code = format!("'{mixed_encoded}' | decode hex | decode");
test().run(code).expect_value_eq(text)
}