mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:16:05 +02:00
support filesize arguments in random
binary
/chars
(#14068)
Closes #13920 # User-Facing Changes `random binary` and `random chars` now support filesize arguments: ```nushell random binary 1kb random chars --length 1kb ```
This commit is contained in:
21
crates/nu-command/tests/commands/random/binary.rs
Normal file
21
crates/nu-command/tests/commands/random/binary.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn generates_bytes_of_specified_length() {
|
||||
let actual = nu!(r#"
|
||||
random binary 16 | bytes length
|
||||
"#);
|
||||
|
||||
let result = actual.out;
|
||||
assert_eq!(result, "16");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generates_bytes_of_specified_filesize() {
|
||||
let actual = nu!(r#"
|
||||
random binary 1kb | bytes length
|
||||
"#);
|
||||
|
||||
let result = actual.out;
|
||||
assert_eq!(result, "1000");
|
||||
}
|
@ -9,3 +9,13 @@ fn generates_chars_of_specified_length() {
|
||||
let result = actual.out;
|
||||
assert_eq!(result, "15");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generates_chars_of_specified_filesize() {
|
||||
let actual = nu!(r#"
|
||||
random chars --length 1kb | str stats | get bytes
|
||||
"#);
|
||||
|
||||
let result = actual.out;
|
||||
assert_eq!(result, "1000");
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
mod binary;
|
||||
mod bool;
|
||||
mod chars;
|
||||
mod dice;
|
||||
|
Reference in New Issue
Block a user