This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from Sensirion/add-voc-algorithm-tests
Add VOC algorithm tests
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
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
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,32 @@ | ||
#include "CppUTest/CommandLineTestRunner.h" | ||
#include "sensirion_voc_algorithm.h" | ||
|
||
TEST_GROUP (Sgp40VocIndexAlgorithmTest) {}; | ||
|
||
TEST (Sgp40VocIndexAlgorithmTest, returns_zero_during_blackout) { | ||
VocAlgorithmParams params; | ||
VocAlgorithm_init(¶ms); | ||
for (int i = 0; i < VocAlgorithm_INITIAL_BLACKOUT; ++i) { | ||
int32_t voc_index; | ||
VocAlgorithm_process(¶ms, 0, &voc_index); | ||
CHECK_EQUAL_TEXT(0, voc_index, | ||
"VOC index should be 0 during initial blackout"); | ||
} | ||
} | ||
|
||
TEST (Sgp40VocIndexAlgorithmTest, returns_average_after_blackout) { | ||
VocAlgorithmParams params; | ||
VocAlgorithm_init(¶ms); | ||
int32_t voc_index; | ||
for (int i = 0; i < VocAlgorithm_INITIAL_BLACKOUT + 2; ++i) { | ||
VocAlgorithm_process(¶ms, 0, &voc_index); | ||
} | ||
|
||
CHECK_EQUAL_TEXT( | ||
VocAlgorithm_VOC_INDEX_OFFSET_DEFAULT, voc_index, | ||
"VOC index should be the offset default after the the blackout period"); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
return CommandLineTestRunner::RunAllTests(argc, argv); | ||
} |