MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / test_structs

Function test_structs

cel/src/ser.rs:1161–1199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1159
1160 #[test]
1161 fn test_structs() {
1162 // Test Struct serialization
1163 let test_struct = TestCompoundTypes::Struct {
1164 a: 32_i32,
1165 nested: HashMap::from_iter([(
1166 true,
1167 HashMap::from_iter([(
1168 "Test".to_string(),
1169 vec!["a".to_string(), "b".to_string(), "c".to_string()],
1170 )]),
1171 )]),
1172 };
1173 let expected: Value = HashMap::<Key, Value>::from([(
1174 "Struct".into(),
1175 HashMap::<Key, Value>::from_iter([
1176 ("a".into(), 32_i32.into()),
1177 (
1178 "nested".into(),
1179 HashMap::<Key, Value>::from_iter([(
1180 true.into(),
1181 HashMap::<Key, Value>::from_iter([(
1182 "Test".into(),
1183 vec!["a".to_string(), "b".to_string(), "c".to_string()].into(),
1184 )])
1185 .into(),
1186 )])
1187 .into(),
1188 ),
1189 ])
1190 .into(),
1191 )])
1192 .into();
1193 let program = Program::compile("expected.all(key, test[key] == expected[key])").unwrap();
1194 let mut context = Context::default();
1195 context.add_variable("expected", expected).unwrap();
1196 context.add_variable("test", test_struct).unwrap();
1197 let value = program.execute(&context).unwrap();
1198 assert_eq!(value, true.into());
1199 }
1200
1201 #[test]
1202 fn test_maps() {

Callers

nothing calls this directly

Calls 2

add_variableMethod · 0.80
executeMethod · 0.80

Tested by

no test coverage detected