Add more tests

This commit is contained in:
Jonathan Turner 2019-06-03 12:37:16 +12:00
parent 9ba42eae46
commit f3d14aad48
13 changed files with 64 additions and 1 deletions

View File

@ -167,7 +167,7 @@ impl ExternalCommand {
let mut first = true;
for i in &inputs {
if !first {
new_arg_string.push_str(" && ");
new_arg_string.push_str("&&");
new_arg_string.push_str(&self.name);
} else {
first = false;

View File

@ -58,4 +58,29 @@ mod tests {
fn test_toml() {
test_helper("open_toml");
}
#[test]
fn test_json() {
test_helper("open_json");
}
#[test]
fn json_roundtrip() {
test_helper("json_roundtrip");
}
#[test]
fn toml_roundtrip() {
test_helper("toml_roundtrip");
}
#[test]
fn sort_by() {
test_helper("sort_by");
}
#[test]
fn split() {
test_helper("split");
}
}

1
tests/json_roundtrip.out Normal file
View File

@ -0,0 +1 @@
"example glossary"

2
tests/json_roundtrip.txt Normal file
View File

@ -0,0 +1,2 @@
open tests\test.json | to-json | from-json | select glossary.title | echo $it
exit

1
tests/open_json.out Normal file
View File

@ -0,0 +1 @@
markup

2
tests/open_json.txt Normal file
View File

@ -0,0 +1,2 @@
open tests\test.json | select glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it
exit

1
tests/sort_by.out Normal file
View File

@ -0,0 +1 @@
description

2
tests/sort_by.txt Normal file
View File

@ -0,0 +1,2 @@
open tests\test.toml --raw | split-row "\n" | skip 1 | first 4 | split-column "=" | sort-by Column1 | skip 1 | first 1 | select Column1 | trim | echo $it
exit

2
tests/split.out Normal file
View File

@ -0,0 +1,2 @@
name
version

2
tests/split.txt Normal file
View File

@ -0,0 +1,2 @@
open tests\test.toml --raw | split-row "\n" | skip 1 | first 2 | split-column "=" | select Column1 | trim | echo $it
exit

22
tests/test.json Normal file
View File

@ -0,0 +1,22 @@
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}

1
tests/toml_roundtrip.out Normal file
View File

@ -0,0 +1 @@
nu

2
tests/toml_roundtrip.txt Normal file
View File

@ -0,0 +1,2 @@
open tests\test.toml | to-toml | from-toml | select package.name | echo $it
exit