Skip to content

Commit

Permalink
Merge pull request #61 from bxparks/develop
Browse files Browse the repository at this point in the history
merge 1.4 into master
  • Loading branch information
bxparks authored Oct 29, 2020
2 parents f47bd08 + 9e39103 commit e0aa8df
Show file tree
Hide file tree
Showing 169 changed files with 4,932 additions and 2,868 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/aunit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: AUnit Tests

on: [push]

jobs:
build:

runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

- name: Setup
run: |
cd ..
git clone https://github.com/bxparks/UnixHostDuino
- name: Verify examples
run: |
make -C examples
- name: Verify tests
run: |
make -C tests
make -C tests runtests
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

* Unreleased
* 1.4 (2020-10-28)
* Support comparison of 2 arbitrary pointers using
`assertEqual(const void*, const void*)` and
`assertNotEqual(const void*, const void*)`. Fixes
[Issue #34](https://github.com/bxparks/AUnit/issues/34).
* Add GitHub Workflow Actions continuous integration for examples
and tests under `examples/` and `tests/`.
* 1.3.3 (2020-09-15)
* Increase maximum allowed `setTimeout()` from 255 seconds to 65535 seconds
(18.2 hours). (See [Issue
Expand Down
110 changes: 88 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ and Teensy platforms. Another companion project
[AUniter](https://github.com/bxparks/AUniter) project provides command line
tools to verify, upload and validate the unit tests to the microcontroller,
instead of having to go through the Arduino IDE. Both the AUniter and
UnixHostDuino tools can be used in a continuous integration system like Jenkins.
UnixHostDuino tools can be used in a continuous integration system like Jenkins,
or with [GitHub Actions](https://github.com/features/actions).

**Version**: 1.3.3 (2020-09-15)
**Version**: 1.4 (2020-10-28)

**Changelog**: [CHANGELOG.md](CHANGELOG.md).
**Changelog**: [CHANGELOG.md](CHANGELOG.md)

[![AUniter Jenkins Badge](https://us-central1-xparks2018.cloudfunctions.net/badge?project=AUnit)](https://github.com/bxparks/AUniter)
![AUnit Tests](https://github.com/bxparks/AUnit/workflows/AUnit%20Tests/badge.svg)

## Summary

Expand Down Expand Up @@ -202,7 +203,7 @@ currently have 3 Arduino project using AUnit extensively
backwards compatible. They do not use the new features of AUnit.
* [AceRoutine](https://github.com/bxparks/AceRoutine)
* Demonstrates the full power of AUnit better.
* [AceSegment](https://github.com/bxparks/AceSegment)
* [AceTime](https://github.com/bxparks/AceTime)
* Demonstrates the full power of AUnit better.

## Usage
Expand Down Expand Up @@ -423,9 +424,9 @@ are available. These are essentially identical to ArduinoUnit:
#### Supported Parameter Types
The 6 core assert macros (assertEqual, assertNotEqual, assertLess, assertMore,
assertLessOrEqual, assertMoreOrEqual) support the following 18
combinations for their parameter types:
The 6 core assert macros (`assertEqual()`, `assertNotEqual()`, `assertLess()`,
`assertMore()`, `assertLessOrEqual()`, `assertMoreOrEqual()`) support the
following 18 combinations for their parameter types:
* `(bool, bool)`
* `(char, char)`
Expand All @@ -446,7 +447,12 @@ combinations for their parameter types:
* `(const __FlashStringHelper*, const String&)`
* `(const __FlashStringHelper*, const __FlashStringHelper*)`
As you can see, all 9 combinations of the 3 string types (`char*`, `String`, and
The `assertEqual()` and `assertNotEqual()` support arbitary pointer types
through implicit casts to `const void*`:
* `(const void*, const void*)` (since v1.4)
All 9 combinations of the 3 string types (`char*`, `String`, and
`__FlashStringHelper*`) are supported.
These macros perform deep comparisons for string types instead of just comparing
Expand All @@ -471,6 +477,7 @@ For example, the following type conversions will occur:
* `char*` -> `const char*`.
* `char[N]` -> `const char*`
* `float` -> `double`
* pointer types -> `const void*`
Note that `char`, `signed char`, and `unsigned char` are 3 distinct types in
C++, so a `(char, char)` will match exactly to one of the `assertXxx()`
Expand Down Expand Up @@ -536,6 +543,59 @@ difficult to remember (and sometimes difficult to understand). The best way to
avoid these compiler errors is to make sure that the assertion parameter types
are identical, potentially using explicit casting.
### Pointer Comparisons
Version 1.4 adds pointer comparison to `assertEqual()` and `assertNotEqual()`.
Arbritary pointers are implicitly cast to a `const void*` and compared to
each other. If the assertion fails, the pointer is converted to an integer type,
and the hexadecimal value of the pointer is printed. For example,
```C++
test(voidPointer) {
const int aa[] = {1, 2};
const long bb[] = {1, 2};
assertEqual(aa, bb);
}
```

This test will fail with the following error message:
```
Assertion failed: (aa=0x3FFFFF38) == (bb=0x3FFFFF30), file AUnitTest.ino, line 338.
Test voidPointer failed.
```

Comparison against the `nullptr` will work:

```C++
test(nullPointer) {
const int aa[] = {1, 2};
assertEqual(aa, nullptr);
}
```
prints the following:
```
Assertion failed: (aa=0x3FFFFF58) == (nullptr=0x0), file AUnitTest.ino, line 348.
Test nullPointer failed.
```
Comparing a string type (i.e. `const char*`, or `const __FlashStringHelper*`)
to a `nullptr` will cause an error due to ambiguous matches on overloaded
functions. The solution is to explicitly cast the `nullptr` to the corresponding
string type:
```C+++
test(stringPointer) {
const char aa[] = "abc";
// assertEqual(aa, nullptr); // Causes errors
assertEqual(aa, (const char*) nullptr); // Works.
}
```

### Case Insensitive String Comparisons

Two macros provide case-insensitive string comparisons (analogous to
Expand Down Expand Up @@ -1284,9 +1344,24 @@ some quick examples copied from the `AUniter/README.md` file:

### Continuous Integration

The AUniter tools have been integrated into the [Jenkins](https://jenkins.io)
continuous integration service. See details in
[Continuous Integration with Jenkins](https://github.com/bxparks/AUniter/tree/develop/jenkins).
There are at least 2 ways to incorporate AUnit into a continuous integration
system:

* You can use [Jenkins](https://jenkins.io) on a local machine and use the
AUniter tools (https://github.com/bxparks/AUniter) as explained in
[Continuous Integration with
Jenkins](https://github.com/bxparks/AUniter/tree/develop/jenkins).
* Not Recommended anymore because it is too difficult to maintain
a local Jenkins service. And using the Arduino IDE as the command line
compiler is too slow.
* You can compile and run the AUnit tests using the GNU `make` command under
Linux or MacOS using the UnixHostDuino framework
(https://github.com/bxparks/UnixHostDuino). The `make` commands can be readily
integrated into a continuous integration service like [GitHub
Actions](https://github.com/features/actions).
* **Recommended**
* See the `.github/workflows/aunit_tests.yml` file in this repository
for an example.

### UnixHostDuino

Expand All @@ -1295,7 +1370,7 @@ machines using the [UnixHostDuino](https://github.com/bxparks/UnixHostDuino)
library because most unit tests depend on just the `Serial` port (which
UnixHostDuino binds to `stdout` and `stdin`).

The [unit tests for AUnit itself](tests) have all been upgraded to run
The unit tests for AUnit itself uner `./tests` have all been upgraded to run
under UnixHostDuino. Here are a few tips when writing unit tests
to run under UnixHostDuino:

Expand Down Expand Up @@ -1407,15 +1482,6 @@ failure) slightly easier to implement. For the most part, the end-users can
ignore the existence of the `Assertion` and `MetaAssertion` classes and think of
this as a simple 2-level inheritance tree.

### Comparing Pointers

Currently the `assertEqual()` and other `assertXxx()` methods do not support
comparing arbitrary pointers (i.e. `(void*)`. This could change if
[Issue #34](https://github.com/bxparks/AUnit/issues/34) is
resolved. In the meantime, a workaround is to cast the pointer to a `uintptr_t`
integer type from `#include <stdint.h>` and then calling `assertEqual()` on the
integer type.

### Testing Private Helper Methods

There is a school of thought which says that unit tests should test only the
Expand Down
2 changes: 1 addition & 1 deletion docs/doxygen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "AUnit"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.3.3
PROJECT_NUMBER = 1.4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
6 changes: 3 additions & 3 deletions docs/html/AUnitVerbose_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down Expand Up @@ -119,10 +119,10 @@
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a87cbb10969eff63f8ae66afc4e9457eb"><td class="memItemLeft" align="right" valign="top"><a id="a87cbb10969eff63f8ae66afc4e9457eb"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION</b>&#160;&#160;&#160;10303</td></tr>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION</b>&#160;&#160;&#160;10400</td></tr>
<tr class="separator:a87cbb10969eff63f8ae66afc4e9457eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a70ade1487f0d9d7172f24897cd0f2dd5"><td class="memItemLeft" align="right" valign="top"><a id="a70ade1487f0d9d7172f24897cd0f2dd5"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION_STRING</b>&#160;&#160;&#160;&quot;1.3.3&quot;</td></tr>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION_STRING</b>&#160;&#160;&#160;&quot;1.4&quot;</td></tr>
<tr class="separator:a70ade1487f0d9d7172f24897cd0f2dd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
Expand Down
6 changes: 3 additions & 3 deletions docs/html/AUnitVerbose_8h_source.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down Expand Up @@ -113,8 +113,8 @@
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="TestMacros_8h.html">aunit/TestMacros.h</a>&quot;</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; </div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="comment">// Version format: xxyyzz == &quot;xx.yy.zz&quot;</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;<span class="preprocessor">#define AUNIT_VERSION 10303</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;<span class="preprocessor">#define AUNIT_VERSION_STRING &quot;1.3.3&quot;</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;<span class="preprocessor">#define AUNIT_VERSION 10400</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;<span class="preprocessor">#define AUNIT_VERSION_STRING &quot;1.4&quot;</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; </div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
Expand Down
6 changes: 3 additions & 3 deletions docs/html/AUnit_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down Expand Up @@ -119,10 +119,10 @@
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a87cbb10969eff63f8ae66afc4e9457eb"><td class="memItemLeft" align="right" valign="top"><a id="a87cbb10969eff63f8ae66afc4e9457eb"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION</b>&#160;&#160;&#160;10303</td></tr>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION</b>&#160;&#160;&#160;10400</td></tr>
<tr class="separator:a87cbb10969eff63f8ae66afc4e9457eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a70ade1487f0d9d7172f24897cd0f2dd5"><td class="memItemLeft" align="right" valign="top"><a id="a70ade1487f0d9d7172f24897cd0f2dd5"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION_STRING</b>&#160;&#160;&#160;&quot;1.3.3&quot;</td></tr>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION_STRING</b>&#160;&#160;&#160;&quot;1.4&quot;</td></tr>
<tr class="separator:a70ade1487f0d9d7172f24897cd0f2dd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
Expand Down
6 changes: 3 additions & 3 deletions docs/html/AUnit_8h_source.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down Expand Up @@ -113,8 +113,8 @@
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="TestMacros_8h.html">aunit/TestMacros.h</a>&quot;</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160;<span class="comment">// Version format: xxyyzz == &quot;xx.yy.zz&quot;</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;<span class="preprocessor">#define AUNIT_VERSION 10303</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;<span class="preprocessor">#define AUNIT_VERSION_STRING &quot;1.3.3&quot;</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;<span class="preprocessor">#define AUNIT_VERSION 10400</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;<span class="preprocessor">#define AUNIT_VERSION_STRING &quot;1.4&quot;</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; </div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
Expand Down
2 changes: 1 addition & 1 deletion docs/html/AssertMacros_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/AssertMacros_8h_source.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/AssertVerboseMacros_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/AssertVerboseMacros_8h_source.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">AUnit
&#160;<span id="projectnumber">1.3.3</span>
&#160;<span id="projectnumber">1.4</span>
</div>
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
</td>
Expand Down
Loading

0 comments on commit e0aa8df

Please sign in to comment.