From 596d4d37b1c2c75d2834276bb22007cac718b781 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 29 Aug 2019 09:21:34 +0300 Subject: [PATCH] Refactor serde tests into own module --- tests/integration.rs | 15 +++------------ tests/serde.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 tests/serde.rs diff --git a/tests/integration.rs b/tests/integration.rs index 561e66f..5d7012b 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -2,6 +2,9 @@ extern crate evalexpr; use evalexpr::{error::*, *}; +#[cfg(feature = "serde")] +mod serde; + #[test] fn test_unary_examples() { assert_eq!(eval("3"), Ok(Value::Int(3))); @@ -589,18 +592,6 @@ fn test_strings() { assert_eq!(eval("\"a\" < \"b\""), Ok(Value::from(true))); } -#[cfg(feature = "serde")] -#[test] -fn test_serde() { - let strings = ["3", "4+4", "21^(2*2)--3>5||!true"]; - - for string in &strings { - let manual_tree = build_operator_tree(string).unwrap(); - let serde_tree: Node = ron::de::from_str(&format!("\"{}\"", string)).unwrap(); - assert_eq!(manual_tree.eval(), serde_tree.eval()); - } -} - #[test] fn test_tuple_definitions() { assert_eq!(eval_empty("()"), Ok(())); diff --git a/tests/serde.rs b/tests/serde.rs new file mode 100644 index 0000000..bb261d1 --- /dev/null +++ b/tests/serde.rs @@ -0,0 +1,12 @@ +use evalexpr::{build_operator_tree, Node}; + +#[test] +fn test_serde() { + let strings = ["3", "4+4", "21^(2*2)--3>5||!true"]; + + for string in &strings { + let manual_tree = build_operator_tree(string).unwrap(); + let serde_tree: Node = ron::de::from_str(&format!("\"{}\"", string)).unwrap(); + assert_eq!(manual_tree.eval(), serde_tree.eval()); + } +} \ No newline at end of file