Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit 433bbc2

Browse files
committed
Remove dependency on rustc_serialize
1 parent 0404ec0 commit 433bbc2

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ build = "build.rs"
1616
colored = "1.5"
1717
difference = "1.0"
1818
error-chain = "0.11"
19-
rustc-serialize = "0.3"
19+
serde_json = "1.0"
2020

2121
[build-dependencies]
2222
skeptic = "0.13"

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106

107107
extern crate difference;
108108
#[macro_use] extern crate error_chain;
109-
extern crate rustc_serialize;
109+
extern crate serde_json;
110110

111111
mod errors;
112112

src/macros.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::borrow::Cow;
2-
use rustc_serialize::json::Json;
2+
use serde_json;
33

44
/// Easily construct an `Assert` with a custom command.
55
///
@@ -50,10 +50,8 @@ macro_rules! assert_cmd {
5050
/// If `x` can not be decoded as `String`.
5151
#[doc(hidden)]
5252
fn deserialize_json_string(x: &str) -> String {
53-
match Json::from_str(x).expect(&format!("Unable to deserialize `{:?}` as string.", x)) {
54-
Json::String(deserialized) => deserialized,
55-
_ => panic!("Unable to deserialize `{:?}` as string.", x),
56-
}
53+
serde_json::from_str(x)
54+
.expect(&format!("Unable to deserialize `{:?}` as string.", x))
5755
}
5856

5957
/// Deserialize a JSON-encoded `String`.
@@ -99,3 +97,32 @@ macro_rules! __assert_single_token_expression {
9997
// little helper
10098
(@DENY) => { };
10199
}
100+
101+
#[cfg(test)]
102+
mod test {
103+
use super::*;
104+
105+
#[test]
106+
fn flatten_unquoted()
107+
{
108+
assert_eq!(
109+
flatten_escaped_string("hello world"),
110+
"hello world");
111+
}
112+
113+
#[test]
114+
fn flatten_quoted()
115+
{
116+
assert_eq!(
117+
flatten_escaped_string(r#""hello world""#),
118+
"hello world");
119+
}
120+
121+
#[test]
122+
fn flatten_escaped()
123+
{
124+
assert_eq!(
125+
flatten_escaped_string(r#""hello world \u0042 A""#),
126+
"hello world B A");
127+
}
128+
}

0 commit comments

Comments
 (0)