-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from RobTillaart/main
Add Arduino build-CI + badges in readme.md
- Loading branch information
Showing
11 changed files
with
220 additions
and
4 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,27 @@ | ||
platforms: | ||
rpipico: | ||
board: rp2040:rp2040:rpipico | ||
package: rp2040:rp2040 | ||
gcc: | ||
features: | ||
defines: | ||
- ARDUINO_ARCH_RP2040 | ||
warnings: | ||
flags: | ||
|
||
packages: | ||
rp2040:rp2040: | ||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json | ||
|
||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
platforms: | ||
- uno | ||
# - due | ||
# - zero | ||
# - leonardo | ||
- m4 | ||
- esp32 | ||
- esp8266 | ||
# - mega2560 | ||
- rpipico |
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-lint | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update | ||
compliance: strict |
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,17 @@ | ||
--- | ||
name: Arduino CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
runTest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
- run: | | ||
gem install arduino_ci | ||
arduino_ci.rb |
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,18 @@ | ||
name: JSON check | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.json' | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: json-syntax-check | ||
uses: limitusus/json-syntax-check@v1 | ||
with: | ||
pattern: "\\.json$" | ||
|
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
File renamed without changes.
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,124 @@ | ||
// | ||
// FILE: unit_test_001.cpp | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2023-06-28 | ||
// PURPOSE: unit tests for Smooth library | ||
// https://github.com/RobTillaart/SIMON | ||
// | ||
|
||
|
||
// supported assertions | ||
// ---------------------------- | ||
// assertEqual(expected, actual); // a == b | ||
// assertNotEqual(unwanted, actual); // a != b | ||
// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b)) | ||
// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b)) | ||
// assertLess(upperBound, actual); // a < b | ||
// assertMore(lowerBound, actual); // a > b | ||
// assertLessOrEqual(upperBound, actual); // a <= b | ||
// assertMoreOrEqual(lowerBound, actual); // a >= b | ||
// assertTrue(actual); | ||
// assertFalse(actual); | ||
// assertNull(actual); | ||
|
||
// // special cases for floats | ||
// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon | ||
// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon | ||
// assertInfinity(actual); // isinf(a) | ||
// assertNotInfinity(actual); // !isinf(a) | ||
// assertNAN(arg); // isnan(a) | ||
// assertNotNAN(arg); // !isnan(a) | ||
|
||
|
||
#include <ArduinoUnitTests.h> | ||
|
||
#include "Arduino.h" | ||
#include "Smooth.h" | ||
|
||
|
||
unittest_setup() | ||
{ | ||
fprintf(stderr, "Arduino Smooth library\n"); | ||
} | ||
|
||
|
||
unittest_teardown() | ||
{ | ||
} | ||
|
||
|
||
unittest(test_constructor) | ||
{ | ||
Smooth sm(42); | ||
assertEqual(42, sm.get_window()); | ||
assertEqual(0, sm.get_count()); | ||
assertEqualFloat(0, sm.get_avg(), 0.0001); | ||
|
||
Smooth sm0(5, 0, 0); | ||
assertEqual(5, sm0.get_window()); | ||
assertEqual(0, sm0.get_count()); | ||
assertEqualFloat(0, sm0.get_avg(), 0.0001); | ||
|
||
Smooth sm1(7, 20); | ||
assertEqual(7, sm1.get_window()); | ||
assertEqual(20, sm1.get_count()); | ||
assertEqualFloat(0, sm0.get_avg(), 0.0001); | ||
|
||
Smooth sm2(15, 25, 10); | ||
assertEqual(15, sm2.get_window()); | ||
assertEqual(25, sm2.get_count()); | ||
assertEqualFloat(10, sm2.get_avg(), 0.0001); | ||
} | ||
|
||
|
||
unittest(test_reset) | ||
{ | ||
Smooth sm2(15, 25, 10); | ||
assertEqual(15, sm2.get_window()); | ||
assertEqual(25, sm2.get_count()); | ||
assertEqualFloat(10, sm2.get_avg(), 0.0001); | ||
|
||
sm2.reset(10); | ||
assertEqual(10, sm2.get_window()); | ||
assertEqual(0, sm2.get_count()); | ||
assertEqualFloat(0, sm2.get_avg(), 0.0001); | ||
|
||
sm2.reset(5, 4); | ||
assertEqual(5, sm2.get_window()); | ||
assertEqual(4, sm2.get_count()); | ||
assertEqualFloat(0, sm2.get_avg(), 0.0001); | ||
|
||
sm2.reset(5, 4356, -17.68); | ||
assertEqual(5, sm2.get_window()); | ||
assertEqual(4356, sm2.get_count()); | ||
assertEqualFloat(-17.68, sm2.get_avg(), 0.0001); | ||
} | ||
|
||
|
||
unittest(test_avg) | ||
{ | ||
Smooth sm(5, 0, 0); | ||
|
||
assertEqual(5, sm.get_window()); | ||
assertEqual(0, sm.get_count()); | ||
assertEqualFloat(0, sm.get_avg(), 0.0001); | ||
|
||
sm.add(10); | ||
assertEqual(1, sm.get_count()); | ||
assertEqualFloat(10, sm.get_avg(), 0.0001); | ||
assertEqualFloat(10, sm(), 0.0001); | ||
|
||
sm.add(5); | ||
assertEqual(2, sm.get_count()); | ||
assertEqualFloat(7.5, sm.get_avg(), 0.0001); | ||
assertEqualFloat(7.5, sm(), 0.0001); | ||
} | ||
|
||
|
||
|
||
|
||
unittest_main() | ||
|
||
|
||
// -- END OF FILE -- | ||
|