mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 15:11:52 +02:00
fix wrong casting with into filesize (#13110)
# Description Fix wrong casting which is related to https://github.com/nushell/nushell/pull/12974#discussion_r1618598336 # User-Facing Changes AS-IS (before fixing) ``` $ "-10000PiB" | into filesize 6.2 EiB <--- Wrong casted value $ "10000PiB" | into filesize -6.2 EiB <--- Wrong casted value ``` TO-BE (after fixing) ``` $ "-10000PiB" | into filesize Error: nu:🐚:cant_convert × Can't convert to filesize. ╭─[entry #6:1:1] 1 │ "-10000PiB" | into filesize · ─────┬───── · ╰── can't convert string to filesize ╰──── $ "10000PiB" | into filesize Error: nu:🐚:cant_convert × Can't convert to filesize. ╭─[entry #7:1:1] 1 │ "10000PiB" | into filesize · ─────┬──── · ╰── can't convert string to filesize ╰──── ```
This commit is contained in:
@ -76,6 +76,13 @@ fn into_filesize_wrong_negative_str_filesize() {
|
||||
assert!(actual.err.contains("can't convert string to filesize"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_filesize_large_negative_str_filesize() {
|
||||
let actual = nu!("'-10000PiB' | into filesize");
|
||||
|
||||
assert!(actual.err.contains("can't convert string to filesize"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_filesize_negative_str() {
|
||||
let actual = nu!("'-1' | into filesize");
|
||||
@ -104,6 +111,13 @@ fn into_filesize_wrong_positive_str_filesize() {
|
||||
assert!(actual.err.contains("can't convert string to filesize"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_filesize_large_positive_str_filesize() {
|
||||
let actual = nu!("'+10000PiB' | into filesize");
|
||||
|
||||
assert!(actual.err.contains("can't convert string to filesize"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_filesize_positive_str() {
|
||||
let actual = nu!("'+1' | into filesize");
|
||||
|
Reference in New Issue
Block a user