Debian Codegraph @

tests/integration/arrayvec.rs

raw symbols SCIP
1 use crate::prelude::*;
2 use arrayvec07::{ArrayString, ArrayVec};
3
4 #[test]
5 fn arrayvec07() {
6 test!(ArrayVec<i32, 8>)
7 .assert_snapshot()
8 .assert_allows_ser_roundtrip([
9 ArrayVec::from_iter([]),
10 ArrayVec::from_iter([1, 2, 3, 4, 5, 6, 7, 8]),
11 ])
12 .assert_matches_de_roundtrip(
13 (0..16).map(|len| Value::Array((0..len).map(Value::from).collect())),
14 )
15 .assert_matches_de_roundtrip(arbitrary_values_except(
16 is_array_of_u64,
17 "FIXME schema allows out-of-range positive integers",
18 ));
19 }
20
21 #[test]
22 fn arrayvec07_arraystring() {
23 test!(ArrayString<8>)
24 .assert_identical::<String>()
25 .assert_allows_ser_roundtrip(["".try_into().unwrap(), "12345678".try_into().unwrap()])
26 .assert_matches_de_roundtrip(arbitrary_values_except(
27 Value::is_string,
28 "There's not a good way to express UTF-8 byte length in JSON schema, so schema ignores the ArrayString's capacity.",
29 ));
30 }
31
32 fn is_array_of_u64(value: &Value) -> bool {
33 value
34 .as_array()
35 .is_some_and(|a| a.iter().all(Value::is_u64))
36 }