MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / test_basis

Function test_basis

flow-rs/src/config/parser.rs:93–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91
92 #[test]
93 fn test_basis() -> Result<()> {
94 let temp_dir = tempfile::tempdir()?;
95 let file1_path = temp_dir.path().join("a.toml");
96 let file2_path = temp_dir.path().join("b.toml");
97 let mut file1 = std::fs::File::create(&file1_path)?;
98 write!(
99 file1,
100 "{}",
101 r#"
102include=["./b.toml"]
103a=1
104b="string in a"
105c=[1,2,3]
106d=[4,5,6]
107e={a=1, b=2}"#
108 )?;
109 let mut file2 = std::fs::File::create(&file2_path)?;
110 write!(
111 file2,
112 "{}",
113 r#"
114include=[]
115a=2
116b="string in b"
117c=[4,5,6]
118d=[1,2,3]
119e={c=3, b=4}"#
120 )?;
121 let config: Config = Parser::from_file(&file1_path, None)?;
122 assert_eq!(config.a, 1);
123 assert_eq!(config.b, "string in a");
124 assert_eq!(config.c, vec![1, 2, 3, 4, 5, 6]);
125 assert_eq!(
126 config
127 .d
128 .difference(&(1..=6).collect::<HashSet<i32>>())
129 .count(),
130 0
131 );
132 assert_eq!(config.e.len(), 3);
133 assert_eq!(config.e["a"], 1);
134 assert_eq!(config.e["b"], 2);
135 assert_eq!(config.e["c"], 3);
136 Ok(())
137 }
138
139 #[test]
140 #[should_panic]

Callers

nothing calls this directly

Calls 1

createFunction · 0.85

Tested by

no test coverage detected