Remove panics from random integer and make the constraint more idiomatic (#2578)

* Remove panics from random integer and make the constraint more idiomatic

* Add open intervals to NumericRange
This commit is contained in:
Radek Vít
2020-09-19 22:41:49 +02:00
committed by GitHub
parent 193c4cc6d5
commit 798766b4b5
5 changed files with 117 additions and 39 deletions

View File

@ -5,9 +5,33 @@ fn generates_an_integer() {
let actual = nu!(
cwd: ".", pipeline(
r#"
random integer --min 42 --max 43
random integer 42..43
"#
));
assert!(actual.out.contains("42") || actual.out.contains("43"));
}
#[test]
fn generates_55() {
let actual = nu!(
cwd: ".", pipeline(
r#"
random integer 55..55
"#
));
assert!(actual.out.contains("55"));
}
#[test]
fn generates_0() {
let actual = nu!(
cwd: ".", pipeline(
r#"
random integer ..<1
"#
));
assert!(actual.out.contains("0"));
}