Debian Codegraph @

tests/canonical.rs

raw symbols SCIP
1 #[cfg(feature = "std")]
2 mod std_testsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/ {
3 use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::valuerust-analyzer cargo serde_cbor_2 0.13.0 value/::Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#;
4
5 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
6 fn integer_canonical_sort_orderrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/integer_canonical_sort_order().() {
7 let expected = [
8 0,
9 23,
10 24,
11 255,
12 256,
13 65535,
14 65536,
15 4294967295,
16 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().1,
17 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().24,
18 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().25,
19 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().256,
20 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().257,
21 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().65536,
22 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().65537,
23 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().4294967296,
24 ]
25 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
26 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i))
27 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
28
29 let mut sorted = expected.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
30 sorted.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
31
32 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, sorted);
33 }
34
35 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
36 fn string_canonical_sort_orderrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/string_canonical_sort_order().() {
37 let expected = ["", "a", "b", "aa"]
38 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
39 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))
40 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
41
42 let mut sorted = expected.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
43 sorted.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
44
45 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, sorted);
46 }
47
48 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
49 fn bytes_canonical_sort_orderrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/bytes_canonical_sort_order().() {
50 let expected = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1u8], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8, 0u8]]
51 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
52 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Bytesrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bytes#)
53 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
54
55 let mut sorted = expected.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
56 sorted.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
57
58 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, sorted);
59 }
60
61 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
62 fn simple_data_canonical_sort_orderrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/simple_data_canonical_sort_order().() {
63 let expected = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Boolrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bool#(false), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Boolrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bool#(true), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Nullrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Null#];
64
65 let mut sorted = expected.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
66 sorted.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
67
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, sorted);
69 }
70
71 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
72 fn major_type_canonical_sort_orderrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/major_type_canonical_sort_order().() {
73 let expected = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
74 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(0),
75 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().1),
76 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Bytesrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bytes#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]),
77 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
78 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Nullrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Null#,
79 ];
80
81 let mut sorted = expected.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
82 sorted.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
83
84 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, sorted);
85 }
86
87 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
88 fn test_rfc_examplerust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_rfc_example().() {
89 // See: https://tools.ietf.org/html/draft-ietf-cbor-7049bis-04#section-4.10
90 let expected = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
91 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(10),
92 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(100),
93 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().1),
94 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("z".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()),
95 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("aa".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()),
96 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(100)]),
97 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().1)]),
98 Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Boolrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bool#(false),
99 ];
100 let mut sorted = expected.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
101 sorted.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
102 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, sorted);
103 }
104 }