Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning: only integer literals, symbols defined outside the test file, strings, and derived expressions are currently supported in TEST_CASE calls. TEST_CASE calls also can’t be split over multiple lines. So:

Code Block
languagec
// OK
TEST_CASE(0x1234)

// OK - test logs will have "test_function(GPIO_PORT_A)"
#include "gpio.h"
TEST_CASE(GPIO_PORT_A)

// OK - test logs will have "test_function((GpioAddress)CONTROLLER_BOARD_ADDR_LED_BLUE)"
#include "controller_board_pins.h"
TEST_CASE((GpioAddress)CONTROLLER_BOARD_ADDR_LED_BLUE)

// OK - test logs will have "test_function(10*50/(5+5))", not "test_function(50)"
TEST_CASE(10*50/(5+5))

// OK
TEST_CASE("foo")

// OK
TEST_CASE(
  1, 2, 3
)

// Not OK - FOO is defined in the current file
#define FOO 0x1234
TEST_CASE(FOO)

// Not OK - stringsarrays aren't allowed TEST_CASE("foo")

// Not OK - arrays aren't allowed(as they contain {})
TEST_CASE(uint8_t[]{1, 2, 3})

// Not OK - Foo is defined in the current file, and no compound literals
typedef struct Foo {
  uint8_t bar;
} Foo;
TEST_CASE((Foo){ .bar = 2 })

// Not OK - compound literals aren't allowed (as they contain {})
TEST_CASE((GpioAddress){ .port = GPIO_PORT_A, .pin = 4 })

// Not OK - multiple lines
TEST_CASE(
  1, 2, 3
)

This is because our old version of the Unity test framework (http://www.throwtheswitch.org/unity) literally copies the arguments you put in the TEST_CASE call to the generated test runner file, which runs your tests. It doesn’t have access to any of the symbols defined in your test file, but it does include everything your test file does. A lot of this weirdness will be fixed when we update Unity: Jira LegacyserverSystem JIRAcolumnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolutionserverId6df7ba0d-c6df-39f5-b19f-bb96d235af5fkeySOFT-420It’s also really dumb, so it does silly things like interpreting } as marking a new line.

Aside: the TEST_CASE macro is defined in test_helpers.h, so you’ll have to include it.