Skip to content

Commit

Permalink
Add a test that makes sense
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Nov 26, 2022
1 parent 4b2a1eb commit 09818a8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/tools/jsondoclint/src/json_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Write;

use serde_json::Value;

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SelectorPart {
Field(String),
Index(usize),
Expand Down
27 changes: 25 additions & 2 deletions src/tools/jsondoclint/src/json_find/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
use super::*;

#[test]
fn should_fail() {
assert_eq!(true, false);
fn basic_find() {
use SelectorPart::*;

let j = serde_json::json!({
"index": {
"4": {
"inner": {
"items": ["1", "2", "3"]
}
}
}
});

let sel = find_selector(&j, &serde_json::json!("1"));
let exp: Vec<Vec<SelectorPart>> = vec![vec![
Field("index".to_owned()),
Field("4".to_owned()),
Field("inner".to_owned()),
Field("items".to_owned()),
Index(0),
]];

assert_eq!(exp, sel);
}
4 changes: 2 additions & 2 deletions src/tools/jsondoclint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ pub(crate) mod item_kind;
mod json_find;
mod validator;

#[derive(Debug)]
#[derive(Debug, PartialEq, Eq)]
struct Error {
kind: ErrorKind,
id: Id,
}

#[derive(Debug)]
#[derive(Debug, PartialEq, Eq)]
enum ErrorKind {
NotFound,
Custom(String),
Expand Down

0 comments on commit 09818a8

Please sign in to comment.