Bugfix/indtext-find-string-among-similar (#1173)
* Enhanced string comparison functions and update indtext API usage - Added library specific case-sensitive and case-insensitive string comparison functions that mimic strcmp. - Updated indtext_by_string and indtext_by_istring to use the new comparison functions. - Improved documentation for return values in indtext functions. - Expanded test data in main.c for comprehensive testing when beginning of string matches another string.
This commit is contained in:
@@ -16,9 +16,12 @@
|
||||
/**
|
||||
* @brief Test
|
||||
*/
|
||||
static INDTEXT_DATA data_list[] = { { 1, "Joshua" }, { 2, "Mary" },
|
||||
{ 3, "Anna" }, { 4, "Christopher" },
|
||||
{ 5, "Patricia" }, { 0, NULL } };
|
||||
static INDTEXT_DATA data_list[] = {
|
||||
{ 1, "Joshua" }, { 2, "Mary" },
|
||||
{ 3, "Anna" }, { 4, "Christopher" },
|
||||
{ 5, "Patricia" }, { 6, "JoshuaMaryAnnaChristopherPatricia" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(indtext_tests, testIndexText)
|
||||
@@ -26,11 +29,11 @@ ZTEST(indtext_tests, testIndexText)
|
||||
static void testIndexText(void)
|
||||
#endif
|
||||
{
|
||||
unsigned i; /*counter */
|
||||
uint32_t i; /*counter */
|
||||
const char *pString;
|
||||
unsigned index;
|
||||
uint32_t index;
|
||||
bool valid;
|
||||
unsigned count = 0;
|
||||
uint32_t count = 0;
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
pString = indtext_by_index(data_list, i);
|
||||
@@ -38,7 +41,7 @@ static void testIndexText(void)
|
||||
count++;
|
||||
valid = indtext_by_string(data_list, pString, &index);
|
||||
zassert_true(valid, NULL);
|
||||
zassert_equal(index, i, NULL);
|
||||
zassert_equal(index, i, "index=%u i=%u", index, i);
|
||||
zassert_equal(
|
||||
index, indtext_by_string_default(data_list, pString, index),
|
||||
NULL);
|
||||
|
||||
Reference in New Issue
Block a user