test; add basic json for testing

上级 4a556df9
......@@ -152,4 +152,34 @@ impl IRawGrammar {
first_line_match: None,
}
}
}
#[cfg(test)]
mod tests {
use serde::{Deserialize, Serialize};
use serde_json::Result;
#[derive(Serialize, Deserialize)]
struct Person {
name: String,
age: u8,
phones: Vec<String>,
}
#[test]
fn should_convert_json() {
let data = r#"
{
"name": "John Doe",
"age": 43,
"phones": [
"+44 1234567",
"+44 2345678"
]
}"#;
let p: Person = serde_json::from_str(data).unwrap();
assert_eq!(43, p.age)
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册