END_TEST START_TEST(core_012) { struct tagbstring t = bsStatic("Hello world"); struct bStream * s; int ret = 0; bstring b, c; s = bsFromBstr(&t); ck_assert(s != NULL); b = bfromcstr(""); ck_assert(b != NULL); ret = bsread(b, s, 6); ck_assert_int_eq(ret, 0); ret = biseqcstr(b, "Hello "); ck_assert_int_eq(ret, 1); if (b) { b->slen = 0; } ret = bsread(b, s, 6); ck_assert_int_eq(ret, 0); ret = biseqcstr(b, "world"); ck_assert_int_eq(ret, 1); c = bsclose(s); ck_assert(c == NULL); ret = bdestroy(b); ck_assert_int_eq(ret, BSTR_OK); }
int test12 (void) { struct tagbstring t = bsStatic ("Hello world"); struct bStream * s; bstring b; int ret = 0; printf ("TEST: bsFromBstr.\n"); ret = bsread (b = bfromcstr (""), s = bsFromBstr (&t), 6); ret += 1 != biseqcstr (b, "Hello "); if (b) b->slen = 0; ret = bsread (b, s, 6); ret += 1 != biseqcstr (b, "world"); bdestroy (b); bsclose (s); printf ("\t# failures: %d\n", ret); return ret; }