1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00
expr now detects overflows and logs to stderr instead of overflowing the
input
https://github.com/uutils/coreutils/issues/1194
This commit is contained in:
bootandy 2018-06-26 23:30:07 +01:00
parent d5e6259b4c
commit 4756eb5c19
2 changed files with 33 additions and 9 deletions

View file

@ -12,6 +12,17 @@ fn test_simple_arithmetic() {
new_ucmd!().args(&["4", "/", "2"]).run().stdout_is("2\n");
}
#[test]
fn test_complex_arithmetic() {
let run = new_ucmd!().args(&["9223372036854775807", "+", "9223372036854775807"]).run();
run.stdout_is("");
run.stderr_is("expr: error: +: Numerical result out of range");
let run = new_ucmd!().args(&["9", "/", "0"]).run();
run.stdout_is("");
run.stderr_is("expr: error: division by zero");
}
#[test]
fn test_parenthesis() {
new_ucmd!().args(&["(", "1", "+", "1", ")", "*", "2"]).run().stdout_is("4\n");