parent
8f91cf3d0c
commit
5bf745f51d
@ -0,0 +1,55 @@
|
||||
#include "../minunit.h"
|
||||
#include <lcthw/bstrlib.h>
|
||||
|
||||
char *test_bfromcstr()
|
||||
{
|
||||
bstring b = bfromcstr("oh hai");
|
||||
mu_assert(b != NULL, "bstring is NULL.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *test_blk2bstr()
|
||||
{
|
||||
bstring b = blk2bstr("hats", 5);
|
||||
mu_assert(b != NULL, "bstring is NULL.");
|
||||
|
||||
b = blk2bstr(NULL, 42);
|
||||
mu_assert(b == NULL, "bstring is not NULL.");
|
||||
|
||||
b = blk2bstr("bats", -17);
|
||||
mu_assert(b == NULL, "bstring is not NULL.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *test_bstrcpy()
|
||||
{
|
||||
bstring b = bfromcstr("mats");
|
||||
mu_assert(bstrcpy(b) != NULL, "bstring is NULL.");
|
||||
|
||||
mu_assert(bstrcpy(NULL) == NULL, "bstring is not NULL.");
|
||||
|
||||
int orig_len = b->slen;
|
||||
b->slen = -1;
|
||||
mu_assert(bstrcpy(b) == NULL, "bstring is not NULL.");
|
||||
b->slen = orig_len;
|
||||
|
||||
b->data = NULL;
|
||||
mu_assert(bstrcpy(b) == NULL, "bstring is not NULL.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *all_tests()
|
||||
{
|
||||
mu_suite_start();
|
||||
|
||||
mu_run_test(test_bfromcstr);
|
||||
mu_run_test(test_blk2bstr);
|
||||
mu_run_test(test_bstrcpy);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RUN_TESTS(all_tests);
|
Loading…
Reference in new issue