February 18, 2020 How to catch RangeError in unittest? | ||||
---|---|---|---|---|
| ||||
I have a function add(index, data) which throws RangeError if the index is invalid. unittest { // is supposed to test that RangeError is thrown on a range violation assertThrown!RangeError(add(size_t.max, something)); //which doesn't work, the test is killed with core.exception.RangeError: Range violation // this kills the test, too: core.exception.RangeError: Range violation try { add(size_t.max, something); assert(false, "Expecting RangeError"); } catch (RangeError) {} } Just for clarification, I do _not_ intend to catch RangeError outside of a unittest. What I want is that the test acknowledges the correctly thrown RangeError and gracefully reports success. What are my options? |
February 18, 2020 Re: How to catch RangeError in unittest? | ||||
---|---|---|---|---|
| ||||
Posted in reply to wjoe | On Tuesday, 18 February 2020 at 13:07:35 UTC, wjoe wrote:
> I have a function add(index, data) which throws RangeError if the index is invalid.
>
Never mind. For whatever reason RangeError is now caught. Sorry for the noise.
|
Copyright © 1999-2021 by the D Language Foundation