Skip to content

Commit

Permalink
chore(tests): add string test
Browse files Browse the repository at this point in the history
  • Loading branch information
Water-Melon committed May 6, 2024
1 parent ba3800c commit 97b4d6e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions t/string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "mln_string.h"
#include <assert.h>

int main(void)
{
mln_string_t text = mln_string("Hello");
mln_string_t *slices, *ref, *s = mln_string_dup(&text);
assert(s != NULL);

assert((ref = mln_string_ref(s)) == s);

assert(!mln_string_strcmp(ref, &text));

assert((slices = mln_string_slice(ref, "e")) != NULL);

assert(slices[0].len > 0);
assert(!mln_string_const_strcmp(&slices[0], "H"));
assert(slices[1].len > 0);
assert(!mln_string_const_strcmp(&slices[1], "llo"));

mln_string_slice_free(slices);
mln_string_free(ref);
mln_string_free(s);
return 0;
}

0 comments on commit 97b4d6e

Please sign in to comment.