Switch input structure entirely to bxstring

This commit is contained in:
Thomas Jensen
2023-05-24 21:00:49 +02:00
parent 45ce5e6762
commit a759026790
16 changed files with 539 additions and 172 deletions

View File

@ -28,6 +28,7 @@
#include <string.h>
#include "boxes.h"
#include "tools.h"
#include "unicode.h"
#include "unicode_test.h"
@ -158,4 +159,28 @@ void test_is_allowed_in_kv_string(void **state)
}
void test_u32_strnrstr(void **state)
{
UNUSED(state);
uint32_t *haystack = u32_strconv_from_arg("a foo found found bar fou", "ASCII");
assert_non_null(haystack);
uint32_t *needle = u32_strconv_from_arg("found", "ASCII");
assert_non_null(needle);
assert_null(u32_strnrstr(NULL, needle, u32_strlen(needle), 0));
assert_ptr_equal(haystack, u32_strnrstr(haystack, NULL, 0, 0));
uint32_t *actual = u32_strnrstr(haystack, needle, u32_strlen(needle), 1);
assert_ptr_equal(haystack + 6, actual);
actual = u32_strnrstr(haystack, needle, u32_strlen(needle), -1); /* -1 will be "fixed" to 0 */
assert_ptr_equal(haystack + 12, actual);
BFREE(haystack);
BFREE(needle);
}
/* vim: set cindent sw=4: */