/* * Authors (alphabetical order) * - Bertrand Songis * - Bryan J. Rentoul (Gruvin) * * gruvin9x is based on code named er9x by * Author - Erez Raviv , which is in turn * was based on the original (and ongoing) project by Thomas Husterer, * th9x -- http://code.google.com/p/th9x/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include #include "gruvin9x.h" uint16_t anaIn(uint8_t chan) { return 0; } TEST(trims, greaterTrimLink) { memset(&g_model, 0, sizeof(g_model)); setTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim setTrimValue(3, 0, 32); EXPECT_EQ(getTrimValue(getTrimFlightPhase(0, 1), 0), 32); } TEST(trims, chainedTrims) { memset(&g_model, 0, sizeof(g_model)); setTrimValue(0, 0, 32); setTrimValue(1, 0, TRIM_EXTENDED_MAX+1); // link to FP0 trim setTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim EXPECT_EQ(getTrimValue(getTrimFlightPhase(0, 2), 0), 32); } TEST(trims, infiniteChainedTrims) { memset(&g_model, 0, sizeof(g_model)); setTrimValue(0, 0, 32); setTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim setTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim setTrimValue(3, 0, TRIM_EXTENDED_MAX+3); // link to FP2 trim EXPECT_EQ(getTrimValue(getTrimFlightPhase(0, 2), 0), 32); } TEST(outdezNAtt, test_unsigned) { uint16_t altitude = 65530; uint8_t refBuf[sizeof(displayBuf)]; memset(displayBuf, 0, sizeof(displayBuf)); lcd_putc(0*FWNUM, 0, '6'); lcd_putc(1*FWNUM, 0, '5'); lcd_putc(2*FWNUM, 0, '5'); lcd_putc(3*FWNUM, 0, '3'); lcd_putc(4*FWNUM, 0, '0'); memcpy(refBuf, displayBuf, sizeof(displayBuf)); memset(displayBuf, 0, sizeof(displayBuf)); lcd_outdezNAtt(1, 0, altitude, LEFT|UNSIGN); EXPECT_EQ(memcmp(refBuf, displayBuf, sizeof(displayBuf)), 0) << "Unsigned numbers will be bad displayed"; } TEST(EEPROM, 1000_random_writes) { eepromFile = NULL; // in memory RlcFile f; uint8_t buf[1000]; uint8_t buf2[1000]; EeFsFormat(); for(int i=0; i<1000; i++) { int size = rand()%800; for(int j=0; j