Skip to content

Commit 8e922de

Browse files
authored
Merge pull request #29 from bxparks/develop
0.5.3 - support case-insensitive string comparisons
2 parents 3ede6d1 + e624759 commit 8e922de

File tree

95 files changed

+1474
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1474
-430
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
* 0.5.3 (2018-05-16)
4+
* Add assertStringCaseEqual() and assertStringCaseNotEqual(),
5+
case-insensitive versions of assertEqual() and assertNotEqual() for
6+
strings. Issue #28.
7+
* Support nullptr strings in various assertXxx() macros.
38
* 0.5.2 (2018-05-08)
49
* Rename failNow(), passNow(), skipNow(), expireNow() macros to
510
failTestNow(), passTestNow(), skipTestNow(), expireTestNow() to reduce

README.md

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
A unit testing framework for Arduino platforms inspired by ArduinoUnit and
44
Google Test.
55

6-
Version: 0.5.2 (2018-05-08)
6+
Version: 0.5.3 (2018-05-16)
77

88
## Summary
99

@@ -15,7 +15,7 @@ Just like ArduinoUnit, the unit tests run directly on the microcontrollers
1515
themselves, not on emulators or simulators. The test results are printed on the
1616
`Serial` object by default, but can be redirected to another `Print` object.
1717

18-
AUnit was created to solve 3 problems with ArduinoUnit:
18+
AUnit was created to solve 3 problems with ArduinoUnit 2.2:
1919
* ArduinoUnit consumes too much flash memory on an AVR platform (e.g.
2020
Arduino UNO, Nano) as explained in
2121
[ArduinoUnit#70](https://github.com/mmurdoch/arduinounit/issues/70).
@@ -27,7 +27,7 @@ AUnit was created to solve 3 problems with ArduinoUnit:
2727
equivalent to the `TEST_F()` macro in Google Test.
2828

2929
In contrast:
30-
* AUnit consumes as much as 65% *less* flash memory than ArduinoUnit on the
30+
* AUnit consumes as much as 65% *less* flash memory than ArduinoUnit 2.2 on the
3131
AVR platform. On Teensy-ARM, the savings can be as much as 30%.
3232
* AUnit has been tested on AVR, Teensy-ARM and ESP8266.
3333
* AUnit implements the `testF()` and `testingF()` macros to use fixtures.
@@ -39,8 +39,7 @@ convert to AUnit:
3939
* `#include <ArduinoUnit.h>` -> `#include <AUnit.h>`
4040
* `Test::run()` -> `aunit::TestRunner::run()`
4141

42-
Essentially all of the various macros are compatible between ArduinoUnit and
43-
AUnit:
42+
Most of the core macros are compatible between ArduinoUnit and AUnit:
4443
* `test()`
4544
* `testing()`
4645
* `assertXxx()`
@@ -50,7 +49,7 @@ AUnit:
5049
* `externTest()`
5150
* `externTesting()`
5251

53-
AUnit supports exclude and include filters:
52+
AUnit also supports exclude and include filters:
5453
* `TestRunner::exclude()`
5554
* `TestRunner::include()`
5655

@@ -61,15 +60,15 @@ the `Verbosity` flags on per test basis:
6160

6261
### Missing Features
6362

64-
Here are the features which have not been ported over from ArduinoUnit:
63+
Here are the features which have not been ported over from ArduinoUnit 2.2:
6564

6665
* ArduinoUnit supports multiple `*` wildcards in its `exclude()` and `include()`
6766
methods. AUnit supports only a single `*` wildcard and it must occur at the
6867
end if present.
6968

7069
### Added Features
7170

72-
Here are the features in AUnit which are not available in ArduinoUnit:
71+
Here are the features in AUnit which are not available in ArduinoUnit 2.2:
7372

7473
* Configurable timeout parameter to prevent `testing()` test cases from
7574
running forever:
@@ -79,31 +78,34 @@ Here are the features in AUnit which are not available in ArduinoUnit:
7978
* `assertTestNotExpire()`
8079
* `checkTestExpire()`
8180
* `checkTestNotExpire()`
81+
* Case-insensitive string comparisons:
82+
* `assertStringCaseEqual()`
83+
* `assertStringCaseNotEqual()`
8284
* Test fixtures using the "F" variations of existing macros:
8385
* `testF()`
8486
* `testingF()`
8587
* `assertTestXxxF()`
8688
* `checkTestXxxF()`
8789
* `externTestF()`
8890
* `externTestingF()`
89-
* Status setters
91+
* Unconditional termination:
9092
* `passTestNow()`
9193
* `failTestNow()`
9294
* `skipTestNow()`
9395
* `expireTestNow()`
94-
* `teardown()` method, mirroring the `setup()`
96+
* `teardown()` method which mirrors the `setup()` method:
9597
* `teardown()`
98+
* Test filters support 2-arguments, matching `testF()` and `testingF()`:
99+
* `TestRunner::include(testClass, name)`
100+
* `TestRunner::exclude(testClass, name)`
101+
* Terse and verbose modes:
102+
* `#include <AUnit.h>` - terse messages uses less flash memory
103+
* `#include <AUnitVerbose.h>` - verbose messages uses more flash memory
96104
* Tested on the following Arduino platforms:
97105
* AVR (8-bit)
98106
* Teensy ARM (32-bit)
99107
* ESP8266 (32-bit)
100108
* ESP32 (32-bit)
101-
* Test filters support the 2 arguments versions:
102-
* `TestRunner::include(testClass, name)` - matching `testF()`
103-
* `TestRunner::exclude(testClass, name)` - matching `testingF()`
104-
* Terse and verbose modes:
105-
* `#include <AUnit.h>` - terse messages uses less flash memory
106-
* `#include <AUnitVerbose.h>` - verbose messages uses more flash
107109

108110
Every feature of AUnit is unit tested using AUnit itself.
109111

@@ -135,9 +137,14 @@ The source files are organized as follows:
135137
* `src/AUnit.h` - main header file
136138
* `src/AUnitVerbose.h` - verbose version of main header file
137139
* `src/aunit/` - all implementation files
138-
* `tests/` - unit tests written using [AUnit](https://github.com/bxparks/AUnit)
140+
* `tests/` - unit tests written using AUnit itself
139141
* `examples/` - example sketches
140142

143+
### Docs
144+
145+
The [docs/](docs/) directory contains the
146+
[Doxygen docs published on GitHub Pages](https://bxparks.github.io/AUnit/html).
147+
141148
### Examples
142149

143150
The `examples/` directory has a number of examples:
@@ -159,18 +166,15 @@ In the `tests/` directory:
159166
called properly by the finite state machine
160167

161168
Perhaps the best way to see AUnit in action through real life examples. I
162-
currently have 2 Arduino project using AUnit extensively:
169+
currently have 2 Arduino project using AUnit extensively
170+
(look under the `tests/` directory in each project).
163171

164172
* [AceButton](https://github.com/bxparks/AceButton)
173+
* Originally created using ArduinoUnit 2.2, and I have kept those tests
174+
backwards compatible. They do not use the new features of AUnit.
165175
* [AceSegment](https://github.com/bxparks/AceSegment)
176+
* Demonstrates the full power of AUnit better.
166177

167-
Look under the `tests` directory in each project.
168-
169-
The tests for AceButton were originally created using ArduinoUnit 2.2, and I
170-
have kept those tests backwards compatible. They do not use the new features of
171-
AUnit.
172-
173-
The tests for AceSegment demonstrate the full power of AUnit better.
174178

175179
## Usage
176180

@@ -347,8 +351,18 @@ are available. These are essentially identical to ArduinoUnit:
347351
* `assertLessOrEqual(a, b)`
348352
* `assertMoreOrEqual(a, b)`
349353

350-
The following overloaded types for the various `assertXxx()` macros are
351-
defined:
354+
Two additional macros provide case-insensitive string comparisons
355+
(analogous to `ASSERT_STRCASEEQ()` and `ASSERT_STRCASENE()` in
356+
Google Test):
357+
358+
* `assertStringCaseEqual()`
359+
* `assertStringCaseNotEqual()`
360+
361+
#### Supported Parameter Types
362+
363+
The 6 core assert macros (assertEqual, assertNotEqual, assertLess, assertMore,
364+
assertLessOrEqual, assertMoreOrEqual) support the following 16
365+
combinations for their parameter types:
352366

353367
* `(bool, bool)`
354368
* `(char, char)`
@@ -370,8 +384,20 @@ defined:
370384
As you can see, all 9 combinations of the 3 string types (`char*`, `String`, and
371385
`__FlashStringHelper*`) are supported.
372386

387+
These macros perform deep comparisons for string types instead of just comparing
388+
their pointer values. This is different than the `ASSERT_EQ()` and `ASSERT_NE()`
389+
macros in Google Test which perform only pointer comparisons. In other words,
390+
`assertEqual()` with string types is equivalent to `ASSERT_STREQ()` in Google
391+
Test.
392+
393+
Also for string types, these macros support `nullptr` (unlike the underlying
394+
`strcmp()` function from the C-library). The `nullptr` string is defined to be
395+
"smaller" than any non-null string, including the empty string. Two `nullptr`
396+
strings are considered to be equal however.
397+
373398
Additionally, the usual C++ implicit type conversion and function overloading
374-
matching algorithms apply. For example, the conversions will occur:
399+
matching algorithms apply to support additional argument types.
400+
For example, the following type conversions will occur:
375401

376402
* `signed char` -> `int`
377403
* `unsigned char` -> `int`
@@ -390,9 +416,10 @@ _The names of the macros are identical. However, the
390416
type inference logic of two `(a, b)` arguments in the `assertXxx(a, b)` is
391417
slightly different. ArduinoUnit allows the two parameters to be slightly
392418
different types, at the expense of a compiler warning. In AUnit, the
393-
warning becomes a compiler error. See below._
419+
warning becomes a compiler error. See the "Parameters Must Match Types" section
420+
below._
394421

395-
#### Assertion Parameters Must Match Types
422+
#### Parameters Must Match Types
396423

397424
In ArduinoUnit, the `assertXxx()` macros could be slightly different types, for
398425
example:
@@ -401,7 +428,8 @@ unsigned int uintValue = 5;
401428
assertEqual(5, uintValue);
402429
```
403430

404-
If the compiler warnings are enabled, a warning from the compiler is printed:
431+
If the compiler warnings are enabled in the Preferences box of the
432+
IDE, a warning from the compiler is printed:
405433

406434
```
407435
../ArduinoUnit/src/ArduinoUnitUtility/Compare.h:17:28: warning:
@@ -704,11 +732,11 @@ they do *not* terminate the test immediately.
704732

705733
In most cases, the `failTestNow()`, `skipTestNow()` and `expireTestNow()` macros
706734
are more useful than the equivalent methods in the `Test` class. However, in a
707-
testing() loop test, the pass() method is probably better than the passTestNow()
708-
macro because we usually don't want to see an error message for a test that
709-
passes.
735+
`testing()` loop test, the `pass()` method is probably better than the
736+
`passTestNow()` macro because we usually don't want to see an error message
737+
from a passing test.
710738

711-
***ArduinoUnit Compatibility***: _
739+
***ArduinoUnit Compatibility***:
712740
_The method(s) marked by [&ast;] are only available in AUnit._
713741

714742
### Overridable Methods

docs/doxygen.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "AUnit"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 0.5.2
41+
PROJECT_NUMBER = 0.5.3
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

docs/html/AUnitVerbose_8h.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tr style="height: 56px;">
2323
<td id="projectalign" style="padding-left: 0.5em;">
2424
<div id="projectname">AUnit
25-
&#160;<span id="projectnumber">0.5.2</span>
25+
&#160;<span id="projectnumber">0.5.3</span>
2626
</div>
2727
<div id="projectbrief">Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.</div>
2828
</td>
@@ -112,7 +112,7 @@
112112
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
113113
Macros</h2></td></tr>
114114
<tr class="memitem:a87cbb10969eff63f8ae66afc4e9457eb"><td class="memItemLeft" align="right" valign="top"><a id="a87cbb10969eff63f8ae66afc4e9457eb"></a>
115-
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION</b>&#160;&#160;&#160;000502</td></tr>
115+
#define&#160;</td><td class="memItemRight" valign="bottom"><b>AUNIT_VERSION</b>&#160;&#160;&#160;000503</td></tr>
116116
<tr class="separator:a87cbb10969eff63f8ae66afc4e9457eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
117117
</table>
118118
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>

0 commit comments

Comments
 (0)