summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
authorAnna Karas <aka@semihalf.com>2020-07-07 15:34:54 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-07-12 19:38:39 +0000
commit86acc04d2874fb9ef00408a4b96d496030a95eb1 (patch)
tree0e0fca086ad1b9f491566f1ed74cc8cad54e8cb5 /tests/lib
parentf7cd0d5a0563fc039bc73a4e61eba76205e0fe98 (diff)
downloadcoreboot-86acc04d2874fb9ef00408a4b96d496030a95eb1.tar.xz
tests: Improve test_skip_atoi() in /lib/string-test test case
Confirm that the pointer is updated to point behind the parsed number. Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: If75a51056229904612c6a9ea20db4182d1935009 Reviewed-on: https://review.coreboot.org/c/coreboot/+/43288 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/string-test.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/lib/string-test.c b/tests/lib/string-test.c
index 859f749618..7718547c70 100644
--- a/tests/lib/string-test.c
+++ b/tests/lib/string-test.c
@@ -48,11 +48,12 @@ struct str_with_l_val_t {
struct str_with_u_val_t {
char *str;
uint32_t value;
+ uint32_t offset;
} str_with_u_val[] = {
- {"42aa", 42},
- {"a", 0},
- {"0", 0},
- {"4a2", 4},
+ {"42aa", 42, 2},
+ {"a", 0, 0},
+ {"0", 0, 1},
+ {"4a2", 4, 1},
};
static void test_strdup(void **state)
@@ -207,11 +208,13 @@ static void test_strncmp(void **state)
static void test_skip_atoi(void **state)
{
int i;
- char *ptr;
+ char *ptr, *copy;
for (i = 0; i < ARRAY_SIZE(str_with_u_val); i++) {
ptr = str_with_u_val[i].str;
+ copy = ptr;
assert_true(str_with_u_val[i].value == skip_atoi(&ptr));
+ assert_int_equal(str_with_u_val[i].offset, ptr - copy);
}
}