mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 01:39:30 +02:00
Event cleanup
This commit is contained in:
parent
32378df03e
commit
b528c8917f
25 changed files with 45 additions and 138 deletions
|
@ -1,5 +1,5 @@
|
|||
# Include the directory with your source files
|
||||
include_directories(${CMAKE_SOURCE_DIR}/Software/src/devboard/utils .)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/Software/src/devboard ${CMAKE_SOURCE_DIR}/Software/src/devboard/utils . )
|
||||
|
||||
# Create a variable to store the list of test files
|
||||
file(GLOB TEST_SOURCES utils/*.cpp)
|
||||
|
|
|
@ -201,7 +201,7 @@ class Runtime {
|
|||
return 0; \
|
||||
} else { \
|
||||
double percentage = 100.0 * num_failed / mt::TestsManager::tests().size(); \
|
||||
fprintf(stderr, "%s{ summary} %lu tests failed (%.2f%%)%s\n", mt::red(), num_failed, percentage, mt::def()); \
|
||||
fprintf(stderr, "%s{ summary} %zu tests failed (%.2f%%)%s\n", mt::red(), num_failed, percentage, mt::def()); \
|
||||
return -1; \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#include "test_lib.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
MySerial Serial;
|
||||
|
||||
unsigned long testlib_millis = 0;
|
||||
|
||||
uint8_t bms_status = ACTIVE;
|
||||
|
|
|
@ -2,14 +2,20 @@
|
|||
#define __TEST_LIB_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
#include "config.h"
|
||||
#include "microtest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MySerial;
|
||||
|
||||
extern unsigned long testlib_millis;
|
||||
extern MySerial Serial;
|
||||
extern uint8_t bms_status;
|
||||
|
||||
/* Mock millis() */
|
||||
static inline unsigned long millis(void) {
|
||||
|
@ -38,6 +44,4 @@ class MySerial {
|
|||
}
|
||||
};
|
||||
|
||||
extern MySerial Serial;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,13 +58,14 @@ TEST(set_event_test) {
|
|||
ASSERT_EQ(entries[EVENT_CELL_OVER_VOLTAGE].data, 0);
|
||||
ASSERT_EQ(entries[EVENT_CELL_OVER_VOLTAGE].occurences, 0);
|
||||
ASSERT_EQ(entries[EVENT_CELL_OVER_VOLTAGE].timestamp, 0);
|
||||
// Set current time and overvoltage event for cell 23
|
||||
// Set current time and overvoltage event for cell 23 (RED color, bms_status == FAULT)
|
||||
time_seconds = 345;
|
||||
set_event(EVENT_CELL_OVER_VOLTAGE, 123);
|
||||
// Ensure proper event data
|
||||
ASSERT_EQ(entries[EVENT_CELL_OVER_VOLTAGE].data, 123);
|
||||
ASSERT_EQ(entries[EVENT_CELL_OVER_VOLTAGE].occurences, 1);
|
||||
ASSERT_EQ(entries[EVENT_CELL_OVER_VOLTAGE].timestamp, 345);
|
||||
ASSERT_EQ(bms_status, FAULT);
|
||||
}
|
||||
|
||||
TEST(event_message_test) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue