static void test_Cat(TestBatchRunner *runner) { String *wanted = Str_newf("a%s", smiley); CharBuf *got = S_get_cb(""); CB_Cat(got, wanted); TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat"); DECREF(got); got = S_get_cb("a"); CB_Cat_Char(got, 0x263A); TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Char"); DECREF(got); got = S_get_cb("a"); CB_Cat_Utf8(got, smiley, smiley_len); TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Utf8"); DECREF(got); got = S_get_cb("a"); CB_Cat_Trusted_Utf8(got, smiley, smiley_len); TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Trusted_Utf8"); DECREF(got); DECREF(wanted); }
static void test_Cat(TestBatch *batch) { CharBuf *wanted = CB_newf("a%s", smiley); CharBuf *got = S_get_cb(""); CB_Cat(got, wanted); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Cat"); DECREF(got); got = S_get_cb("a"); CB_Cat_Char(got, 0x263A); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Cat_Char"); DECREF(got); got = S_get_cb("a"); CB_Cat_Str(got, smiley, smiley_len); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Cat_Str"); DECREF(got); got = S_get_cb("a"); CB_Cat_Trusted_Str(got, smiley, smiley_len); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Cat_Trusted_Str"); DECREF(got); DECREF(wanted); }
static void test_Mimic_and_Clone(TestBatchRunner *runner) { String *wanted = S_get_str("foo"); CharBuf *wanted_cb = S_get_cb("foo"); CharBuf *got = S_get_cb("bar"); CB_Mimic(got, (Obj*)wanted); TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic String"); DECREF(got); got = S_get_cb("bar"); CB_Mimic(got, (Obj*)wanted_cb); TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic CharBuf"); DECREF(got); got = S_get_cb("bar"); CB_Mimic_Utf8(got, "foo", 3); TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic_Utf8"); DECREF(got); got = CB_Clone(wanted_cb); TEST_TRUE(runner, S_cb_equals(got, wanted), "Clone"); DECREF(got); DECREF(wanted); DECREF(wanted_cb); }
static void vcatf_null_obj(VArray *tests) { CharBuf *wanted = S_get_cb("foo bar [NULL] baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %o baz", NULL); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void vcatf_s(VArray *tests) { CharBuf *wanted = S_get_cb("foo bar bizzle baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %s baz", "bizzle"); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void test_vcatf_null_obj(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo bar [NULL] baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %o baz", NULL); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%o NULL"); DECREF(wanted); DECREF(got); }
static void vcatf_i32(VArray *tests) { CharBuf *wanted = S_get_cb("foo bar -100000 baz"); i32_t num = -100000; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %i32 baz", num); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void vcatf_u64(VArray *tests) { CharBuf *wanted = S_get_cb("foo bar 5000000000 baz"); u64_t num = U64_C(5000000000); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u64 baz", num); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void test_vcatf_s(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo bar bizzle baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %s baz", "bizzle"); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%s"); DECREF(wanted); DECREF(got); }
static void vcatf_i8(VArray *tests) { CharBuf *wanted = S_get_cb("foo bar -3 baz"); i8_t num = -3; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %i8 baz", num); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void test_vcatf_u64(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo bar 5000000000 baz"); uint64_t num = U64_C(5000000000); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u64 baz", num); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%u64"); DECREF(wanted); DECREF(got); }
static void vcatf_cb(VArray *tests) { CharBuf *wanted = S_get_cb("foo bar ZEKE baz"); CharBuf *catworthy = S_get_cb("ZEKE"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %o baz", catworthy); DECREF(catworthy); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void vcatf_obj(VArray *tests) { CharBuf *wanted = S_get_cb("ooga content:FOO booga"); LeafQuery *leaf_query = TestUtils_make_leaf_query("content", "FOO"); CharBuf *got = S_get_cb("ooga"); CB_catf(got, " %o booga", leaf_query); DECREF(leaf_query); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void test_vcatf_u8(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo bar 3 baz"); uint8_t num = 3; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u8 baz", num); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%u8"); DECREF(wanted); DECREF(got); }
static void test_vcatf_u32(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo bar 100000 baz"); uint32_t num = 100000; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u32 baz", num); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%u32"); DECREF(wanted); DECREF(got); }
static void test_vcatf_cb(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo bar ZEKE baz"); CharBuf *catworthy = S_get_cb("ZEKE"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %o baz", catworthy); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%o CharBuf"); DECREF(catworthy); DECREF(wanted); DECREF(got); }
static void test_vcatf_obj(TestBatch *batch) { CharBuf *wanted = S_get_cb("ooga 20 booga"); Integer32 *i32 = Int32_new(20); CharBuf *got = S_get_cb("ooga"); CB_catf(got, " %o booga", i32); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%o Obj"); DECREF(i32); DECREF(wanted); DECREF(got); }
static void test_To_I64(TestBatch *batch) { CharBuf *charbuf = S_get_cb("10"); TEST_TRUE(batch, CB_To_I64(charbuf) == 10, "To_I64"); CB_setf(charbuf, "-10"); TEST_TRUE(batch, CB_To_I64(charbuf) == -10, "To_I64 negative"); DECREF(charbuf); }
static void test_vcatf_null_obj(TestBatchRunner *runner) { String *wanted = S_get_str("foo bar [NULL] baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %o baz", NULL); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%o NULL"); DECREF(wanted); DECREF(got); }
static void test_serialization(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo"); CharBuf *got = (CharBuf*)TestUtils_freeze_thaw((Obj*)wanted); TEST_TRUE(batch, got && CB_Equals(wanted, (Obj*)got), "Round trip through FREEZE/THAW"); DECREF(got); DECREF(wanted); }
static void test_vcatf_s(TestBatchRunner *runner) { String *wanted = S_get_str("foo bar bizzle baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %s baz", "bizzle"); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%s"); DECREF(wanted); DECREF(got); }
static void test_vcatf_i8(TestBatchRunner *runner) { String *wanted = S_get_str("foo bar -3 baz"); int8_t num = -3; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %i8 baz", num); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%i8"); DECREF(wanted); DECREF(got); }
static void test_vcatf_u32(TestBatchRunner *runner) { String *wanted = S_get_str("foo bar 100000 baz"); uint32_t num = 100000; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u32 baz", num); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%u32"); DECREF(wanted); DECREF(got); }
static void test_vcatf_u64(TestBatchRunner *runner) { String *wanted = S_get_str("foo bar 5000000000 baz"); uint64_t num = UINT64_C(5000000000); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u64 baz", num); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%u64"); DECREF(wanted); DECREF(got); }
static void test_Mimic_and_Clone(TestBatch *batch) { CharBuf *wanted = S_get_cb("foo"); CharBuf *got = S_get_cb("bar"); CB_Mimic(got, (Obj*)wanted); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Mimic"); DECREF(got); got = S_get_cb("bar"); CB_Mimic_Str(got, "foo", 3); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Mimic_Str"); DECREF(got); got = CB_Clone(wanted); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "Clone"); DECREF(got); DECREF(wanted); }
static void test_vcatf_str(TestBatchRunner *runner) { String *wanted = S_get_str("foo bar ZEKE baz"); String *catworthy = S_get_str("ZEKE"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %o baz", catworthy); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%o CharBuf"); DECREF(catworthy); DECREF(wanted); DECREF(got); }
static void test_vcatf_obj(TestBatchRunner *runner) { String *wanted = S_get_str("ooga 20 booga"); Integer32 *i32 = Int32_new(20); CharBuf *got = S_get_cb("ooga"); CB_catf(got, " %o booga", i32); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%o Obj"); DECREF(i32); DECREF(wanted); DECREF(got); }
static void vcatf_f64(VArray *tests) { CharBuf *wanted; char buf[64]; float num = 1.3f; CharBuf *got = S_get_cb("foo "); sprintf(buf, "foo bar %g baz", num); wanted = CB_new_from_trusted_utf8(buf, strlen(buf)); CB_catf(got, "bar %f64 baz", num); VA_Push(tests, (Obj*)TestCB_new(wanted, got)); }
static void test_vcatf_f64(TestBatch *batch) { CharBuf *wanted; char buf[64]; float num = 1.3f; CharBuf *got = S_get_cb("foo "); sprintf(buf, "foo bar %g baz", num); wanted = CB_new_from_trusted_utf8(buf, strlen(buf)); CB_catf(got, "bar %f64 baz", num); TEST_TRUE(batch, CB_Equals(wanted, (Obj*)got), "%%f64"); DECREF(wanted); DECREF(got); }
static void test_vcatf_f64(TestBatchRunner *runner) { String *wanted; char buf[64]; float num = 1.3f; CharBuf *got = S_get_cb("foo "); sprintf(buf, "foo bar %g baz", num); wanted = Str_new_from_trusted_utf8(buf, strlen(buf)); CB_catf(got, "bar %f64 baz", num); TEST_TRUE(runner, S_cb_equals(got, wanted), "%%f64"); DECREF(wanted); DECREF(got); }