Initial commit of the unit testing framework

This commit is contained in:
Josh Stewart 2020-01-24 12:21:12 +11:00
parent 76ef814847
commit b2c27b7eb0
6 changed files with 60 additions and 2 deletions

View File

@ -124,7 +124,8 @@ void canCommand()
break;
case 'Q': // send code version
for (unsigned int revn = 0; revn < sizeof( TSfirmwareVersion) - 1; revn++)
//for (unsigned int revn = 0; revn < sizeof( TSfirmwareVersion) - 1; revn++)
for (unsigned int revn = 0; revn < 10 - 1; revn++)
{
CANSerial.write( TSfirmwareVersion[revn]);
}

View File

@ -58,7 +58,8 @@ void sendPageASCII();
void receiveCalibration(byte);
void sendToothLog();
void testComm();
void commandButtons();
void commandButtons(int16_t);
void sendCompositeLog();
byte getPageValue(byte, uint16_t);
#endif // COMMS_H

View File

@ -93,6 +93,7 @@ void triggerSec_Miata9905();
uint16_t getRPM_Miata9905();
int getCrankAngle_Miata9905();
void triggerSetEndTeeth_Miata9905();
int getCamAngle_Miata9905();
void triggerSetup_MazdaAU();
void triggerPri_MazdaAU();

26
test/tests_init.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <globals.h>
#include <init.h>
#include <unity.h>
#include "tests_init.h"
void testInitialisation()
{
RUN_TEST(test_initialisation_complete);
RUN_TEST(test_initialisation_ports);
}
void test_initialisation_complete(void)
{
initialiseAll(); //Run the main initialise function
TEST_ASSERT_EQUAL(true, initialisationComplete);
}
void test_initialisation_ports(void)
{
initialiseAll(); //Run the main initialise function
TEST_ASSERT_NOT_EQUAL(0, inj1_pin_port);
TEST_ASSERT_NOT_EQUAL(0, inj2_pin_port);
TEST_ASSERT_NOT_EQUAL(0, inj3_pin_port);
TEST_ASSERT_NOT_EQUAL(0, inj4_pin_port);
}

3
test/tests_init.h Normal file
View File

@ -0,0 +1,3 @@
void testInitialisation();
void test_initialisation_complete(void);
void test_initialisation_ports(void);

26
test/tests_main.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <Arduino.h>
#include "tests_init.h"
#include <unity.h>
void setup() {
// NOTE!!! Wait for >2 secs
// if board doesn't support software reset via Serial.DTR/RTS
delay(2000);
UNITY_BEGIN(); // IMPORTANT LINE!
pinMode(LED_BUILTIN, OUTPUT);
}
uint8_t i = 0;
uint8_t max_blinks = 5;
void loop()
{
testInitialisation();
UNITY_END(); // stop unit testing
}