From 5abbfba2544a4d338eaf89323ccd04c835ea7053 Mon Sep 17 00:00:00 2001 From: freestrings Date: Mon, 17 Jun 2019 11:19:25 +0900 Subject: [PATCH] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EC=97=90=20select=20=EB=8C=80=EC=8B=A0=20select=5Fas?= =?UTF-8?q?=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EA=B2=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/common.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/common.rs b/tests/common.rs index a2884f7..acd2925 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -31,11 +31,15 @@ pub fn read_contents(path: &str) -> String { #[allow(dead_code)] pub fn select_and_then_compare<'a>(path: &str, json: Value, target: Value) { - let mut s = Selector::new(); - let _ = s.str_path(path); - let _ = s.value(&json); - let result = serde_json::to_value(s.select().unwrap()).unwrap(); - assert_eq!(result, target, "{}", path); + let mut selector = Selector::new(); + let result = selector.str_path(path).unwrap() + .value(&json) + .select_as::().unwrap(); + + assert_eq!(result, match target { + Value::Array(vec) => vec, + _ => panic!("Give me the Array!") + }, "{}", path); } #[allow(dead_code)]