Skip to content

Commit d914c8e

Browse files
committed
Move tests of idna to serde-json
1 parent 695351b commit d914c8e

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

idna/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ name = "unit"
1919

2020
[dev-dependencies]
2121
rustc-test = "0.3"
22-
rustc-serialize = "0.3"
22+
serde_json = "1.0"
2323

2424
[dependencies]
2525
unicode-bidi = "0.3"

idna/tests/punycode.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// except according to those terms.
88

99
use idna::punycode::{decode, encode_str};
10-
use rustc_serialize::json::{Json, Object};
10+
use serde_json::Value;
11+
use serde_json::map::Map;
12+
use std::str::FromStr;
1113
use test::TestFn;
1214

1315
fn one_test(decoded: &str, encoded: &str) {
@@ -31,19 +33,19 @@ fn one_test(decoded: &str, encoded: &str) {
3133
}
3234
}
3335

34-
fn get_string<'a>(map: &'a Object, key: &str) -> &'a str {
36+
fn get_string<'a>(map: &'a Map<String, Value>, key: &str) -> &'a str {
3537
match map.get(&key.to_string()) {
36-
Some(&Json::String(ref s)) => s,
38+
Some(&Value::String(ref s)) => s,
3739
None => "",
3840
_ => panic!(),
3941
}
4042
}
4143

4244
pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
43-
match Json::from_str(include_str!("punycode_tests.json")) {
44-
Ok(Json::Array(tests)) => for (i, test) in tests.into_iter().enumerate() {
45+
match Value::from_str(include_str!("punycode_tests.json")) {
46+
Ok(Value::Array(tests)) => for (i, test) in tests.into_iter().enumerate() {
4547
match test {
46-
Json::Object(o) => {
48+
Value::Object(o) => {
4749
let test_name = {
4850
let desc = get_string(&o, "description");
4951
if desc.is_empty() {

idna/tests/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
extern crate idna;
2-
extern crate rustc_serialize;
2+
extern crate serde_json;
33
extern crate rustc_test as test;
44

55
mod punycode;

0 commit comments

Comments
 (0)