summaryrefslogtreecommitdiff
path: root/src/parameterexpression.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-09-26 21:59:37 +0200
committertroido <troido@protonmail.com>2020-09-26 21:59:37 +0200
commit7630cd991b8fc2be01402a2522115adc56cba4de (patch)
tree1e7d22e71864836b1e233523851b9ade204b8639 /src/parameterexpression.rs
parent0d0586816a87fa1b977f7fa84ee38e639ffccfc5 (diff)
more tests
Diffstat (limited to 'src/parameterexpression.rs')
-rw-r--r--src/parameterexpression.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/parameterexpression.rs b/src/parameterexpression.rs
index 5a313f7..0ff9f1c 100644
--- a/src/parameterexpression.rs
+++ b/src/parameterexpression.rs
@@ -218,3 +218,37 @@ impl<'de> Deserialize<'de> for ParameterExpression {
}
}
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use super::ParameterExpression as PE;
+ use crate::hashmap;
+
+ #[test]
+ fn test_desrialize(){
+ assert_eq!(
+ PE::deserialize(json!("hello")).unwrap(),
+ PE::Constant(Parameter::String("hello".to_string()))
+ );
+ assert_eq!(
+ PE::deserialize(json!(["arg", "hello"])).unwrap(),
+ PE::Argument("hello".to_string())
+ );
+ assert_eq!(
+ PE::deserialize(json!(["list", ["hello", 3]])).unwrap(),
+ PE::List(vec![
+ PE::Constant(Parameter::String("hello".to_string())),
+ PE::Constant(Parameter::Int(3))
+ ])
+ );
+ assert_eq!(
+ PE::deserialize(json!(["template", {"type": "radish", "kwargs": {"health": 10}}])).unwrap(),
+ PE::Template{
+ name: EntityType("radish".to_string()),
+ kwargs: hashmap!{"health".to_string() => PE::Constant(Parameter::Int(10))},
+ save: None
+ }
+ );
+ }
+}
+