Skip to content

Commit 09818a8

Browse files
committed
Add a test that makes sense
1 parent 4b2a1eb commit 09818a8

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/tools/jsondoclint/src/json_find.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt::Write;
22

33
use serde_json::Value;
44

5-
#[derive(Debug, Clone)]
5+
#[derive(Debug, Clone, PartialEq, Eq)]
66
pub enum SelectorPart {
77
Field(String),
88
Index(usize),
+25-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
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
}

src/tools/jsondoclint/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ pub(crate) mod item_kind;
99
mod json_find;
1010
mod validator;
1111

12-
#[derive(Debug)]
12+
#[derive(Debug, PartialEq, Eq)]
1313
struct Error {
1414
kind: ErrorKind,
1515
id: Id,
1616
}
1717

18-
#[derive(Debug)]
18+
#[derive(Debug, PartialEq, Eq)]
1919
enum ErrorKind {
2020
NotFound,
2121
Custom(String),

0 commit comments

Comments
 (0)