mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 09:53:43 +01:00
8b19399b13
Closes #13874 # User-Facing Changes `length` now supports binary input: ```nushell > random binary 1kb | length 1000 ```
36 lines
853 B
Rust
36 lines
853 B
Rust
use nu_test_support::fs::Stub::FileWithContent;
|
|
use nu_test_support::nu;
|
|
use nu_test_support::playground::Playground;
|
|
|
|
#[test]
|
|
fn length_columns_in_cal_table() {
|
|
let actual = nu!("cal --as-table | columns | length");
|
|
|
|
assert_eq!(actual.out, "7");
|
|
}
|
|
|
|
#[test]
|
|
fn length_columns_no_rows() {
|
|
let actual = nu!("echo [] | length");
|
|
|
|
assert_eq!(actual.out, "0");
|
|
}
|
|
|
|
#[test]
|
|
fn length_fails_on_echo_record() {
|
|
let actual = nu!("echo {a:1 b:2} | length");
|
|
|
|
assert!(actual.err.contains("only_supports_this_input_type"));
|
|
}
|
|
|
|
#[test]
|
|
fn length_byte_stream() {
|
|
Playground::setup("length_bytes", |dirs, sandbox| {
|
|
sandbox.mkdir("length_bytes");
|
|
sandbox.with_files(&[FileWithContent("data.txt", "😀")]);
|
|
|
|
let actual = nu!(cwd: dirs.test(), "open data.txt | length");
|
|
assert_eq!(actual.out, "4");
|
|
});
|
|
}
|