Refactor serde tests into own module
This commit is contained in:
parent
8c6228c3d9
commit
596d4d37b1
@ -2,6 +2,9 @@ extern crate evalexpr;
|
|||||||
|
|
||||||
use evalexpr::{error::*, *};
|
use evalexpr::{error::*, *};
|
||||||
|
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
|
mod serde;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unary_examples() {
|
fn test_unary_examples() {
|
||||||
assert_eq!(eval("3"), Ok(Value::Int(3)));
|
assert_eq!(eval("3"), Ok(Value::Int(3)));
|
||||||
@ -589,18 +592,6 @@ fn test_strings() {
|
|||||||
assert_eq!(eval("\"a\" < \"b\""), Ok(Value::from(true)));
|
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]
|
#[test]
|
||||||
fn test_tuple_definitions() {
|
fn test_tuple_definitions() {
|
||||||
assert_eq!(eval_empty("()"), Ok(()));
|
assert_eq!(eval_empty("()"), Ok(()));
|
||||||
|
12
tests/serde.rs
Normal file
12
tests/serde.rs
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user