Skip to content

Commit 78b49d7

Browse files
committed
common: test trivial AsCborValue conversion
1 parent 046b87a commit 78b49d7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/common/tests.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,24 @@ fn test_large_registered_label_with_private_decode_fail() {
441441
expect_err(result, err_msg);
442442
}
443443
}
444+
445+
#[test]
446+
fn test_as_cbor_value() {
447+
let cases = [
448+
Value::Null,
449+
Value::Bool(true),
450+
Value::Bool(false),
451+
Value::from(128),
452+
Value::from(-1),
453+
Value::Bytes(vec![1, 2]),
454+
Value::Text("string".to_owned()),
455+
Value::Array(vec![Value::from(0)]),
456+
Value::Map(vec![]),
457+
Value::Tag(1, Box::new(Value::from(0))),
458+
Value::Float(1.054571817),
459+
];
460+
for val in cases {
461+
assert_eq!(val, Value::from_cbor_value(val.clone()).unwrap());
462+
assert_eq!(val, val.clone().to_cbor_value().unwrap());
463+
}
464+
}

0 commit comments

Comments
 (0)