1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

unittests/clif: add attribute test cases

- missing value in attribute with separator should fail
- single-quoted value in attribute should fail
- empty value in quoted attribute should fail
This commit is contained in:
Leandro Lanzieri 2021-03-04 15:02:51 +01:00
parent dfb2c21570
commit 9e2e99fafb
No known key found for this signature in database
GPG Key ID: F4E9A721761C7593

View File

@ -282,7 +282,25 @@ static void test_clif_get_attr_missing_value(void)
/* Used to result in a spatial memory safety violation.
* See: https://github.com/RIOT-OS/RIOT/pull/15945 */
int r = clif_get_attr(input, strlen(input), &attr);
TEST_ASSERT_EQUAL_INT(strlen(input), r);
TEST_ASSERT_EQUAL_INT(CLIF_NOT_FOUND, r);
}
static void test_clif_get_attr_missing_quote(void)
{
clif_attr_t attr;
char *input = ";rt=\"temp";
int r = clif_get_attr(input, strlen(input), &attr);
TEST_ASSERT_EQUAL_INT(CLIF_NOT_FOUND, r);
}
static void test_clif_get_empty_attr_value(void)
{
clif_attr_t attr;
char *input = ";rt=\"\"";
int r = clif_get_attr(input, strlen(input), &attr);
TEST_ASSERT_EQUAL_INT(CLIF_NOT_FOUND, r);
}
static void test_clif_get_attr_empty(void)
@ -301,6 +319,8 @@ Test *tests_clif_tests(void)
new_TestFixture(test_clif_encode_links),
new_TestFixture(test_clif_decode_links),
new_TestFixture(test_clif_get_attr_missing_value),
new_TestFixture(test_clif_get_attr_missing_quote),
new_TestFixture(test_clif_get_empty_attr_value),
new_TestFixture(test_clif_get_attr_empty)
};