rusefi/unit_tests/unit_test_framework.cpp

41 lines
987 B
C++
Raw Normal View History

2018-03-04 12:57:15 -08:00
/*
* @file unit_test_framework.cpp
*
* Created on: Mar 4, 2018
* Author: Andrey Belomutskiy, (c) 2012-2018
*/
#include <stdlib.h>
2018-09-16 19:39:46 -07:00
#include "global.h"
2019-07-24 21:28:04 -07:00
#include "unit_test_framework.h"
2018-03-04 12:57:15 -08:00
/**
* 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) {
2019-07-24 21:28:04 -07:00
ASSERT_NEAR(expected, actual, 0.00001) << 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);
}
}