use cbor_macro::{cbo, cbor};
use cboritem::CborItem;
pub const TEST_CONST_CBOR: CborItem<'static> = cbor!(1);
pub const TEST_CONST_CBO: CborItem<'static> = cbo!(r#"1"#);
#[test]
fn test_simple() {
assert_eq!([0], *cbor!(0));
assert_eq!([1], cbor!(1).as_ref());
assert_eq!([0x19, 0x30, 0x39], &cbor!(12345)[..]);
}
#[test]
fn test_plainstring() {
assert_eq!([0x62, 0x63, 0x64], *cbor!("cd"));
assert_eq!([0x41, 0x63], *cbor!('c'));
}
#[test]
fn test_nonrust() {
assert_eq!([0xc6, 0x0a], *cbor!(6(10)));
assert_eq!([0x82, 0x01, 0x02], *cbor!([1, / comment / 2]));
assert_eq!(
[0x83, 0x01, 0x02, 0x03],
*cbor!([
1,
/ comment - even complex ones are okay(ish) / 2,
3
])
);
assert_eq!([0xa1, 0x01, 0x02], *cbor!({1: 2}));
}
#[test]
fn test_complex() {
use cbor_macro::cbo;
assert_eq!([0], *cbo!(r#"0"#));
assert_eq!(
[0x42, 0x43, 0x44],
*cbo!(
r#"
'CD'
"#
)
);
}
#[test]
fn pretty() {
use cbor_macro::{cbor, pretty};
assert_eq!(cbor!(1), pretty!("01 # unsigned(1)"));
}