diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:19 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:19 +0100 |
commit | b4266e59e5b0ced3fcd74a4b0871a5b32e46e0ac (patch) | |
tree | d0da751d9bc6982e47f637b0f8b0bff90d91c5b3 /stockton-types/tests/ent_map.rs | |
parent | b2fbd5116b66a3560639bdcbad914c52b43e878e (diff) |
feat(types): allow entity mapper to fail and fix possible ent_map! panic
Diffstat (limited to 'stockton-types/tests/ent_map.rs')
-rw-r--r-- | stockton-types/tests/ent_map.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/stockton-types/tests/ent_map.rs b/stockton-types/tests/ent_map.rs index 107620d..6c799ff 100644 --- a/stockton-types/tests/ent_map.rs +++ b/stockton-types/tests/ent_map.rs @@ -83,14 +83,14 @@ fn ent_map_macro() { attributes: map![ "classname" => "A" ] - }).downcast_ref::<A>().unwrap(), &A); + }).unwrap().downcast_ref::<A>().unwrap(), &A); assert_eq!(map_func(&BSPEntity { attributes: map![ "classname" => "B", "data" => "foobar" ] - }).downcast_ref::<B>().unwrap(), &B { data: "foobar".to_string() }); + }).unwrap().downcast_ref::<B>().unwrap(), &B { data: "foobar".to_string() }); assert_eq!(map_func(&BSPEntity { attributes: map![ @@ -98,5 +98,18 @@ fn ent_map_macro() { "data" => "foobar", "into" => "a b c" ] - }).downcast_ref::<C>().unwrap(), &C { data2: "foobar".to_string(), into: CustomStruct { one: 1, two: 2, three: 3 } }); + }).unwrap().downcast_ref::<C>().unwrap(), &C { data2: "foobar".to_string(), into: CustomStruct { one: 1, two: 2, three: 3 } }); + + assert!(map_func(&BSPEntity { + attributes: map![ + "classname" => "D" + ] + }).is_none()); + + assert!(map_func(&BSPEntity { + attributes: map![ + "classname" => "B", + "ebeb" => "foobar" + ] + }).is_none()); }
\ No newline at end of file |