5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp

Committer:
jacobjohnson
Date:
2017-02-27
Revision:
1:f30bdcd2b33b
Parent:
0:098463de4c5d

File content as of revision 1:f30bdcd2b33b:

#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(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");
};

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");
}