mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
fix ranges over zero-length input (#15062)
Fixes #15061 # User-Facing Changes Fixes panics when slicing empty input with inclusive ranges: ```nushell > random binary 0 | bytes at 0..0 Error: x Main thread panicked. |-> at crates/nu-protocol/src/value/range.rs:118:42 `-> attempt to subtract with overflow ```
This commit is contained in:
@ -388,6 +388,13 @@ fn substring_by_negative_index() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn substring_of_empty_string() {
|
||||
let actual = nu!("'' | str substring ..0");
|
||||
assert_eq!(actual.err, "");
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn str_reverse() {
|
||||
let actual = nu!(r#"
|
||||
|
Reference in New Issue
Block a user