-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identifying the device type based on the device type string and choosing the correct configuration.
- Loading branch information
1 parent
70c2225
commit 8224e28
Showing
11 changed files
with
259 additions
and
46 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
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
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,85 @@ | ||
// File under test platform.c | ||
#include "platform.h" | ||
|
||
#include "unity.h" | ||
#include <string.h> | ||
|
||
|
||
static char actualDeviceType[100]; | ||
|
||
void setUp(void) { | ||
strcpy(actualDeviceType, "abcdefghijklmn"); | ||
} | ||
|
||
void tearDown(void) { | ||
// Empty | ||
} | ||
|
||
void testThatDeviceTypeStringIsReturned() { | ||
// Fixture | ||
const char* deviceTypeString = "0;CF20"; | ||
|
||
// Test | ||
int actual = platformParseDeviceTypeString(deviceTypeString, actualDeviceType); | ||
|
||
// Assert | ||
TEST_ASSERT_EQUAL_STRING("CF20", actualDeviceType); | ||
TEST_ASSERT_EQUAL(0, actual); | ||
} | ||
|
||
void testThatDeviceTypeStringIsReturnedWithTrailingSemiColonAndKeyValues() { | ||
// Fixture | ||
const char* deviceTypeString = "0;CF21;R=C"; | ||
|
||
// Test | ||
int actual = platformParseDeviceTypeString(deviceTypeString, actualDeviceType); | ||
|
||
// Assert | ||
TEST_ASSERT_EQUAL_STRING("CF21", actualDeviceType); | ||
TEST_ASSERT_EQUAL(0, actual); | ||
} | ||
|
||
void testThatDeviceTypeStringIsReturnedWhenTypeIdentifierIsShorterThan4Chars() { | ||
// Fixture | ||
const char* deviceTypeString = "0;AB;R=C"; | ||
|
||
// Test | ||
int actual = platformParseDeviceTypeString(deviceTypeString, actualDeviceType); | ||
|
||
// Assert | ||
TEST_ASSERT_EQUAL_STRING("AB", actualDeviceType); | ||
TEST_ASSERT_EQUAL(0, actual); | ||
} | ||
|
||
void testThatDeviceTypeIsNotReturnedWhenTypeIdentifierIsTooLong() { | ||
// Fixture | ||
const char* deviceTypeString = "0;CF21XXX;R=C"; | ||
|
||
// Test | ||
int actual = platformParseDeviceTypeString(deviceTypeString, actualDeviceType); | ||
|
||
// Assert | ||
TEST_ASSERT_NOT_EQUAL(0, actual); | ||
} | ||
|
||
void testThatDeviceTypeIsNotReturnedIfVersionIfNot0() { | ||
// Fixture | ||
const char* deviceTypeString = "1;CF21"; | ||
|
||
// Test | ||
int actual = platformParseDeviceTypeString(deviceTypeString, actualDeviceType); | ||
|
||
// Assert | ||
TEST_ASSERT_NOT_EQUAL(0, actual); | ||
} | ||
|
||
void testThatDeviceTypeIsNotReturnedIfSecondCharIsNotSemicolon() { | ||
// Fixture | ||
const char* deviceTypeString = "0+CF21"; | ||
|
||
// Test | ||
int actual = platformParseDeviceTypeString(deviceTypeString, actualDeviceType); | ||
|
||
// Assert | ||
TEST_ASSERT_NOT_EQUAL(0, actual); | ||
} |
Oops, something went wrong.