Skip to content

Commit

Permalink
Arduino ci (#1)
Browse files Browse the repository at this point in the history
* initial arduino-ci
* add unit test
  • Loading branch information
RobTillaart authored Dec 18, 2020
1 parent a6b380b commit 205748e
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .arduino-ci.yml
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
13 changes: 13 additions & 0 deletions .github/workflows/arduino_test_runner.yml
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
16 changes: 9 additions & 7 deletions DEVNULL.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
//
// FILE: DEVNULL.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// VERSION: 0.1.1
// PURPOSE: Arduino library for a /dev/null stream - usefull for testing
// URL: https://github.com/RobTillaart/DEVNULL
//
// HISTORY:
// 0.1.0 2020-06-23 initial version
// 0.1.0 2020-06-23 initial version
// 0.1.1 2020-12-18 add arduino-ci +

#include "Arduino.h"

Expand All @@ -16,13 +17,14 @@ class DEVNULL : public Stream
public:
DEVNULL() {};

int available() { return 0; };
int peek() { return EOF; };
int read() { return EOF; };
size_t write(const uint8_t data) { bottomLessPit = data; return 0; };
int available() { return 0; };
int peek() { return EOF; };
int read() { return EOF; };
void flush() { return; }; // placeholder to keep CI happy
size_t write(const uint8_t data) { _bottomLessPit = data; return 1; };

private:
uint8_t bottomLessPit;
uint8_t _bottomLessPit;
};

// -- END OF FILE --
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

[![Arduino CI](https://github.com/RobTillaart/DEVNULL/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DEVNULL/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DEVNULL.svg?maxAge=3600)](https://github.com/RobTillaart/DEVNULL/releases)

# DEVNULL

Arduino library for a /dev/null stream
Expand All @@ -20,6 +25,7 @@ Performance can be increased by implementing all methods of the print interface
with only a return 0;

## Operation

use with care

See example
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/DEVNULL.git"
},
"version":"0.1.0",
"version":"0.1.1",
"frameworks": "arduino",
"platforms": "*"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=DEVNULL
version=0.1.0
version=0.1.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for a /dev/null stream
Expand Down
56 changes: 56 additions & 0 deletions test/unit_test_001.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
// DATE: 2020-12-18
// PURPOSE: unit tests for the DEVNULL library
// https://github.com/RobTillaart/
// 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 "DEVNULL.h"


unittest_setup()
{
}

unittest_teardown()
{
}


unittest(test_all)
{
DEVNULL dn;

assertEqual(0, dn.available());
assertEqual(EOF, dn.peek());
assertEqual(EOF, dn.read());
assertEqual(1, dn.write('a'));
assertEqual(11, dn.print("hello world"));
}

unittest_main()

// --------

0 comments on commit 205748e

Please sign in to comment.