More nuon tests, fix table print (#4762)

This commit is contained in:
JT 2022-03-07 08:39:02 -05:00 committed by GitHub
parent 4f43d75130
commit 0b6b321ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 0 deletions

View File

@ -126,3 +126,39 @@ fn binary_roundtrip() {
assert_eq!(actual.out, "0x[1FFF]"); assert_eq!(actual.out, "0x[1FFF]");
} }
#[test]
fn read_binary_data() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.nuon | get 5.3
"#
));
assert_eq!(actual.out, "31")
}
#[test]
fn read_record() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.nuon | get 4.name
"#
));
assert_eq!(actual.out, "Bobby")
}
#[test]
fn read_bool() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.nuon | get 3 | $in == $true
"#
));
assert_eq!(actual.out, "true")
}

View File

@ -11,6 +11,8 @@ pub fn get_columns(input: &[Value]) -> Vec<String> {
columns.push(col.to_string()); columns.push(col.to_string());
} }
} }
} else {
return vec![];
} }
} }

20
tests/fixtures/formats/sample.nuon vendored Normal file
View File

@ -0,0 +1,20 @@
# Some sample nuon values
[
# The nuon compact table format
[[a, nuon, table]; [1, 2, 3], [4, 5, 6]],
# A filesize
100kib,
# A duration
100sec
# A boolean
true,
# A record
{name: "Bobby", age: 99}
# Binary data
0x[11, ff, ee, 1f]
]