This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +28
-5
lines changed
src/tools/jsondoclint/src Expand file tree Collapse file tree 3 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::fmt::Write;
22
33use serde_json:: Value ;
44
5- #[ derive( Debug , Clone ) ]
5+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
66pub enum SelectorPart {
77 Field ( String ) ,
88 Index ( usize ) ,
Original file line number Diff line number Diff line change 1+ use super :: * ;
2+
13#[ test]
2- fn should_fail ( ) {
3- assert_eq ! ( true , false ) ;
4+ fn basic_find ( ) {
5+ use SelectorPart :: * ;
6+
7+ let j = serde_json:: json!( {
8+ "index" : {
9+ "4" : {
10+ "inner" : {
11+ "items" : [ "1" , "2" , "3" ]
12+ }
13+ }
14+ }
15+ } ) ;
16+
17+ let sel = find_selector ( & j, & serde_json:: json!( "1" ) ) ;
18+ let exp: Vec < Vec < SelectorPart > > = vec ! [ vec![
19+ Field ( "index" . to_owned( ) ) ,
20+ Field ( "4" . to_owned( ) ) ,
21+ Field ( "inner" . to_owned( ) ) ,
22+ Field ( "items" . to_owned( ) ) ,
23+ Index ( 0 ) ,
24+ ] ] ;
25+
26+ assert_eq ! ( exp, sel) ;
427}
Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ pub(crate) mod item_kind;
99mod json_find;
1010mod validator;
1111
12- #[ derive( Debug ) ]
12+ #[ derive( Debug , PartialEq , Eq ) ]
1313struct Error {
1414 kind : ErrorKind ,
1515 id : Id ,
1616}
1717
18- #[ derive( Debug ) ]
18+ #[ derive( Debug , PartialEq , Eq ) ]
1919enum ErrorKind {
2020 NotFound ,
2121 Custom ( String ) ,
You can’t perform that action at this time.
0 commit comments