Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
0 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: | ||
platforms: | ||
- uno | ||
|
||
unittest: | ||
platforms: | ||
- uno |
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 @@ | ||
*.bin |
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,5 @@ | ||
sudo: false | ||
language: ruby | ||
script: | ||
- bundle install | ||
- bundle exec arduino_ci_remote.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,2 @@ | ||
source 'https://rubygems.org' | ||
gem 'arduino_ci', '~> 0.1.7' |
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,19 @@ | ||
PATH | ||
remote: /Users/ikatz/Development/non-wayfair/arduino_ci | ||
specs: | ||
arduino_ci (0.1.7) | ||
os (~> 1.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
os (1.0.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
arduino_ci! | ||
|
||
BUNDLED WITH | ||
1.16.0 |
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,90 @@ | ||
#include <ArduinoUnitTests.h> | ||
#include "../Queue.h" | ||
|
||
int testSize = 4; // number of elements we'll use in our test queues | ||
|
||
unittest(empty) | ||
{ | ||
Queue<int> queue(testSize); | ||
assertEqual(0, queue.count()); // initially empty | ||
assertEqual(0, queue.peek()); // 0 happens to be the default int val | ||
assertEqual(0, queue.pop()); | ||
assertEqual(0, queue.count()); // still empty | ||
} | ||
|
||
unittest(filling_and_emptying) | ||
{ | ||
Queue<int> queue(testSize); | ||
assertEqual(0, queue.count()); // initially empty | ||
for (int i = 1; i <= testSize; ++i) { | ||
queue.push(i * 11); | ||
assertEqual(i, queue.count()); // count increases with pushes | ||
} | ||
for (int i = 1; i <= testSize; ++i) { | ||
assertEqual(i * 11, queue.peek()); // verify FIFO | ||
assertEqual(testSize + 1 - i, queue.count()); // verify count unchanged | ||
assertEqual(i * 11, queue.pop()); // verify FIFO | ||
assertEqual(testSize - i, queue.count()); // verify count unchanged | ||
} | ||
} | ||
|
||
unittest(filling_and_clearing) | ||
{ | ||
Queue<int> queue(testSize); | ||
assertEqual(0, queue.count()); // initially empty | ||
for (int i = 1; i <= testSize; ++i) { | ||
queue.push(i * 11); | ||
assertEqual(i, queue.count()); // count increases with pushes | ||
} | ||
assertEqual(testSize, queue.count()); // now full | ||
queue.clear(); | ||
assertEqual(0, queue.count()); // again empty | ||
} | ||
|
||
unittest(overfilling) | ||
{ | ||
Queue<int> queue(testSize); | ||
assertEqual(0, queue.count()); // initially empty | ||
for (int i = 1; i <= testSize; ++i) { | ||
queue.push(i * 11); | ||
} | ||
assertEqual(testSize, queue.count()); // now full | ||
for (int i = (testSize + 1); i <= testSize * 2; ++i) { | ||
queue.push(i * 11); | ||
assertEqual(testSize, queue.count()); // still full | ||
} | ||
|
||
for (int i = 1; i <= testSize; ++i) { | ||
assertEqual(i * 11, queue.peek()); // verify FIFO | ||
assertEqual(testSize + 1 - i, queue.count()); // verify count unchanged | ||
assertEqual(i * 11, queue.pop()); // verify FIFO | ||
assertEqual(testSize - i, queue.count()); // verify count unchanged | ||
} | ||
} | ||
|
||
unittest(wrapping) | ||
{ | ||
Queue<int> queue(testSize); | ||
queue.push(0); // offset the queue so we have to wrap around | ||
queue.push(1); | ||
queue.pop(); | ||
queue.pop(); | ||
|
||
for (int i = 1; i <= testSize; ++i) { | ||
queue.push(i * 11); | ||
} | ||
assertEqual(testSize, queue.count()); // now full | ||
for (int i = (testSize + 1); i <= testSize * 2; ++i) { | ||
queue.push(i * 11); | ||
assertEqual(testSize, queue.count()); // still full | ||
} | ||
|
||
for (int i = 1; i <= testSize; ++i) { | ||
assertEqual(i * 11, queue.peek()); // verify FIFO | ||
assertEqual(testSize + 1 - i, queue.count()); // verify count unchanged | ||
assertEqual(i * 11, queue.pop()); // verify FIFO | ||
assertEqual(testSize - i, queue.count()); // verify count unchanged | ||
} | ||
} | ||
|
||
unittest_main() |