This is a simple question I believe... I want the variable virtualLeds
to be shared between all the tests in the test group LedDriverTests
, this is the code:
#include "CppUTest/TestHarness.h"
#include <stdint.h>
extern "C"
{
#include "led_driver.h"
}
TEST_GROUP(LedDriverTests)
{
static uint16_t virtualLeds;
void setup()
{
}
void teardown()
{
}
void expect(void)
{
}
void given(void)
{
}
};
TEST(LedDriverTests, AllOffAtInitialization)
{
// Set all the bits to 1, the LEDs are turned ON by hardware.
virtualLeds = 0xFFFF;
led_driver_create(&virtualLeds);
LONGS_EQUAL(0x0000, virtualLeds);
}
TEST(LedDriverTests, TurnOnLedOne)
{
led_driver_turn_on(1);
LONGS_EQUAL(0x0001, virtualLeds);
}
TEST(LedDriverTests, TurnOffLedOne)
{
led_driver_turn_on(1);
led_driver_turn_off(1);
LONGS_EQUAL(0x0000, virtualLeds);
}
When I try to compile I get the following error:
undefined reference to `TEST_GROUP_CppUTestGroupLedDriverTests::virtualLeds'
Any ideas?