-
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.
Clean up the project structure (#23)
* Move source files to `src` directory * Create a lib directory, move a header into it * Set up a test directory, with a sample test * Add test action * Fix check command; update badge list in README
- Loading branch information
1 parent
9819622
commit 6ac1227
Showing
25 changed files
with
77 additions
and
7 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,31 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
~/.platformio/.cache | ||
key: ${{ runner.os }}-pio | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install PlatformIO Core | ||
run: pip install --upgrade platformio | ||
|
||
- name: Run tests | ||
run: | | ||
pio test -e native |
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,5 @@ | ||
#pragma once | ||
|
||
// TODO: delete this after some other tests are set up | ||
// NOLINTNEXTLINE(misc-no-recursion) | ||
inline int factorial(int number) { return number <= 1 ? 1 : factorial(number - 1) * number; } |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#define DOCTEST_CONFIG_IMPLEMENT // REQUIRED: Enable custom main() | ||
#include <doctest.h> | ||
|
||
#include <factorial.hpp> | ||
|
||
TEST_CASE("testing the factorial function") { | ||
CHECK(factorial(0) == 1); | ||
CHECK(factorial(1) == 1); | ||
CHECK(factorial(2) == 2); | ||
CHECK(factorial(3) == 6); | ||
CHECK(factorial(10) == 3628800); | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
doctest::Context context; | ||
|
||
// BEGIN:: PLATFORMIO REQUIRED OPTIONS | ||
context.setOption("success", true); // Report successful tests | ||
context.setOption("no-exitcode", true); // Do not return non-zero code on failed test case | ||
// END:: PLATFORMIO REQUIRED OPTIONS | ||
|
||
// YOUR CUSTOM DOCTEST OPTIONS | ||
|
||
context.applyCommandLine(argc, argv); | ||
return context.run(); | ||
} |