File: array_string_value.rs

package info (click to toggle)
rust-zvariant 5.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 844 kB
  • sloc: makefile: 2
file content (18 lines) | stat: -rw-r--r-- 550 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#[cfg(feature = "arrayvec")]
#[test]
fn array_string_value() {
    use arrayvec::ArrayString;
    use std::str::FromStr;
    use zvariant::{LE, serialized::Context, to_bytes};

    #[macro_use]
    mod common {
        include!("common.rs");
    }
    let s = ArrayString::<32>::from_str("hello world!").unwrap();
    let ctxt = Context::new_dbus(LE, 0);
    let encoded = to_bytes(ctxt, &s).unwrap();
    assert_eq!(encoded.len(), 17);
    let decoded: ArrayString<32> = encoded.deserialize().unwrap().0;
    assert_eq!(&decoded, "hello world!");
}