Skip to content

Commit d66fec4

Browse files
authored
Merge pull request #192 from RobTillaart/master
add Arduino-CI + prepare unit tests
2 parents 798cfc2 + 2da19ae commit d66fec4

File tree

5 files changed

+147
-0
lines changed

5 files changed

+147
-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"

.github/workflows/arduino-lint.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
on: [push, pull_request]
2+
jobs:
3+
lint:
4+
runs-on: ubuntu-latest
5+
steps:
6+
- uses: actions/checkout@v2
7+
- uses: arduino/arduino-lint-action@v1
8+
with:
9+
library-manager: update
10+
compliance: strict
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/[email protected]

.github/workflows/jsoncheck.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: json-syntax-check
15+
uses: limitusus/json-syntax-check@v1
16+
with:
17+
pattern: "\\.json$"
18+

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)