kicad/thirdparty/sentry-native/tests/unit/test_slice.c

22 lines
577 B
C
Raw 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"
#include <sentry.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);
}