File: text_comparisons.rs

package info (click to toggle)
rust-capnp 0.19.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,396 kB
  • sloc: makefile: 2
file content (24 lines) | stat: -rw-r--r-- 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#![cfg(feature = "alloc")]

use capnp::{message, text};

#[test]
pub fn text_comparisons() {
    let mut msg1 = message::Builder::new_default();
    let mut msg2 = message::Builder::new_default();

    msg1.set_root("abcde").unwrap();
    msg2.set_root("fghij").unwrap();

    let str1 = msg1.get_root_as_reader::<text::Reader>().unwrap();
    let str2 = msg2.get_root_as_reader::<text::Reader>().unwrap();

    assert!(str1 < str2);
    assert!(str1 < "zzzz");
    assert!("aaaa" < str2);
    assert_eq!(str1, "abcde");
    assert_eq!(str1, "abcde".to_string());
    assert_eq!("fghij", str2);
    assert_eq!("fghij".to_string(), str2);
    assert_ne!(str1, str2);
}