7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2024-11-24 16:05:01 +00:00
kicad/thirdparty/sentry-native/tests/unit/test_slice.c
2022-08-15 20:48:53 -04:00

21 lines
557 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "sentry_slice.h"
#include "sentry_testsupport.h"
SENTRY_TEST(slice)
{
char buf[] = "my string buffer";
char sbuf[] = "string";
// we dont have explicit slicing functions, so create the slices manually
sentry_slice_t my = { buf, 2 };
sentry_slice_t str1 = { buf + 3, 6 };
sentry_slice_t str2 = { sbuf, 6 };
TEST_CHECK(sentry__slice_eq(str1, str2));
TEST_CHECK(!sentry__slice_eq(str1, my));
char *owned = sentry__slice_to_owned(str1);
TEST_CHECK_STRING_EQUAL(owned, "string");
sentry_free(owned);
}