mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Make expected error in test::@error macro optional
If not supplied with a fault, `test::@error` checks if a fault of any type/value was returned
This commit is contained in:
committed by
Christoffer Lerno
parent
07363c6ecd
commit
7063e684ba
@@ -303,6 +303,34 @@ fn void test_error_not_raised()
|
||||
test::@error(ffail_int(1, 1), io::FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
fn void test_error_nofault()
|
||||
{
|
||||
TestFailFn ffail_void = fn void?(bool to_fail)
|
||||
{
|
||||
if (to_fail) return io::FILE_NOT_FOUND?;
|
||||
};
|
||||
TestIntFn ffail_int = fn int?(int a, int b)
|
||||
{
|
||||
if (b == 0) return io::FILE_NOT_FOUND?;
|
||||
return a / b;
|
||||
};
|
||||
test::@setup(state.setup_fn, state.teardown_fn);
|
||||
|
||||
test::@error(ffail_void(true));
|
||||
test::@error(ffail_int(1, 0));
|
||||
}
|
||||
|
||||
fn void test_error_nofault_not_raised()
|
||||
{
|
||||
TestIntFn ffail_int = fn int?(int a, int b) {
|
||||
if (b == 0) return io::FILE_NOT_FOUND?;
|
||||
return a / b;
|
||||
};
|
||||
test::@setup(state.setup_fn, state.teardown_fn);
|
||||
state.expected_fail = true;
|
||||
test::@error(ffail_int(1, 1));
|
||||
}
|
||||
|
||||
fn void test_error_wrong_error_expected()
|
||||
{
|
||||
TestIntFn ffail_int = fn int?(int a, int b) {
|
||||
|
||||
Reference in New Issue
Block a user