rusefi/unit_tests/test-framework/unit_test_framework.h

35 lines
1.0 KiB
C
Raw Normal View History

2018-03-04 12:57:15 -08:00
/*
* @file unit_test_framework.h
2018-03-04 12:57:15 -08:00
*
* @date Mar 4, 2018
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2018-03-04 12:57:15 -08:00
*/
2020-01-31 10:45:15 -08:00
#pragma once
2018-03-04 12:57:15 -08:00
2019-12-01 22:52:54 -08:00
using ::testing::Return;
2018-03-04 12:57:15 -08:00
2019-10-13 06:59:43 -07:00
// This lets us inspect private state from unit tests
2020-09-03 19:52:29 -07:00
// cool hack but probably should not be used, even conditional private/public compilation is more obvious
//#define private public
2019-10-13 06:59:43 -07:00
/**
2024-05-01 08:31:30 -07:00
* These are usually used with ASSERT_NEAR(val1, val2, abs_error)
*/
#define EPS0D 1
2019-01-14 15:20:20 -08:00
#define EPS1D 0.1
#define EPS2D 0.01
#define EPS3D 0.001
#define EPS4D 0.0001
#define EPS5D 0.00001
2019-01-14 20:40:13 -08:00
// todo: migrate to googletest, use EXPECT_* and ASSERT_*
2024-05-01 08:27:54 -07:00
// along the lines of ASSERT_EQ(x, y) << msg;
2018-03-04 19:00:32 -08:00
void assertEqualsM2(const char *msg, float expected, float actual, float EPS);
void assertEqualsM(const char *msg, float expected, float actual);
void assertEqualsLM(const char *msg, long expected, long actual);
void assertEqualsM4(const char *prefix, const char *msg, float expected, float actual);
2018-03-04 12:57:15 -08:00
#define EXPECT_NO_FATAL_ERROR EXPECT_NO_THROW
#define EXPECT_FATAL_ERROR(expr) EXPECT_THROW((expr), std::logic_error)