Files
Arpad Borsos e995329629 fix: Correct wrong slice comparison (#164)
* fix: Correct wrong slice comparison

* add explicit slice tests
2020-03-10 11:12:23 +01:00

22 lines
577 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"
#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);
}