Skip to content

Commit

Permalink
adding assert failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackstoneEngineering committed Jul 13, 2016
1 parent 631392f commit 908003b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 58 deletions.
108 changes: 54 additions & 54 deletions TESTS/API/AnalogOut/AnalogOut.cpp
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "rtos.h"

using namespace utest::v1;

// Template to set one Analog pin as input and then cycle through the rest as outputs.
// As you turn more pins on the voltage on the ain pin will go up.
template <PinName aout_pin, PinName ain_pin>
void AnalogOutput_Test()
{
AnalogIn ain(ain_pin);
AnalogOut aout(aout_pin);
float valueOff = 0;
float valueOn = 0;
aout = 0;
valueOff = ain.read();
aout = 0.5;
valueOn = ain.read();
printf("***** valueOff = %f, valueOn = %f \n",valueOff, valueOn);
TEST_ASSERT(valueOn > valueOff);
valueOff = ain.read();
aout = 1.0;
valueOn = ain.read();
printf("***** valueOff = %f, valueOn = %f \n",valueOff, valueOn);
TEST_ASSERT(valueOn > valueOff);
}

utest::v1::status_t test_setup(const size_t number_of_cases) {
// Setup Greentea using a reasonable timeout in seconds
GREENTEA_SETUP(30, "default_auto");
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
// TODO: take input based on pinmap
Case cases[] = {
Case("Test Analog Output on A5", AnalogOutput_Test<A5,A0>,greentea_failure_handler),
};

Specification specification(test_setup, cases);

// Entry point into the tests
int main() {
return !Harness::run(specification);
}
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "rtos.h"

using namespace utest::v1;

// Template to set one Analog pin as input and then cycle through the rest as outputs.
// As you turn more pins on the voltage on the ain pin will go up.
template <PinName aout_pin, PinName ain_pin>
void AnalogOutput_Test()
{
AnalogIn ain(ain_pin);
AnalogOut aout(aout_pin);
float valueOff = 0;
float valueOn = 0;
aout = 0;
valueOff = ain.read();
aout = 0.5;
valueOn = ain.read();
printf("***** valueOff = %f, valueOn = %f \n",valueOff, valueOn);
TEST_ASSERT(valueOn > valueOff);
valueOff = ain.read();
aout = 1.0;
valueOn = ain.read();
printf("***** valueOff = %f, valueOn = %f \n",valueOff, valueOn);
TEST_ASSERT(valueOn > valueOff);
}

utest::v1::status_t test_setup(const size_t number_of_cases) {
// Setup Greentea using a reasonable timeout in seconds
GREENTEA_SETUP(30, "default_auto");
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
// TODO: take input based on pinmap
Case cases[] = {
Case("Test Analog Output on A5", AnalogOutput_Test<A5,A0>,greentea_failure_handler),
};

Specification specification(test_setup, cases);

// Entry point into the tests
int main() {
return !Harness::run(specification);
}
2 changes: 1 addition & 1 deletion TESTS/API/SPI/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

void test_sd_write(){
// Currently no SD Test written, waiting for public release to enable
TEST_ASSERT(false);
TEST_ASSERT_MESSAGE(false,"SD Tests are not supported yet, this is a placeholder for future tests.");
}

utest::v1::status_t test_setup(const size_t number_of_cases) {
Expand Down
5 changes: 2 additions & 3 deletions TESTS/API/UART/UART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ void test_uart_single(){
TEST_ASSERT(UART_SENTINAL == value);
if(UART_SENTINAL == value){
// printf("Test Finished Successfully!\n");
TEST_ASSERT(true);
TEST_ASSERT_MESSAGE(true,"characters match!");
} else{
// printf("Test Failed! \n");
TEST_ASSERT(false);
TEST_ASSERT_MESSAGE(false,"characters do not match, possible corruption?");
}
TEST_ASSERT(true);
}

// TODO: add more verbose tests
Expand Down

0 comments on commit 908003b

Please sign in to comment.