|
| 1 | + |
| 2 | +// DISABLED AS NOT ALL STD LIBRARIES ARE MOCKED / INCLUDEABLE |
| 3 | + |
| 4 | + |
| 5 | +// |
| 6 | +// FILE: unit_test_001.cpp |
| 7 | +// AUTHOR: Miles Burton / Rob Tillaart |
| 8 | +// DATE: 2021-01-10 |
| 9 | +// PURPOSE: unit tests for the Arduino-Temperature-Control-Library |
| 10 | +// https://github.com/MilesBurton/Arduino-Temperature-Control-Library |
| 11 | +// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md |
| 12 | +// |
| 13 | + |
| 14 | +// supported assertions |
| 15 | +// ---------------------------- |
| 16 | +// assertEqual(expected, actual); // a == b |
| 17 | +// assertNotEqual(unwanted, actual); // a != b |
| 18 | +// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b)) |
| 19 | +// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b)) |
| 20 | +// assertLess(upperBound, actual); // a < b |
| 21 | +// assertMore(lowerBound, actual); // a > b |
| 22 | +// assertLessOrEqual(upperBound, actual); // a <= b |
| 23 | +// assertMoreOrEqual(lowerBound, actual); // a >= b |
| 24 | +// assertTrue(actual); |
| 25 | +// assertFalse(actual); |
| 26 | +// assertNull(actual); |
| 27 | + |
| 28 | +// // special cases for floats |
| 29 | +// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon |
| 30 | +// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon |
| 31 | +// assertInfinity(actual); // isinf(a) |
| 32 | +// assertNotInfinity(actual); // !isinf(a) |
| 33 | +// assertNAN(arg); // isnan(a) |
| 34 | +// assertNotNAN(arg); // !isnan(a) |
| 35 | + |
| 36 | +#include <ArduinoUnitTests.h> |
| 37 | + |
| 38 | + |
| 39 | +#include "Arduino.h" |
| 40 | + |
| 41 | +/* |
| 42 | + |
| 43 | + |
| 44 | +// BASED UPON SIMPLE |
| 45 | +// |
| 46 | + |
| 47 | + |
| 48 | +#include "OneWire.h" |
| 49 | +#include "DallasTemperature.h" |
| 50 | + |
| 51 | +// Data wire is plugged into port 2 on the Arduino |
| 52 | +#define ONE_WIRE_BUS 2 |
| 53 | + |
| 54 | +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) |
| 55 | +OneWire oneWire(ONE_WIRE_BUS); |
| 56 | + |
| 57 | +// Pass our oneWire reference to Dallas Temperature. |
| 58 | +DallasTemperature sensors(&oneWire); |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +unittest_setup() |
| 63 | +{ |
| 64 | +} |
| 65 | + |
| 66 | +unittest_teardown() |
| 67 | +{ |
| 68 | +} |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +unittest(test_constructor) |
| 73 | +{ |
| 74 | + fprintf(stderr, "VERSION: %s\n", DALLASTEMPLIBVERSION); |
| 75 | + |
| 76 | + sensors.begin(); |
| 77 | + sensors.requestTemperatures(); |
| 78 | + float tempC = sensors.getTempCByIndex(0); |
| 79 | + if(tempC != DEVICE_DISCONNECTED_C) |
| 80 | + { |
| 81 | + fprintf(stderr, "Temperature for the device 1 (index 0) is: "); |
| 82 | + fprintf(stderr, "5f\n", tempC); |
| 83 | + } |
| 84 | + else |
| 85 | + { |
| 86 | + fprintf(stderr, "Error: Could not read temperature data\n"); |
| 87 | + } |
| 88 | + |
| 89 | + assertEqual(1, 1); // keep unit test happy |
| 90 | +} |
| 91 | +*/ |
| 92 | + |
| 93 | +unittest_main() |
| 94 | + |
| 95 | +// -------- |
0 commit comments