Test Cases: Limits
Posted 10-10-2021 at 11:53 PM by astrogeek
This post is part of the Alphanumeric Calculator program group.
Test cases to validate limits and range of expressions, undefined input errors.
Test cases input file:
And the results using Rev.3 lexer/parser as posted to this blog.
Test cases to validate limits and range of expressions, undefined input errors.
Test cases input file:
Code:
cat tests_limits /* Tests detection and reporting of limits and unexpected input */ ######## Valid - Min/Max values 999999999999 -999999999999 nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine negative nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine ######## Undefined input at start, middle and end of lines abcdef one hundred plux three thousand one abcdefghijabcdefghijabcdefghijabcdefghij one thousand ######## Invalid - Limits and range of input, numeric and expressions 1000000000000 - 1 999999999999 + 1 -999999999999 - 1 nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine plus one negative nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine minus one ######## Detect multiplication overflow: 1 is OK, 2 is range err, 3 is overflow, 4/5 attempt div by 0 in overflow test 99999999999 times 9 99999999999 times 99 99999999999 times 99999999 zero times one one times zero ######## Division by zero error 1/0 one thousand over (five minus ten over two) ######## Exceed the lexer input limit LLONG_MAX, 1 is OK but range err, 2 is overflow error 9223372036854775807 9223372036854775808
Code:
./alphacalc tests_limits -c ######## Valid - Min/Max values nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine negative nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine negative nine hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine ######## Undefined input at start, middle and end of lines tests_limits:9.1-9.7: error: Undefined input! abcdef tests_limits:9.1-9.7: error: syntax error tests_limits:10.13-10.17: error: Undefined input! plux tests_limits:10.13-10.17: error: syntax error tests_limits:11.5-11.20: error: Undefined input! abcdefghijabcde tests_limits:11.5-11.20: error: syntax error tests_limits:11.21-11.36: error: Undefined input! fghijabcdefghij tests_limits:11.37-11.47: error: Undefined input! abcdefghij ######## Invalid - Limits and range of input, numeric and expressions tests_limits:13.1-13.13: error: Value out of range! tests_limits:14.14-14.14: error: Sum out of range! tests_limits:15.15-15.15: error: Difference out of range! tests_limits:16.126-16.129: error: Sum out of range! tests_limits:17.135-17.139: error: Difference out of range! ######## Detect multiplication overflow: 1 is OK, 2 is range err, 3 is overflow, 4/5 attempt div by 0 in overflow test eight hundred ninety nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety one tests_limits:20.13-20.17: error: Product out of range! tests_limits:21.13-21.17: error: Multiplication overflow! zero zero ######## Division by zero error tests_limits:25.3-25.3: error: Division by zero! tests_limits:26.19-26.43: error: Division by zero! ######## Exceed the lexer input limit LLONG_MAX, 1 is OK but range err, 2 is overflow error tests_limits:28.1-28.19: error: Value out of range! tests_limits:29.1-29.19: error: Invalid numeric input!
Total Comments 0