-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
0a3c310
commit c1ce1c7
Showing
5 changed files
with
85 additions
and
22 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
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,8 @@ | ||
#ifndef __INCLUDE_GUARD__UNIT_TEST_RGB_H__ | ||
#define __INCLUDE_GUARD__UNIT_TEST_RGB_H__ | ||
|
||
#include <stdint.h> | ||
|
||
uint8_t TEST_EXEC__RGB_convert_hex_to_rgb(); | ||
|
||
#endif // __INCLUDE_GUARD__UNIT_TEST_PWM_H__ |
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,44 @@ | ||
#include "unit_tests/unit_test_helpers.h" | ||
#include "unit_tests/unit_test_rgb.h" | ||
#include "rgb.h" | ||
|
||
#include <string.h> | ||
|
||
uint8_t TEST_EXEC__RGB_convert_hex_to_rgb() | ||
{ | ||
char hex_color_code[10] = "\0"; | ||
LED_RGB_t rgb_result; | ||
uint8_t status; | ||
|
||
// Fail Criteria | ||
|
||
// Empty string | ||
status = RGB_convert_hex_to_rgb(hex_color_code, &rgb_result); | ||
TEST_ASSERT_TRUE(status == 1); | ||
|
||
// Missing "#" | ||
strcpy(hex_color_code, "FFAABB"); | ||
status = RGB_convert_hex_to_rgb(hex_color_code, &rgb_result); | ||
TEST_ASSERT_TRUE(status == 2); | ||
|
||
// Invalid Length - Missing hex value | ||
strcpy(hex_color_code, "#FFAAB"); | ||
status = RGB_convert_hex_to_rgb(hex_color_code, &rgb_result); | ||
TEST_ASSERT_TRUE(status == 3); | ||
|
||
// Invalid Hex Value | ||
strcpy(hex_color_code, "#K2AABB"); | ||
status = RGB_convert_hex_to_rgb(hex_color_code, &rgb_result); | ||
TEST_ASSERT_TRUE(status == 4); | ||
|
||
// Pass Criteria | ||
strcpy(hex_color_code, "#D2AABB"); | ||
status = RGB_convert_hex_to_rgb(hex_color_code, &rgb_result); | ||
TEST_ASSERT_TRUE(status == 0); | ||
|
||
TEST_ASSERT_TRUE(rgb_result.RGB_red == 0xD2); | ||
TEST_ASSERT_TRUE(rgb_result.RGB_green == 0xAA); | ||
TEST_ASSERT_TRUE(rgb_result.RGB_blue == 0xBB); | ||
|
||
return 0; | ||
} |