2021-09-02 23:19:54 +00:00
|
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_int() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
|
|
|
1 | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.out.contains("1 B"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_decimal() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
|
|
|
1.2 | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.out.contains("1 B"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_str() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
|
|
|
'2000' | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2022-02-04 02:01:45 +00:00
|
|
|
assert!(actual.out.contains("2.0 KiB"));
|
2021-09-02 23:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_str_newline() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2022-02-04 02:01:45 +00:00
|
|
|
"2000
|
|
|
|
" | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.out.contains("2.0 KiB"));
|
2021-09-02 23:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_str_many_newlines() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2022-02-04 02:01:45 +00:00
|
|
|
"2000
|
|
|
|
|
|
|
|
" | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.out.contains("2.0 KiB"));
|
2021-09-02 23:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_filesize() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2022-02-04 02:01:45 +00:00
|
|
|
3kib | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.out.contains("3.0 KiB"));
|
2021-09-02 23:19:54 +00:00
|
|
|
}
|
2022-11-10 21:33:15 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn into_filesize_negative_filesize() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
|
|
|
-3kib | into filesize
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.out.contains("-3.0 KiB"));
|
|
|
|
}
|