Add real-world json as a test case
This commit is contained in:
parent
74b6a1e410
commit
cde41e6eda
49
src/joplin-cfg.json
Normal file
49
src/joplin-cfg.json
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://joplinapp.org/schema/settings.json",
|
||||||
|
"locale": "en_GB",
|
||||||
|
"sync.target": 6,
|
||||||
|
"markdown.plugin.softbreaks": false,
|
||||||
|
"markdown.plugin.typographer": false,
|
||||||
|
"spellChecker.language": "en-US",
|
||||||
|
"ui.layout": {
|
||||||
|
"key": "root",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"key": "sideBar",
|
||||||
|
"width": 250,
|
||||||
|
"visible": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "noteList",
|
||||||
|
"width": 250,
|
||||||
|
"visible": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "editor",
|
||||||
|
"visible": true,
|
||||||
|
"width": 1493
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "plugin-view-joplin.plugin.note.tabs-note.tabs.panel",
|
||||||
|
"context": {
|
||||||
|
"pluginId": "joplin.plugin.note.tabs"
|
||||||
|
},
|
||||||
|
"visible": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"visible": true
|
||||||
|
},
|
||||||
|
"noteVisiblePanes": [
|
||||||
|
"editor",
|
||||||
|
"viewer"
|
||||||
|
],
|
||||||
|
"theme": 4,
|
||||||
|
"sync.6.username": "webdav",
|
||||||
|
"net.ignoreTlsErrors": true,
|
||||||
|
"style.editor.contentMaxWidth": 600,
|
||||||
|
"editor.codeView": true,
|
||||||
|
"markdown.plugin.sub": true,
|
||||||
|
"markdown.plugin.sup": true,
|
||||||
|
"markdown.plugin.multitable": true
|
||||||
|
}
|
||||||
|
|
16
src/lib.rs
16
src/lib.rs
@ -100,7 +100,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn whitespace() -> impl JsonParser<'static, ()> {
|
fn whitespace() -> impl JsonParser<'static, ()> {
|
||||||
repeated(literal_char(' ')).to(())
|
repeated(choice((
|
||||||
|
literal_char('\t'),
|
||||||
|
literal_char('\n'),
|
||||||
|
literal_char(' '),
|
||||||
|
)))
|
||||||
|
.to(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_array() -> impl JsonParser<'static, JsonValue> {
|
fn json_array() -> impl JsonParser<'static, JsonValue> {
|
||||||
@ -200,7 +205,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_json() {
|
fn parse_json_object() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
json_object().parse(r#"{ "a": 23}"#).unwrap().0,
|
json_object().parse(r#"{ "a": 23}"#).unwrap().0,
|
||||||
JsonValue::Object(vec![("a".into(), JsonValue::Num(23.))])
|
JsonValue::Object(vec![("a".into(), JsonValue::Num(23.))])
|
||||||
@ -210,4 +215,11 @@ mod tests {
|
|||||||
JsonValue::Object(vec![])
|
JsonValue::Object(vec![])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_json() {
|
||||||
|
let test_json = include_str!("joplin-cfg.json");
|
||||||
|
let parsed_json = json_object().parse(test_json);
|
||||||
|
assert!(parsed_json.is_ok());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user