use hextool;
use hextool::{Convert, Hex, UnHex};
#[test]
fn test_hex() {
let hex = Hex::convert("hello", false, false);
assert_eq!(hex, "68656c6c6f");
let hex = Hex::convert("hello", false, true);
assert_eq!(hex, "68 65 6c 6c 6f");
let hex = Hex::convert("hello", true, false);
assert_eq!(hex, "Input is not valid for 'hex' with numeric flag (-n).");
let hex = Hex::convert("3405691582", true, false);
assert_eq!(hex, "cafebabe");
let hex = Hex::convert("3405691582", true, true);
assert_eq!(hex, "ca fe ba be");
}
#[test]
fn test_unhex() {
let unhex = UnHex::convert("68656c6c6f", false, false);
assert_eq!(unhex, "hello");
let unhex = UnHex::convert("abcdefgabc", false, false);
assert_eq!(unhex, "The highlighted chars can't be converted:\nabcdef\u{1b}[31mg\u{1b}[0mabc.");
let unhex = UnHex::convert("ff", true, false);
assert_eq!(unhex, "255");
let unhex = UnHex::convert("0xff", true, false);
assert_eq!(unhex, "255");
let unhex = UnHex::convert("0x41", true, false);
assert_eq!(unhex, "65");
let unhex = UnHex::convert("0x41", false, false);
assert_eq!(unhex, "A");
let unhex = UnHex::convert("cafebabe", true, false);
assert_eq!(unhex, "3405691582");
}