Expose util function to truncate first line

Move the local implementation from adb functions to the string util
functions.
This commit is contained in:
Romain Vimont
2021-11-17 18:25:56 +01:00
parent 443cb14d6e
commit f2781a8b6d
4 changed files with 32 additions and 12 deletions

View File

@@ -337,6 +337,14 @@ static void test_wrap_lines(void) {
free(formatted);
}
static void test_truncate_first_line(void) {
char s[] = "hello\nworld\n!";
size_t len = sc_str_truncate_first_line(s, sizeof(s));
assert(len == 5);
assert(!strcmp("hello", s));
}
int main(int argc, char *argv[]) {
(void) argc;
(void) argv;
@@ -356,5 +364,6 @@ int main(int argc, char *argv[]) {
test_parse_integer_with_suffix();
test_strlist_contains();
test_wrap_lines();
test_truncate_first_line();
return 0;
}