Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_data/tests/string.rs

1.7 KiB, 5 runs

created by r1870400018:287, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1use oxedyne_fe2o3_core::{
2 prelude::*,
3 test::test_it,
4};
5use oxedyne_fe2o3_text::string::Stringer;
6
7
8pub fn test_string(filter: &'static str) -> Outcome<()> {
9
10 res!(test_it(filter, &["To lines 000", "all", "string"], || {
11 let input = Stringer::new(r#"[1, "two", {3: [4, "five", 6]}, [7, 8, 9]]"#);
12 let expected =
13r#"[
14 1,
15 "two",
16 {
17 3: [
18 4,
19 "five",
20 6
21 ]
22 },
23 [
24 7,
25 8,
26 9
27 ]
28]"#;
29 let expected_lines: Vec<_> = expected.split('\n').collect();
30 //for line in &expected_lines {
31 // test!("{}", line);
32 //}
33 let lines = input.to_lines(" ");
34 req!(lines.len(), expected_lines.len());
35 for (i, line) in lines.iter().enumerate() {
36 debug!("{}", line);
37 req!(line, expected_lines[i]);
38 }
39 Ok(())
40 }));
41
42 res!(test_it(filter, &["To lines 010", "all", "string"], || {
43 let input = Stringer::new(r#"(LIST|[(I32|1), (STR|"two"), (OMAP|{(I32|3): (LIST|[(I32|4), (STR|"five"), (I32|6), ]), }), (LIST|[(I32|7), (I32|8), (I32|9), ]), ])"#);
44 let expected =
45r#"(LIST|[
46 (I32|1),
47 (STR|"two"),
48 (OMAP|{
49 (I32|3): (LIST|[
50 (I32|4),
51 (STR|"five"),
52 (I32|6),
53 ]),
54 }),
55 (LIST|[
56 (I32|7),
57 (I32|8),
58 (I32|9),
59 ]),
60])"#;
61 let expected_lines: Vec<_> = expected.split('\n').collect();
62 //for line in &expected_lines {
63 // test!("{}", line);
64 //}
65 let lines = input.to_lines(" ");
66 req!(lines.len(), expected_lines.len());
67 for (i, line) in lines.iter().enumerate() {
68 debug!("{}", line);
69 req!(line, expected_lines[i]);
70 }
71 Ok(())
72 }));
73
74 Ok(())
75}