mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
string-helpers.c: add str_starts_with()
This commit is contained in:
parent
5db953aa89
commit
2446c46069
5 changed files with 45 additions and 7 deletions
|
|
@ -11,6 +11,7 @@ test_lib = static_library(
|
|||
|
||||
tests = [
|
||||
'buf-simple',
|
||||
'str',
|
||||
]
|
||||
|
||||
foreach t : tests
|
||||
|
|
|
|||
28
t/str.c
Normal file
28
t/str.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <setjmp.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cmocka.h>
|
||||
#include "common/string-helpers.h"
|
||||
|
||||
static void
|
||||
test_str_starts_with(void **state)
|
||||
{
|
||||
(void)state;
|
||||
|
||||
assert_true(str_starts_with(" foo", 'f', " \t\r\n"));
|
||||
assert_true(str_starts_with("f", 'f', " \t\r\n"));
|
||||
assert_false(str_starts_with(" foo", '<', " "));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(test_str_starts_with),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue