-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial arduino-ci * add unit tests (with some fails as no HW present)
- Loading branch information
1 parent
b116412
commit 5c30a2b
Showing
8 changed files
with
147 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
platforms: | ||
- uno | ||
- leonardo | ||
- due | ||
- zero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
name: Arduino CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
arduino_ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Arduino-CI/action@master | ||
# Arduino-CI/action@v0.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// | ||
// FILE: unit_test_001.cpp | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2020-12-24 | ||
// PURPOSE: unit tests for the GY521 | ||
// https://github.com/RobTillaart/GY521 | ||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md | ||
// | ||
|
||
// supported assertions | ||
// https://github.com/Arduino-CI/arduino_ci/blob/master/cpp/unittest/Assertion.h#L33-L42 | ||
// ---------------------------- | ||
// assertEqual(expected, actual) | ||
// assertNotEqual(expected, actual) | ||
// assertLess(expected, actual) | ||
// assertMore(expected, actual) | ||
// assertLessOrEqual(expected, actual) | ||
// assertMoreOrEqual(expected, actual) | ||
// assertTrue(actual) | ||
// assertFalse(actual) | ||
// assertNull(actual) | ||
// assertNotNull(actual) | ||
|
||
#include <ArduinoUnitTests.h> | ||
|
||
#define assertEqualFloat(arg1, arg2, arg3) assertOp("assertEqualFloat", "expected", fabs(arg1 - arg2), compareLessOrEqual, "<=", "actual", arg3) | ||
#define assertEqualINF(arg) assertOp("assertEqualINF", "expected", INFINITY, compareEqual, "==", "actual", arg) | ||
#define assertEqualNAN(arg) assertOp("assertEqualNAN", "expected", true, compareEqual, "==", "actual", isnan(arg)) | ||
|
||
|
||
#include "Arduino.h" | ||
#include "GY521.h" | ||
|
||
|
||
|
||
unittest_setup() | ||
{ | ||
} | ||
|
||
unittest_teardown() | ||
{ | ||
} | ||
|
||
/* | ||
unittest(test_new_operator) | ||
{ | ||
assertEqualINF(exp(800)); | ||
assertEqualINF(0.0/0.0); | ||
assertEqualINF(42); | ||
assertEqualNAN(INFINITY - INFINITY); | ||
assertEqualNAN(0.0/0.0); | ||
assertEqualNAN(42); | ||
} | ||
*/ | ||
|
||
unittest(test_constructor) | ||
{ | ||
GY521 sensor(0x69); | ||
fprintf(stderr, "VERSION: %s\n", GY521_LIB_VERSION); | ||
sensor.begin(); | ||
assertEqual(GY521_OK, sensor.getError()); | ||
|
||
assertTrue(sensor.isConnected()); | ||
} | ||
|
||
|
||
unittest(test_get_set) | ||
{ | ||
GY521 sensor(0x69); | ||
fprintf(stderr, "VERSION: %s\n", GY521_LIB_VERSION); | ||
sensor.begin(); | ||
assertEqual(GY521_OK, sensor.getError()); | ||
|
||
sensor.setThrottle(true); | ||
assertTrue(sensor.getThrottle()); | ||
sensor.setThrottle(false); | ||
assertFalse(sensor.getThrottle()); | ||
|
||
fprintf(stderr, "setThrottleTime()\n"); | ||
for (uint16_t ti = 1; ti != 0; ti <<= 1) | ||
{ | ||
sensor.setThrottleTime(ti); | ||
fprintf(stderr, "%d\t", sensor.getThrottleTime()); | ||
assertEqual(ti, sensor.getThrottleTime()); | ||
} | ||
|
||
fprintf(stderr, "setAccelSensitivity() - fails \n"); | ||
for (int as = 0; as < 4; as++) | ||
{ | ||
sensor.setAccelSensitivity(as); | ||
// fprintf(stderr, "%d\n", sensor.getAccelSensitivity()); | ||
assertEqual(255, sensor.getAccelSensitivity()); | ||
} | ||
|
||
fprintf(stderr, "setGyroSensitivity() - fails \n"); | ||
for (int gs = 0; gs < 4; gs++) | ||
{ | ||
sensor.setGyroSensitivity(gs); | ||
// fprintf(stderr, "%d\n", sensor.getAccelSensitivity()); | ||
assertEqual(255, sensor.getAccelSensitivity()); | ||
} | ||
|
||
} | ||
|
||
unittest_main() | ||
|
||
// -------- |