mirror of
https://github.com/nushell/nushell
synced 2024-12-30 23:08:56 +00:00
773dafa8ac
# Description Add support for using negative values file size for `into filesize`. This will help in sorting the file size if negative values are also passed. **Before** ![image](https://github.com/nushell/nushell/assets/43441496/e115b4b3-7526-4379-8dc0-f4f4e44839a1) **After** ![image](https://github.com/nushell/nushell/assets/43441496/4a75fb40-ebe6-46eb-b9d2-55f37db7a6fa) # User-Facing Changes - User can now sort negative filesize also # Tests + Formatting - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting --------- Co-authored-by: Priyank Singh <priyank.singh@soroco.com>
70 lines
1.2 KiB
Rust
70 lines
1.2 KiB
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn into_filesize_int() {
|
|
let actual = nu!("1 | into filesize");
|
|
|
|
assert!(actual.out.contains("1 B"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_filesize_float() {
|
|
let actual = nu!("1.2 | into filesize");
|
|
|
|
assert!(actual.out.contains("1 B"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_filesize_str() {
|
|
let actual = nu!(r#"
|
|
'2000' | into filesize
|
|
"#);
|
|
|
|
assert!(actual.out.contains("2.0 KiB"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_filesize_str_newline() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
"2000
|
|
" | into filesize
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("2.0 KiB"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_filesize_str_many_newlines() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
"2000
|
|
|
|
" | into filesize
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("2.0 KiB"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_filesize_filesize() {
|
|
let actual = nu!("3kib | into filesize");
|
|
|
|
assert!(actual.out.contains("3.0 KiB"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_filesize_negative_filesize() {
|
|
let actual = nu!("-3kib | into filesize");
|
|
|
|
assert!(actual.out.contains("-3.0 KiB"));
|
|
}
|
|
|
|
#[test]
|
|
fn into_negative_filesize() {
|
|
let actual = nu!("'-1' | into filesize");
|
|
|
|
assert!(actual.out.contains("-1 B"));
|
|
}
|