rusefi/unit_tests/test-framework/unit_test_framework.cpp

42 lines
993 B
C++
Raw Normal View History

2018-03-04 12:57:15 -08:00
/*
* @file unit_test_framework.cpp
*
* Created on: Mar 4, 2018
2020-04-18 19:46:22 -07:00
* @author Andrey Belomutskiy, (c) 2012-2020
2018-03-04 12:57:15 -08:00
*/
#include "pch.h"
2018-03-04 12:57:15 -08:00
#include <stdlib.h>
/**
* ASSERT_xxx macro could only be used from inside 'void' methods - for cases where non-void methods are asserting, these
* wrapper functions are still useful.
*/
2018-03-04 12:57:15 -08:00
void assertEqualsM2(const char *msg, float expected, float actual, float eps) {
2019-07-24 21:28:04 -07:00
ASSERT_NEAR(expected, actual, eps) << msg;
2018-03-04 12:57:15 -08:00
}
void assertEqualsM4(const char *prefix, const char *msg, float expected, float actual) {
2020-07-31 19:02:48 -07:00
ASSERT_NEAR(expected, actual, 0.0001f) << prefix << msg;
2018-03-04 12:57:15 -08:00
}
void assertEqualsLM(const char *msg, long expected, long actual) {
2019-07-24 21:28:04 -07:00
ASSERT_EQ(expected, actual) << msg;
2018-03-04 12:57:15 -08:00
}
void assertEqualsM(const char *msg, float expected, float actual) {
assertEqualsM2(msg, expected, actual, 0.0001);
}
void chDbgAssert(int c, char *msg, void *arg) {
if (!c) {
printf("assert failed: %s\r\n", msg);
exit(-1);
}
}
uint32_t getTimeNowLowerNt(void) {
return 0;
}