Update test so that it tests also the case of throwing without any try section (override M_RAISE_FATAL)
This commit is contained in:
1 parent
83e7f2a641
commit
1ff9848384
1 file changed
+24
-1
+24
-1
@@ -21,6 +21,21 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
// The test shall finish with a raise fatal.
|
||||||
|
#define M_RAISE_FATAL(...) do { \
|
||||||
|
if (test_final_in_progress == true) { \
|
||||||
|
exit(0); \
|
||||||
|
} else { \
|
||||||
|
fprintf(stderr, "ERROR(M*LIB): " __VA_ARGS__); \
|
||||||
|
abort(); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
// Is false by default.
|
||||||
|
static bool test_final_in_progress;
|
||||||
|
|
||||||
#include "test-obj.h"
|
#include "test-obj.h"
|
||||||
#include "coverage.h"
|
#include "coverage.h"
|
||||||
|
|
||||||
@@ -424,11 +439,19 @@ static void test3(void)
|
|||||||
assert(init == false);
|
assert(init == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_final(void)
|
||||||
|
{
|
||||||
|
// Throw without a try block shall raise the M_RAISE_FATAL macro
|
||||||
|
test_final_in_progress = true;
|
||||||
|
M_THROW(1);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
test1();
|
test1();
|
||||||
test2();
|
test2();
|
||||||
test3();
|
test3();
|
||||||
testobj_final_check();
|
testobj_final_check();
|
||||||
exit(0);
|
test_final();
|
||||||
|
exit(1); // Shall not be reached.
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user