Skip to content

Commit 6d2ab4b

Browse files
committed
add Arduino-CI + prepare unit tests
1 parent 798cfc2 commit 6d2ab4b

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

.arduino-ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
compile:
2+
# Choosing to run compilation tests on 2 different Arduino platforms
3+
platforms:
4+
- uno
5+
- leonardo
6+
- due
7+
- zero
8+
unittest:
9+
# These dependent libraries will be installed
10+
libraries:
11+
- "OneWire"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
arduino_ci:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: Arduino-CI/action@master
13+
# Arduino-CI/action@v0.1.1

test/unit_test_001.cpp_disabled

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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

Comments
 (0)