Starting test-driven development (TDD) with Unity

- Using PlatformIO's embedded unit testing with native environment
- mbed-dependent .cpp files escaped with #ifndef UNIT_TEST
- First tests for charger module added under test/ directory
This commit is contained in:
Martin Jaeger
2019-05-04 11:31:37 +02:00
parent 90666d697b
commit d9f7103e97
26 changed files with 519 additions and 16 deletions
+6 -2
View File
@@ -16,9 +16,9 @@
#include "pcb.h"
#include "thingset.h"
#include "mbed.h"
#include "eeprom.h"
#include <inttypes.h>
#include <time.h>
// versioning of EEPROM layout (2 bytes)
// change the version number each time the data object array below is changed!
@@ -43,6 +43,8 @@ const uint16_t eeprom_data_objects[] = {
0xA6 // day count
};
#ifndef UNIT_TEST
uint32_t _calc_crc(uint8_t *buf, size_t len)
{
RCC->AHBENR |= RCC_AHBENR_CRCEN;
@@ -66,6 +68,8 @@ uint32_t _calc_crc(uint8_t *buf, size_t len)
return CRC->DR;
}
#endif // UNIT_TEST
#if defined(PIN_EEPROM_SDA) && defined(PIN_EEPROM_SCL)
#ifdef PCB_LS_010
@@ -284,4 +288,4 @@ void eeprom_update()
if (time(NULL) % EEPROM_UPDATE_INTERVAL == 0 && time(NULL) > 0) {
eeprom_store_data();
}
}
}