int mongrel2_ws_reply(mongrel2_socket *pub_socket, mongrel2_request *req, bstring data){ bstring payload = bstrcpy(data); // ! and # are the fill characters. You should not see these if the data is correct bInsertChrs(payload, blength(payload), 1, TERM_CHAR, '!'); bInsertChrs(payload, 0, 1, START_CHAR, '#'); mongrel2_reply(pub_socket,req,payload); // mongrel2_ws_debug(payload); bdestroy(payload); return 0; }
int test6 (void) { struct tagbstring t = bsStatic ("Hello world"); bstring b; int ret = 0; printf ("TEST: bInsertChrs function.\n"); ret += 0 <= bInsertChrs (&t, 6, 4, 'x', '?'); ret += 0 > bInsertChrs (b = bstrcpy (&t), 6, 4, 'x', '?'); ret += 0 >= biseqcstr (b, "Hello xxxxworld"); bdestroy (b); printf ("\t# failures: %d\n", ret); return ret; }
END_TEST START_TEST(core_006) { struct tagbstring t = bsStatic("Hello world"); int ret = 0; bstring b; ret = bInsertChrs(&t, 6, 4, 'x', '?'); ck_assert(ret < 0); b = bstrcpy(&t); ck_assert(b != NULL); ret = bInsertChrs(b, 6, 4, 'x', '?'); ck_assert_int_eq(ret, 0); ret = biseqcstr(b, "Hello xxxxworld"); ck_assert_int_eq(ret, 1); ret = bdestroy(b); ck_assert_int_eq(ret, BSTR_OK); }