5.2.1 - Updated I2C files
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
Diff: TESTS/mbedmicro-mbed/static_assert/test_c.c
- Revision:
- 0:098463de4c5d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TESTS/mbedmicro-mbed/static_assert/test_c.c Wed Jan 25 20:34:15 2017 +0000 @@ -0,0 +1,39 @@ +#include "mbed_assert.h" +#define THE_ANSWER 42 + +// Tests for static asserts in different contexts +// multiple asserts are used to garuntee no conflicts occur in generated labels + +// Test for static asserts in global context +MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), + "An int must be larger than char"); +MBED_STATIC_ASSERT(2 + 2 == 4, + "Hopefully the universe is mathematically consistent"); +MBED_STATIC_ASSERT(THE_ANSWER == 42, + "Said Deep Thought, with infinite majesty and calm"); + +struct test { + int dummy; + + // Test for static asserts in struct context + MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char), + "An int must be larger than char"); + MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4, + "Hopefully the universe is mathematically consistent"); + MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42, + "Said Deep Thought, with infinite majesty and calm"); +}; + +MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int), + "Static assertions should not change the size of a struct"); + +void doit_c(void) { + // Test for static asserts in function context + MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), + "An int must be larger than char"); + MBED_STATIC_ASSERT(2 + 2 == 4, + "Hopefully the universe is mathematically consistent"); + MBED_STATIC_ASSERT(THE_ANSWER == 42, + "Said Deep Thought, with infinite majesty and calm"); +} +