6
6
7
7
#[ cfg( test) ]
8
8
mod tests {
9
+ use jsonpath_ri:: jsonpath;
9
10
use serde:: { Deserialize , Serialize } ;
10
11
use std:: fs;
11
12
use std:: panic;
12
- use jsonpath_ri:: jsonpath;
13
13
14
14
#[ derive( Debug , PartialEq , Serialize , Deserialize ) ]
15
15
struct TestSuite {
@@ -41,10 +41,16 @@ mod tests {
41
41
as_json( & t. result) . expect( "invalid result" )
42
42
) ;
43
43
let path = jsonpath:: parse ( & t. selector ) ;
44
- assert ! ( path. is_ok( ) , "parse failed: {:?}" , path. err( ) . expect( "should be an error" ) ) ;
44
+ assert ! (
45
+ path. is_ok( ) ,
46
+ "parse failed: {:?}" ,
47
+ path. err( ) . expect( "should be an error" )
48
+ ) ;
45
49
46
50
if let Ok ( p) = path {
47
- if let Ok ( result) = p. find ( as_json_value ( & t. document ) . expect ( "invalid document" ) ) {
51
+ if let Ok ( result) =
52
+ p. find ( as_json_value ( & t. document ) . expect ( "invalid document" ) )
53
+ {
48
54
if result != as_json_value_array ( & t. result ) . expect ( "invalid result" ) {
49
55
assert ! ( false , "incorrect result" )
50
56
}
@@ -96,7 +102,9 @@ mod tests {
96
102
97
103
serde_yaml:: Value :: Bool ( b) => Ok ( serde_json:: Value :: Bool ( * b) ) ,
98
104
99
- serde_yaml:: Value :: Number ( num) => Ok ( serde_json:: Value :: Number ( yaml_number_as_json ( num. clone ( ) ) ) ) ,
105
+ serde_yaml:: Value :: Number ( num) => {
106
+ Ok ( serde_json:: Value :: Number ( yaml_number_as_json ( num. clone ( ) ) ) )
107
+ }
100
108
101
109
serde_yaml:: Value :: String ( s) => Ok ( serde_json:: Value :: String ( s. clone ( ) ) ) ,
102
110
@@ -109,7 +117,10 @@ mod tests {
109
117
110
118
serde_yaml:: Value :: Mapping ( map) => {
111
119
let object_members = map. iter ( ) . map ( |( k, v) | {
112
- ( serde_yaml:: to_string ( k) . expect ( "non-string mapping key" ) , as_json_value ( v) . expect ( "invalid map value" ) )
120
+ (
121
+ serde_yaml:: to_string ( k) . expect ( "non-string mapping key" ) ,
122
+ as_json_value ( v) . expect ( "invalid map value" ) ,
123
+ )
113
124
} ) ;
114
125
Ok ( serde_json:: Value :: Object ( object_members. collect ( ) ) )
115
126
}
@@ -124,7 +135,7 @@ mod tests {
124
135
. map ( |v| as_json_value ( v) . expect ( "invalid sequence element" ) ) ;
125
136
Ok ( array_elements. collect ( ) )
126
137
}
127
- _ => Err ( "not a sequence" . to_string ( ) )
138
+ _ => Err ( "not a sequence" . to_string ( ) ) ,
128
139
}
129
140
}
130
141
@@ -134,7 +145,8 @@ mod tests {
134
145
} else if n. is_u64 ( ) {
135
146
serde_json:: Number :: from ( n. as_u64 ( ) . expect ( "invalid u64 in YAML" ) )
136
147
} else {
137
- serde_json:: Number :: from_f64 ( n. as_f64 ( ) . expect ( "invalid f64 in YAML" ) ) . expect ( "invalid f64 for JSON" )
148
+ serde_json:: Number :: from_f64 ( n. as_f64 ( ) . expect ( "invalid f64 in YAML" ) )
149
+ . expect ( "invalid f64 for JSON" )
138
150
}
139
151
}
140
152
}
0 commit comments