This repository was archived by the owner on Dec 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ build = "build.rs"
1616colored = " 1.5"
1717difference = " 1.0"
1818error-chain = " 0.11"
19- rustc-serialize = " 0.3 "
19+ serde_json = " 1.0 "
2020
2121[build-dependencies ]
2222skeptic = " 0.13"
Original file line number Diff line number Diff line change 106106
107107extern crate difference;
108108#[ macro_use] extern crate error_chain;
109- extern crate rustc_serialize ;
109+ extern crate serde_json ;
110110
111111mod errors;
112112
Original file line number Diff line number Diff line change 11use 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) ]
5252fn 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+ }
You can’t perform that action at this time.
0 commit comments