From b33ac53f2856431e7081f1be8df85b0c592cc707 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 4 Jan 2019 00:30:15 -0500 Subject: [PATCH] #34 --- unit_tests/test.mk | 1 + unit_tests/test_hip9011.cpp | 30 ++++++++++++++++++++++++++++++ unit_tests/test_sensors.cpp | 25 ------------------------- 3 files changed, 31 insertions(+), 25 deletions(-) create mode 100644 unit_tests/test_hip9011.cpp diff --git a/unit_tests/test.mk b/unit_tests/test.mk index ecd2ced8c4..c702d9a823 100644 --- a/unit_tests/test.mk +++ b/unit_tests/test.mk @@ -5,6 +5,7 @@ TEST_SRC_CPP = test_util.cpp \ test_basic_math/test_find_index.cpp \ test_basic_math/test_interpolation_3d.cpp \ test_cj125.cpp \ + test_hip9011.cpp \ test_data_structures/test_engine_math.cpp \ test_startOfCrankingPrimingPulse.cpp \ test_fasterEngineSpinningUp.cpp \ diff --git a/unit_tests/test_hip9011.cpp b/unit_tests/test_hip9011.cpp new file mode 100644 index 0000000000..068c411e06 --- /dev/null +++ b/unit_tests/test_hip9011.cpp @@ -0,0 +1,30 @@ +/* + * @file test_hip9011.cpp + * + * Created on: Mar 22, 2018 + */ + +#include "unit_test_framework.h" +#include "hip9011_lookup.h" +#include "gtest/gtest.h" + +TEST(hip9011, lookup) { + assertEqualsM2("", 3183.1013, getRpmByAngleWindowAndTimeUs(600, 360), 0.1); + assertEqualsM2("40us", 47746.5195, getRpmByAngleWindowAndTimeUs(40, 360), 0.1); + + assertEqualsM2("600us 50 degree", 442.0974, getRpmByAngleWindowAndTimeUs(600, 50), 0.1); + assertEqualsM2("240us 50 degree", 1105.2435, getRpmByAngleWindowAndTimeUs(240, 50), 0.1); + assertEqualsM2("240us 50 degree", 6631.4619, getRpmByAngleWindowAndTimeUs(40, 50), 0.1); + + EXPECT_EQ(0, getHip9011GainIndex(3)); + EXPECT_EQ(0, getHip9011GainIndex(2)); + EXPECT_EQ(47, getHip9011GainIndex(0.234)); + EXPECT_EQ(63, getHip9011GainIndex(0.000001)); + + prepareHip9011RpmLookup(50); + + EXPECT_EQ(31, getIntegrationIndexByRpm(1)); + EXPECT_EQ(21, getIntegrationIndexByRpm(1100)); + EXPECT_EQ(1, getIntegrationIndexByRpm(6600)); + EXPECT_EQ(0, getIntegrationIndexByRpm(16600)); +} diff --git a/unit_tests/test_sensors.cpp b/unit_tests/test_sensors.cpp index b8ef5bedc1..fe21b0b282 100644 --- a/unit_tests/test_sensors.cpp +++ b/unit_tests/test_sensors.cpp @@ -8,7 +8,6 @@ #include "global.h" #include "thermistors.h" #include "allsensors.h" -#include "hip9011_lookup.h" #include "engine_test_helper.h" static ThermistorConf tc; @@ -58,35 +57,11 @@ void testTpsRateOfChange(void) { // assertEquals(25, getTpsRateOfChange()); } -static void testHip9011lookup(void) { - print("************************************************** testHip9011lookup\r\n"); - - assertEqualsM2("", 3183.1013, getRpmByAngleWindowAndTimeUs(600, 360), 0.1); - assertEqualsM2("40us", 47746.5195, getRpmByAngleWindowAndTimeUs(40, 360), 0.1); - - assertEqualsM2("600us 50 degree", 442.0974, getRpmByAngleWindowAndTimeUs(600, 50), 0.1); - assertEqualsM2("240us 50 degree", 1105.2435, getRpmByAngleWindowAndTimeUs(240, 50), 0.1); - assertEqualsM2("240us 50 degree", 6631.4619, getRpmByAngleWindowAndTimeUs(40, 50), 0.1); - - assertEquals(0, getHip9011GainIndex(3)); - assertEquals(0, getHip9011GainIndex(2)); - assertEquals(47, getHip9011GainIndex(0.234)); - assertEquals(63, getHip9011GainIndex(0.000001)); - - prepareHip9011RpmLookup(50); - - assertEquals(31, getIntegrationIndexByRpm(1)); - assertEquals(21, getIntegrationIndexByRpm(1100)); - assertEquals(1, getIntegrationIndexByRpm(6600)); - assertEquals(0, getIntegrationIndexByRpm(16600)); -} - void testSensors(void) { print("************************************************** testSensors\r\n"); testMapDecoding(); testTps(); testTpsRateOfChange(); - testHip9011lookup(); ThermistorMath tm; {