From efb84d4449bef040bdcb9326dbc953e8bb727094 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Tue, 10 Nov 2020 16:12:10 +1100 Subject: [PATCH] Fix some of the broken tables tests --- test/tests/test_misc/tests_tables.cpp | 59 +++++++++++++++++++-------- test/tests/test_misc/tests_tables.h | 21 +++++++++- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/test/tests/test_misc/tests_tables.cpp b/test/tests/test_misc/tests_tables.cpp index 3fb097a4..eed78d3a 100644 --- a/test/tests/test_misc/tests_tables.cpp +++ b/test/tests/test_misc/tests_tables.cpp @@ -33,23 +33,24 @@ void setup_FuelTable(void) int tempYAxis[16] = {100, 96, 90, 86, 76, 70, 66, 60, 56, 50, 46, 40, 36, 30, 26, 16}; for (byte x = 0; x< fuelTable.ySize; x++) { fuelTable.axisY[x] = tempYAxis[x]; } - //Go through the 8 rows and add the column values - byte tempRow1[16] = {109, 111, 112, 113, 114, 114, 114, 115, 115, 115, 114, 114, 113, 112, 111, 111}; - byte tempRow2[16] = {104, 106, 107, 108, 109, 109, 110, 110, 110, 110, 110, 109, 108, 107, 107, 106}; - byte tempRow3[16] = {98, 101, 103, 103, 104, 105, 105, 105, 105, 105, 105, 104, 104, 103, 102, 102}; - byte tempRow4[16] = {93, 96, 98, 99, 99, 100, 100, 101, 101, 101, 100, 100, 99, 98, 98, 97}; - byte tempRow5[16] = {81, 86, 88, 89, 90, 91, 91, 91, 91, 91, 91, 90, 90, 89, 89, 88}; - byte tempRow6[16] = {74, 80, 83, 84, 85, 86, 86, 86, 87, 86, 86, 86, 85, 84, 84, 84}; - byte tempRow7[16] = {68, 75, 78, 79, 81, 81, 81, 82, 82, 82, 82, 81, 81, 80, 79, 79}; - byte tempRow8[16] = {61, 69, 72, 74, 76, 76, 77, 77, 77, 77, 77, 76, 76, 75, 75, 74}; - byte tempRow9[16] = {54, 62, 66, 69, 71, 71, 72, 72, 72, 72, 72, 72, 71, 71, 70, 70}; - byte tempRow10[16] = {48, 56, 60, 64, 66, 66, 68, 68, 68, 68, 67, 67, 67, 66, 66, 65}; - byte tempRow11[16] = {42, 49, 54, 58, 61, 62, 62, 63, 63, 63, 63, 62, 62, 61, 61, 61}; - byte tempRow12[16] = {38, 43, 48, 52, 55, 56, 57, 58, 58, 58, 58, 58, 57, 57, 57, 56}; - byte tempRow13[16] = {36, 39, 42, 46, 50, 51, 52, 53, 53, 53, 53, 53, 53, 52, 52, 52}; - byte tempRow14[16] = {35, 36, 38, 41, 44, 46, 47, 48, 48, 49, 48, 48, 48, 48, 47, 47}; - byte tempRow15[16] = {34, 35, 36, 37, 39, 41, 42, 43, 43, 44, 44, 44, 43, 43, 43, 43}; - byte tempRow16[16] = {34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 34, 34, 34, 34, 34, 34}; + + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[0][x] = pgm_read_byte_near(tempRow1 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[1][x] = pgm_read_byte_near(tempRow2 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[2][x] = pgm_read_byte_near(tempRow3 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[3][x] = pgm_read_byte_near(tempRow4 + x);} + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[4][x] = pgm_read_byte_near(tempRow5 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[5][x] = pgm_read_byte_near(tempRow6 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[6][x] = pgm_read_byte_near(tempRow7 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[7][x] = pgm_read_byte_near(tempRow8 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[8][x] = pgm_read_byte_near(tempRow9 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[9][x] = pgm_read_byte_near(tempRow10 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[10][x] = pgm_read_byte_near(tempRow11 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[11][x] = pgm_read_byte_near(tempRow12 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[12][x] = pgm_read_byte_near(tempRow13 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[13][x] = pgm_read_byte_near(tempRow14 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[14][x] = pgm_read_byte_near(tempRow15 + x); } + for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[15][x] = pgm_read_byte_near(tempRow16 + x); } + /* for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[0][x] = tempRow1[x]; } for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[1][x] = tempRow2[x]; } for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[2][x] = tempRow3[x]; } @@ -66,6 +67,7 @@ void setup_FuelTable(void) for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[13][x] = tempRow14[x]; } for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[14][x] = tempRow15[x]; } for (byte x = 0; x< fuelTable.xSize; x++) { fuelTable.values[15][x] = tempRow16[x]; } + */ } @@ -78,12 +80,14 @@ void testTables() RUN_TEST(test_tableLookup_overMaxY); RUN_TEST(test_tableLookup_underMinX); RUN_TEST(test_tableLookup_underMinY); + //RUN_TEST(test_all_incrementing); + } void test_tableLookup_50pct(void) { //Tests a lookup that is exactly 50% of the way between cells on both the X and Y axis - initialiseAll(); //Run the main initialise function + //initialiseAll(); //Run the main initialise function setup_FuelTable(); currentStatus.RPM = 2250; @@ -169,4 +173,23 @@ void test_tableLookup_underMinY(void) uint16_t tempVE = get3DTableValue(&fuelTable, currentStatus.fuelLoad, currentStatus.RPM); //Perform lookup into fuel map for RPM vs MAP value TEST_ASSERT_EQUAL(tempVE, 34); +} + +void test_all_incrementing(void) +{ + //Test the when going up both the load and RPM axis that the returned value is always equal or higher to the previous one + //Tests all combinations of load/rpm from between 0-200 load and 0-9000 rpm + //WARNING: This can take a LONG time to run. It is disabled by default for this reason + uint16_t tempVE = 0; + + for(uint16_t rpm = 0; rpm<8000; rpm+=100) + { + tempVE = 0; + for(uint8_t load = 0; load<120; load++) + { + uint16_t newVE = get3DTableValue(&fuelTable, load, rpm); + TEST_ASSERT_GREATER_OR_EQUAL(tempVE, newVE); + tempVE = newVE; + } + } } \ No newline at end of file diff --git a/test/tests/test_misc/tests_tables.h b/test/tests/test_misc/tests_tables.h index 18aeae8b..58cb9f4c 100644 --- a/test/tests/test_misc/tests_tables.h +++ b/test/tests/test_misc/tests_tables.h @@ -6,4 +6,23 @@ void test_tableLookup_exact2Axis(void); void test_tableLookup_overMaxX(void); void test_tableLookup_overMaxY(void); void test_tableLookup_underMinX(void); -void test_tableLookup_underMinY(void); \ No newline at end of file +void test_tableLookup_underMinY(void); +void test_all_incrementing(void); + + //Go through the 8 rows and add the column values + const PROGMEM byte tempRow1[16] = {109, 111, 112, 113, 114, 114, 114, 115, 115, 115, 114, 114, 113, 112, 111, 111}; + const PROGMEM byte tempRow2[16] = {104, 106, 107, 108, 109, 109, 110, 110, 110, 110, 110, 109, 108, 107, 107, 106}; + const PROGMEM byte tempRow3[16] = {98, 101, 103, 103, 104, 105, 105, 105, 105, 105, 105, 104, 104, 103, 102, 102}; + const PROGMEM byte tempRow4[16] = {93, 96, 98, 99, 99, 100, 100, 101, 101, 101, 100, 100, 99, 98, 98, 97}; + const PROGMEM byte tempRow5[16] = {81, 86, 88, 89, 90, 91, 91, 91, 91, 91, 91, 90, 90, 89, 89, 88}; + const PROGMEM byte tempRow6[16] = {74, 80, 83, 84, 85, 86, 86, 86, 87, 86, 86, 86, 85, 84, 84, 84}; + const PROGMEM byte tempRow7[16] = {68, 75, 78, 79, 81, 81, 81, 82, 82, 82, 82, 81, 81, 80, 79, 79}; + const PROGMEM byte tempRow8[16] = {61, 69, 72, 74, 76, 76, 77, 77, 77, 77, 77, 76, 76, 75, 75, 74}; + const PROGMEM byte tempRow9[16] = {54, 62, 66, 69, 71, 71, 72, 72, 72, 72, 72, 72, 71, 71, 70, 70}; + const PROGMEM byte tempRow10[16] = {48, 56, 60, 64, 66, 66, 68, 68, 68, 68, 67, 67, 67, 66, 66, 65}; + const PROGMEM byte tempRow11[16] = {42, 49, 54, 58, 61, 62, 62, 63, 63, 63, 63, 62, 62, 61, 61, 61}; + const PROGMEM byte tempRow12[16] = {38, 43, 48, 52, 55, 56, 57, 58, 58, 58, 58, 58, 57, 57, 57, 56}; + const PROGMEM byte tempRow13[16] = {36, 39, 42, 46, 50, 51, 52, 53, 53, 53, 53, 53, 53, 52, 52, 52}; + const PROGMEM byte tempRow14[16] = {35, 36, 38, 41, 44, 46, 47, 48, 48, 49, 48, 48, 48, 48, 47, 47}; + const PROGMEM byte tempRow15[16] = {34, 35, 36, 37, 39, 41, 42, 43, 43, 44, 44, 44, 43, 43, 43, 43}; + const PROGMEM byte tempRow16[16] = {34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 34, 34, 34, 34, 34, 34}; \ No newline at end of file