File: test_strings.rs

package info (click to toggle)
rust-borsh 1.5.7-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,808 kB
  • sloc: makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::common_macro::schema_imports::*;

#[test]
fn test_string() {
    let actual_name = str::declaration();
    assert_eq!("String", actual_name);
    let actual_name = String::declaration();
    assert_eq!("String", actual_name);
    let mut actual_defs = schema_map!();
    String::add_definitions_recursively(&mut actual_defs);
    assert_eq!(
        schema_map! {
            "String" => Definition::Sequence {
                length_width: Definition::DEFAULT_LENGTH_WIDTH,
                length_range: Definition::DEFAULT_LENGTH_RANGE,
                elements: "u8".to_string()
            },
            "u8" => Definition::Primitive(1)
        },
        actual_defs
    );

    let mut actual_defs = schema_map!();
    str::add_definitions_recursively(&mut actual_defs);
    assert_eq!(
        schema_map! {
            "String" => Definition::Sequence {
                length_width: Definition::DEFAULT_LENGTH_WIDTH,
                length_range: Definition::DEFAULT_LENGTH_RANGE,
                elements: "u8".to_string()
             },
            "u8" => Definition::Primitive(1)
        },
        actual_defs
    );
}