support binary input in length (#14224)

Closes #13874

# User-Facing Changes

`length` now supports binary input:

```nushell
> random binary 1kb | length
1000
```
This commit is contained in:
Solomon
2024-11-03 20:39:24 -07:00
committed by GitHub
parent d289c773d0
commit 8b19399b13
2 changed files with 38 additions and 2 deletions

View File

@ -1,4 +1,6 @@
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() {
@ -20,3 +22,14 @@ fn length_fails_on_echo_record() {
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");
});
}