-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathlib.rs
More file actions
64 lines (59 loc) · 1.64 KB
/
lib.rs
File metadata and controls
64 lines (59 loc) · 1.64 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#![cfg(test)]
use core::str;
use roxmltree::Document;
use svd_encoder::{Encode, EncodeError};
use svd_parser::{Config, Parse, SVDErrorAt};
use svd_rs as svd;
use xmltree::Element;
mod bad_svd;
/// Generic test helper function
/// Takes an array of (item, xml, xml) pairs where the item implements
/// Parse and Encode and tests object encoding and decoding
pub fn run_test<
T: Parse<Error = SVDErrorAt, Object = T, Config = Config>
+ Encode<Error = EncodeError>
+ core::fmt::Debug
+ PartialEq,
>(
// tests: [(Object, input string, output string)],
tests: &[(T, &str, &str)],
parser_config: Option<Config>,
encoder_config: Option<svd_encoder::Config>,
) {
for t in tests {
let rotree = Document::parse(t.1).unwrap();
let elem = T::parse(
&rotree.root().first_element_child().unwrap(),
&parser_config.unwrap_or(Config::default()),
)
.unwrap();
assert_eq!(
elem, t.0,
"Error parsing xml` (mismatch between parsed and expected)"
);
let tree1 = Element::parse(t.2.as_bytes()).unwrap();
let tree2 = elem
.encode_with_config(&encoder_config.unwrap_or(svd_encoder::Config::default()))
.unwrap();
assert_eq!(
tree1, tree2,
"Error encoding xml (mismatch between encoded and expected)"
);
}
}
mod access;
mod addressblock;
//mod bitrange;
mod cpu;
mod dimelement;
mod endian;
mod enumeratedvalue;
//mod enumeratedvalues;
mod field;
mod interrupt;
mod modifiedwritevalues;
mod register;
//mod registerproperties;
mod cmsis_tests;
mod usage;
mod writeconstraint;