From 297606ce8e12b808daee7d5a16c5759df1366a67 Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 17 Jul 2019 02:33:55 +0200 Subject: [PATCH] Move tests of idna to serde-json --- idna/Cargo.toml | 2 +- idna/tests/punycode.rs | 14 ++++++++------ idna/tests/tests.rs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/idna/Cargo.toml b/idna/Cargo.toml index 2f7155441..dbaa9d3ec 100644 --- a/idna/Cargo.toml +++ b/idna/Cargo.toml @@ -20,7 +20,7 @@ name = "unit" [dev-dependencies] rustc-test = "0.3" -rustc-serialize = "0.3" +serde_json = "1.0" [dependencies] unicode-bidi = "0.3" diff --git a/idna/tests/punycode.rs b/idna/tests/punycode.rs index fe5e94edc..1851a32cf 100644 --- a/idna/tests/punycode.rs +++ b/idna/tests/punycode.rs @@ -7,7 +7,9 @@ // except according to those terms. use idna::punycode::{decode, encode_str}; -use rustc_serialize::json::{Json, Object}; +use serde_json::Value; +use serde_json::map::Map; +use std::str::FromStr; use test::TestFn; fn one_test(decoded: &str, encoded: &str) { @@ -37,20 +39,20 @@ fn one_test(decoded: &str, encoded: &str) { } } -fn get_string<'a>(map: &'a Object, key: &str) -> &'a str { +fn get_string<'a>(map: &'a Map, key: &str) -> &'a str { match map.get(&key.to_string()) { - Some(&Json::String(ref s)) => s, + Some(&Value::String(ref s)) => s, None => "", _ => panic!(), } } pub fn collect_tests(add_test: &mut F) { - match Json::from_str(include_str!("punycode_tests.json")) { - Ok(Json::Array(tests)) => { + match Value::from_str(include_str!("punycode_tests.json")) { + Ok(Value::Array(tests)) => { for (i, test) in tests.into_iter().enumerate() { match test { - Json::Object(o) => { + Value::Object(o) => { let test_name = { let desc = get_string(&o, "description"); if desc.is_empty() { diff --git a/idna/tests/tests.rs b/idna/tests/tests.rs index 808ad6ba8..995bbadd6 100644 --- a/idna/tests/tests.rs +++ b/idna/tests/tests.rs @@ -1,5 +1,5 @@ extern crate idna; -extern crate rustc_serialize; +extern crate serde_json; extern crate rustc_test as test; mod punycode;