mirror of https://github.com/ARMmbed/mbed-os.git
test: Make MBED_ASSERT failures fail
Make MBED_ASSERT failures fail the unit test case. Without this, we might not notice the assertion failure as it wouldn't be bubbled up to googletest.pull/14948/head
parent
f0d7e24066
commit
51b81e0629
|
@ -35,4 +35,5 @@ target_link_libraries(mbed-stubs-platform
|
||||||
mbed-headers-base
|
mbed-headers-base
|
||||||
mbed-headers-hal
|
mbed-headers-hal
|
||||||
mbed-headers-platform
|
mbed-headers-platform
|
||||||
|
gmock_main
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform/mbed_assert.h"
|
#include "platform/mbed_assert.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
@ -27,4 +28,10 @@ extern "C" void mbed_assert_internal(const char *expr, const char *file, int lin
|
||||||
if (mbed_assert_throw_errors) {
|
if (mbed_assert_throw_errors) {
|
||||||
throw 1;
|
throw 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure we fail the unit test if the Mbed assertion fails. Without this,
|
||||||
|
* we might not notice the assertion failure as it wouldn't be bubbled up
|
||||||
|
* to googletest. Note that this is after the above throw, as some tests
|
||||||
|
* check that an exception is thrown (i.e. negative tests). */
|
||||||
|
FAIL();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue