Skip to content

Instantly share code, notes, and snippets.

View wmacevoy's full-sized avatar

Warren MacEvoy wmacevoy

View GitHub Profile
@wmacevoy
wmacevoy / ordered_tests1.ino
Created April 7, 2016 00:16
how to order tests by name
#include <ArduinoUnit.h>
test(t01_first) { Serial.print("one"); pass(); }
test(t02_second) { Serial.print("two"); pass(); }
test(t03_third) { Serial.print("three"); pass(); }
void setup()
{
Serial.begin(9600);
}
@wmacevoy
wmacevoy / ordered_tests2.ino
Last active April 7, 2016 17:22
Ordering tests
#include <ArduinoUnit.h>
testing(first) {
if (micros() > 100) { // just to put off finishing the first test.
Serial.println("pass first test.");
pass();
}
}
testing(second) {
@wmacevoy
wmacevoy / mocktest.ino
Created June 14, 2018 22:33
Using templates for efficient mocks for testing arduino components....
#include <ArduinoUnit.h>
// This is pretty advanced, you need to use template specialization to
// create mocks with no runtime overhead (other than space to represent
// the mocked environment, if you choose to use it (probably in a test).
struct RealImpl {
static void pMode(int pin, int mode) { pinMode(pin,mode); }
static void dWrite(int pin, bool value) { digitalWrite(pin,value); }
static int dRead(int pin) { return digitalRead(pin); }