Replace TEST_TRUE with OK in several test files.
diff --git a/runtime/core/Clownfish/Test/TestByteBuf.c b/runtime/core/Clownfish/Test/TestByteBuf.c index dcea3b5..480fa4a 100644 --- a/runtime/core/Clownfish/Test/TestByteBuf.c +++ b/runtime/core/Clownfish/Test/TestByteBuf.c
@@ -37,10 +37,10 @@ ByteBuf *wanted = BB_new_bytes("foo", 4); // Include terminating NULL. ByteBuf *got = BB_new_bytes("foo", 4); - TEST_TRUE(runner, BB_Equals(wanted, (Obj*)got), "Equals"); + OK(BB_Equals(wanted, (Obj*)got), "Equals"); TEST_INT_EQ(runner, BB_Hash_Sum(got), BB_Hash_Sum(wanted), "Hash_Sum"); - TEST_TRUE(runner, BB_Equals_Bytes(got, "foo", 4), "Equals_Bytes"); + OK(BB_Equals_Bytes(got, "foo", 4), "Equals_Bytes"); TEST_FALSE(runner, BB_Equals_Bytes(got, "foo", 3), "Equals_Bytes spoiled by different size"); TEST_FALSE(runner, BB_Equals_Bytes(got, "bar", 4), @@ -77,7 +77,7 @@ test_Clone(TestBatchRunner *runner) { ByteBuf *bb = BB_new_bytes("foo", 3); ByteBuf *twin = BB_Clone(bb); - TEST_TRUE(runner, BB_Equals(bb, (Obj*)twin), "Clone"); + OK(BB_Equals(bb, (Obj*)twin), "Clone"); DECREF(bb); DECREF(twin); } @@ -93,12 +93,11 @@ "BB_compare returns 0 for equal ByteBufs"); BB_Set_Size(a, 3); - TEST_TRUE(runner, BB_compare(&a, &b) < 0, "shorter ByteBuf sorts first"); + OK(BB_compare(&a, &b) < 0, "shorter ByteBuf sorts first"); BB_Set_Size(a, 5); BB_Set_Size(b, 5); - TEST_TRUE(runner, BB_compare(&a, &b) < 0, - "NULL doesn't interfere with BB_compare"); + OK(BB_compare(&a, &b) < 0, "NULL doesn't interfere with BB_compare"); DECREF(a); DECREF(b); @@ -110,15 +109,15 @@ ByteBuf *b = BB_new(0); BB_Mimic(b, (Obj*)a); - TEST_TRUE(runner, BB_Equals(a, (Obj*)b), "Mimic"); + OK(BB_Equals(a, (Obj*)b), "Mimic"); BB_Mimic_Bytes(a, "bar", 4); - TEST_TRUE(runner, strcmp(BB_Get_Buf(a), "bar") == 0, + OK(strcmp(BB_Get_Buf(a), "bar") == 0, "Mimic_Bytes content"); TEST_INT_EQ(runner, BB_Get_Size(a), 4, "Mimic_Bytes size"); BB_Mimic(b, (Obj*)a); - TEST_TRUE(runner, BB_Equals(a, (Obj*)b), "Mimic"); + OK(BB_Equals(a, (Obj*)b), "Mimic"); DECREF(a); DECREF(b); @@ -131,11 +130,11 @@ ByteBuf *scratch = BB_new_bytes("bar", 3); BB_Cat(got, scratch); - TEST_TRUE(runner, BB_Equals(wanted, (Obj*)got), "Cat"); + OK(BB_Equals(wanted, (Obj*)got), "Cat"); BB_Mimic_Bytes(wanted, "foobarbaz", 9); BB_Cat_Bytes(got, "baz", 3); - TEST_TRUE(runner, BB_Equals(wanted, (Obj*)got), "Cat_Bytes"); + OK(BB_Equals(wanted, (Obj*)got), "Cat_Bytes"); DECREF(scratch); DECREF(got);
diff --git a/runtime/core/Clownfish/Test/TestCharBuf.c b/runtime/core/Clownfish/Test/TestCharBuf.c index 48c36a1..8686fd5 100644 --- a/runtime/core/Clownfish/Test/TestCharBuf.c +++ b/runtime/core/Clownfish/Test/TestCharBuf.c
@@ -65,22 +65,22 @@ CharBuf *got = S_get_cb(""); CB_Cat(got, wanted); - TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat"); + OK(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"); + OK(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"); + OK(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"); + OK(S_cb_equals(got, wanted), "Cat_Trusted_Utf8"); DECREF(got); DECREF(wanted); @@ -93,21 +93,21 @@ CharBuf *got = S_get_cb("bar"); CB_Mimic(got, (Obj*)wanted); - TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic String"); + OK(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"); + OK(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"); + OK(S_cb_equals(got, wanted), "Mimic_Utf8"); DECREF(got); got = CB_Clone(wanted_cb); - TEST_TRUE(runner, S_cb_equals(got, wanted), "Clone"); + OK(S_cb_equals(got, wanted), "Clone"); DECREF(got); DECREF(wanted); @@ -119,7 +119,7 @@ String *wanted = Str_newf("a%s", smiley); CharBuf *got = CB_newf("a%s%sb%sc", smiley, smiley, smiley); CB_Truncate(got, 2); - TEST_TRUE(runner, S_cb_equals(got, wanted), "Truncate"); + OK(S_cb_equals(got, wanted), "Truncate"); DECREF(wanted); DECREF(got); } @@ -130,7 +130,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%s"); DECREF(wanted); DECREF(got); } @@ -140,7 +140,7 @@ String *wanted = S_get_str("foo bar [NULL] baz"); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %s baz", NULL); - TEST_TRUE(runner, S_cb_equals(got, wanted), "%%s NULL"); + OK(S_cb_equals(got, wanted), "%%s NULL"); DECREF(wanted); DECREF(got); } @@ -151,7 +151,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%o CharBuf"); DECREF(catworthy); DECREF(wanted); DECREF(got); @@ -163,7 +163,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%o Obj"); DECREF(i32); DECREF(wanted); DECREF(got); @@ -174,7 +174,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%o NULL"); DECREF(wanted); DECREF(got); } @@ -185,7 +185,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%i8"); DECREF(wanted); DECREF(got); } @@ -196,7 +196,7 @@ int32_t num = -100000; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %i32 baz", num); - TEST_TRUE(runner, S_cb_equals(got, wanted), "%%i32"); + OK(S_cb_equals(got, wanted), "%%i32"); DECREF(wanted); DECREF(got); } @@ -207,7 +207,7 @@ int64_t num = INT64_C(-5000000000); CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %i64 baz", num); - TEST_TRUE(runner, S_cb_equals(got, wanted), "%%i64"); + OK(S_cb_equals(got, wanted), "%%i64"); DECREF(wanted); DECREF(got); } @@ -218,7 +218,7 @@ uint8_t num = 3; CharBuf *got = S_get_cb("foo "); CB_catf(got, "bar %u8 baz", num); - TEST_TRUE(runner, S_cb_equals(got, wanted), "%%u8"); + OK(S_cb_equals(got, wanted), "%%u8"); DECREF(wanted); DECREF(got); } @@ -229,7 +229,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%u32"); DECREF(wanted); DECREF(got); } @@ -240,7 +240,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%u64"); DECREF(wanted); DECREF(got); } @@ -254,7 +254,7 @@ 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"); + OK(S_cb_equals(got, wanted), "%%f64"); DECREF(wanted); DECREF(got); } @@ -272,7 +272,7 @@ #endif wanted = Str_new_from_trusted_utf8(buf, strlen(buf)); CB_catf(got, "bar %x32 baz", (uint32_t)num); - TEST_TRUE(runner, S_cb_equals(got, wanted), "%%x32"); + OK(S_cb_equals(got, wanted), "%%x32"); DECREF(wanted); DECREF(got); }
diff --git a/runtime/core/Clownfish/Test/TestErr.c b/runtime/core/Clownfish/Test/TestErr.c index 5627d7d..7cb0921 100644 --- a/runtime/core/Clownfish/Test/TestErr.c +++ b/runtime/core/Clownfish/Test/TestErr.c
@@ -35,8 +35,7 @@ String *message = Str_newf("oops"); Err *error = Err_new(message); String *string = Err_To_String(error); - TEST_TRUE(runner, Str_Equals(message, (Obj*)string), - "Stringifies as message"); + OK(Str_Equals(message, (Obj*)string), "Stringifies as message"); DECREF(string); DECREF(error); }
diff --git a/runtime/core/Clownfish/Test/TestHash.c b/runtime/core/Clownfish/Test/TestHash.c index e5000c9..b7be731 100644 --- a/runtime/core/Clownfish/Test/TestHash.c +++ b/runtime/core/Clownfish/Test/TestHash.c
@@ -42,16 +42,15 @@ Hash *other = Hash_new(0); StackString *stuff = SSTR_WRAP_UTF8("stuff", 5); - TEST_TRUE(runner, Hash_Equals(hash, (Obj*)other), - "Empty hashes are equal"); + OK(Hash_Equals(hash, (Obj*)other), "Empty hashes are equal"); Hash_Store_Utf8(hash, "foo", 3, (Obj*)CFISH_TRUE); TEST_FALSE(runner, Hash_Equals(hash, (Obj*)other), "Add one pair and Equals returns false"); Hash_Store_Utf8(other, "foo", 3, (Obj*)CFISH_TRUE); - TEST_TRUE(runner, Hash_Equals(hash, (Obj*)other), - "Add a matching pair and Equals returns true"); + OK(Hash_Equals(hash, (Obj*)other), + "Add a matching pair and Equals returns true"); Hash_Store_Utf8(other, "foo", 3, INCREF(stuff)); TEST_FALSE(runner, Hash_Equals(hash, (Obj*)other), @@ -78,7 +77,7 @@ Hash_Store(dupe, (Obj*)str, INCREF(str)); VA_Push(expected, INCREF(str)); } - TEST_TRUE(runner, Hash_Equals(hash, (Obj*)dupe), "Equals"); + OK(Hash_Equals(hash, (Obj*)dupe), "Equals"); TEST_INT_EQ(runner, Hash_Get_Capacity(hash), starting_cap, "Initial capacity sufficient (no rebuilds)"); @@ -89,38 +88,36 @@ VA_Push(got, (Obj*)INCREF(elem)); } - TEST_TRUE(runner, VA_Equals(got, (Obj*)expected), - "basic Store and Fetch"); + OK(VA_Equals(got, (Obj*)expected), "basic Store and Fetch"); TEST_INT_EQ(runner, Hash_Get_Size(hash), 100, "size incremented properly by Hash_Store"); - TEST_TRUE(runner, Hash_Fetch(hash, (Obj*)foo) == NULL, - "Fetch against non-existent key returns NULL"); + OK(Hash_Fetch(hash, (Obj*)foo) == NULL, + "Fetch against non-existent key returns NULL"); Obj *stored_foo = INCREF(foo); Hash_Store(hash, (Obj*)forty, stored_foo); - TEST_TRUE(runner, SStr_Equals(foo, Hash_Fetch(hash, (Obj*)forty)), - "Hash_Store replaces existing value"); + OK(SStr_Equals(foo, Hash_Fetch(hash, (Obj*)forty)), + "Hash_Store replaces existing value"); TEST_FALSE(runner, Hash_Equals(hash, (Obj*)dupe), "replacement value spoils equals"); TEST_INT_EQ(runner, Hash_Get_Size(hash), 100, "size unaffected after value replaced"); - TEST_TRUE(runner, Hash_Delete(hash, (Obj*)forty) == stored_foo, - "Delete returns value"); + OK(Hash_Delete(hash, (Obj*)forty) == stored_foo, "Delete returns value"); DECREF(stored_foo); TEST_INT_EQ(runner, Hash_Get_Size(hash), 99, "size decremented by successful Delete"); - TEST_TRUE(runner, Hash_Delete(hash, (Obj*)forty) == NULL, - "Delete returns NULL when key not found"); + OK(Hash_Delete(hash, (Obj*)forty) == NULL, + "Delete returns NULL when key not found"); TEST_INT_EQ(runner, Hash_Get_Size(hash), 99, "size not decremented by unsuccessful Delete"); DECREF(Hash_Delete(dupe, (Obj*)forty)); - TEST_TRUE(runner, VA_Equals(got, (Obj*)expected), "Equals after Delete"); + OK(VA_Equals(got, (Obj*)expected), "Equals after Delete"); Hash_Clear(hash); - TEST_TRUE(runner, Hash_Fetch(hash, (Obj*)twenty) == NULL, "Clear"); - TEST_TRUE(runner, Hash_Get_Size(hash) == 0, "size is 0 after Clear"); + OK(Hash_Fetch(hash, (Obj*)twenty) == NULL, "Clear"); + OK(Hash_Get_Size(hash) == 0, "size is 0 after Clear"); DECREF(hash); DECREF(dupe); @@ -147,8 +144,8 @@ values = Hash_Values(hash); VA_Sort(keys, NULL, NULL); VA_Sort(values, NULL, NULL); - TEST_TRUE(runner, VA_Equals(keys, (Obj*)expected), "Keys"); - TEST_TRUE(runner, VA_Equals(values, (Obj*)expected), "Values"); + OK(VA_Equals(keys, (Obj*)expected), "Keys"); + OK(VA_Equals(values, (Obj*)expected), "Values"); VA_Clear(keys); VA_Clear(values); @@ -164,17 +161,16 @@ VA_Sort(keys, NULL, NULL); VA_Sort(values, NULL, NULL); - TEST_TRUE(runner, VA_Equals(keys, (Obj*)expected), "Keys from Iter"); - TEST_TRUE(runner, VA_Equals(values, (Obj*)expected), "Values from Iter"); + OK(VA_Equals(keys, (Obj*)expected), "Keys from Iter"); + OK(VA_Equals(values, (Obj*)expected), "Values from Iter"); { StackString *forty = SSTR_WRAP_UTF8("40", 2); StackString *nope = SSTR_WRAP_UTF8("nope", 4); Obj *key = Hash_Find_Key(hash, (Obj*)forty, SStr_Hash_Sum(forty)); - TEST_TRUE(runner, Obj_Equals(key, (Obj*)forty), "Find_Key"); + OK(Obj_Equals(key, (Obj*)forty), "Find_Key"); key = Hash_Find_Key(hash, (Obj*)nope, SStr_Hash_Sum(nope)), - TEST_TRUE(runner, key == NULL, - "Find_Key returns NULL for non-existent key"); + OK(key == NULL, "Find_Key returns NULL for non-existent key"); } DECREF(hash); @@ -212,8 +208,8 @@ values = Hash_Values(hash); VA_Sort(keys, NULL, NULL); VA_Sort(values, NULL, NULL); - TEST_TRUE(runner, VA_Equals(keys, (Obj*)expected), "stress Keys"); - TEST_TRUE(runner, VA_Equals(values, (Obj*)expected), "stress Values"); + OK(VA_Equals(keys, (Obj*)expected), "stress Keys"); + OK(VA_Equals(values, (Obj*)expected), "stress Values"); DECREF(keys); DECREF(values);
diff --git a/runtime/core/Clownfish/Test/TestLockFreeRegistry.c b/runtime/core/Clownfish/Test/TestLockFreeRegistry.c index 515db9a..a822d1f 100644 --- a/runtime/core/Clownfish/Test/TestLockFreeRegistry.c +++ b/runtime/core/Clownfish/Test/TestLockFreeRegistry.c
@@ -53,21 +53,19 @@ StupidHashCharBuf *baz = StupidHashCharBuf_new("baz"); StupidHashCharBuf *foo_dupe = StupidHashCharBuf_new("foo"); - TEST_TRUE(runner, LFReg_Register(registry, (Obj*)foo, (Obj*)foo), - "Register() returns true on success"); + OK(LFReg_Register(registry, (Obj*)foo, (Obj*)foo), + "Register() returns true on success"); TEST_FALSE(runner, LFReg_Register(registry, (Obj*)foo_dupe, (Obj*)foo_dupe), "Can't Register() keys that test equal"); - TEST_TRUE(runner, LFReg_Register(registry, (Obj*)bar, (Obj*)bar), - "Register() key with the same Hash_Sum but that isn't Equal"); + OK(LFReg_Register(registry, (Obj*)bar, (Obj*)bar), + "Register() key with the same Hash_Sum but that isn't Equal"); - TEST_TRUE(runner, LFReg_Fetch(registry, (Obj*)foo_dupe) == (Obj*)foo, - "Fetch()"); - TEST_TRUE(runner, LFReg_Fetch(registry, (Obj*)bar) == (Obj*)bar, - "Fetch() again"); - TEST_TRUE(runner, LFReg_Fetch(registry, (Obj*)baz) == NULL, - "Fetch() non-existent key returns NULL"); + OK(LFReg_Fetch(registry, (Obj*)foo_dupe) == (Obj*)foo, "Fetch()"); + OK(LFReg_Fetch(registry, (Obj*)bar) == (Obj*)bar, "Fetch() again"); + OK(LFReg_Fetch(registry, (Obj*)baz) == NULL, + "Fetch() non-existent key returns NULL"); DECREF(foo_dupe); DECREF(baz);
diff --git a/runtime/core/Clownfish/Test/TestNum.c b/runtime/core/Clownfish/Test/TestNum.c index f84c2c0..ae48830 100644 --- a/runtime/core/Clownfish/Test/TestNum.c +++ b/runtime/core/Clownfish/Test/TestNum.c
@@ -44,18 +44,18 @@ String *true_string = Bool_To_String(CFISH_TRUE); String *false_string = Bool_To_String(CFISH_FALSE); - TEST_TRUE(runner, Str_Starts_With_Utf8(f32_string, "1.3", 3), - "Float32_To_String"); - TEST_TRUE(runner, Str_Starts_With_Utf8(f64_string, "1.3", 3), - "Float64_To_String"); - TEST_TRUE(runner, Str_Equals_Utf8(i32_string, "2147483647", 10), - "Int32_To_String"); - TEST_TRUE(runner, Str_Equals_Utf8(i64_string, "9223372036854775807", 19), - "Int64_To_String"); - TEST_TRUE(runner, Str_Equals_Utf8(true_string, "true", 4), - "Bool_To_String [true]"); - TEST_TRUE(runner, Str_Equals_Utf8(false_string, "false", 5), - "Bool_To_String [false]"); + OK(Str_Starts_With_Utf8(f32_string, "1.3", 3), + "Float32_To_String"); + OK(Str_Starts_With_Utf8(f64_string, "1.3", 3), + "Float64_To_String"); + OK(Str_Equals_Utf8(i32_string, "2147483647", 10), + "Int32_To_String"); + OK(Str_Equals_Utf8(i64_string, "9223372036854775807", 19), + "Int64_To_String"); + OK(Str_Equals_Utf8(true_string, "true", 4), + "Bool_To_String [true]"); + OK(Str_Equals_Utf8(false_string, "false", 5), + "Bool_To_String [false]"); DECREF(false_string); DECREF(true_string); @@ -86,45 +86,38 @@ Float64_Set_Value(f64, 1.33); got64 = Float64_Get_Value(f64); - TEST_TRUE(runner, *(int64_t*)&got64 == *(int64_t*)&wanted64, - "F64 Set_Value Get_Value"); + OK(*(int64_t*)&got64 == *(int64_t*)&wanted64, + "F64 Set_Value Get_Value"); - TEST_TRUE(runner, Float32_To_I64(f32) == 1, "Float32_To_I64"); - TEST_TRUE(runner, Float64_To_I64(f64) == 1, "Float64_To_I64"); + OK(Float32_To_I64(f32) == 1, "Float32_To_I64"); + OK(Float64_To_I64(f64) == 1, "Float64_To_I64"); got32 = (float)Float32_To_F64(f32); - TEST_TRUE(runner, *(int32_t*)&got32 == *(int32_t*)&wanted32, - "Float32_To_F64"); + OK(*(int32_t*)&got32 == *(int32_t*)&wanted32, "Float32_To_F64"); got64 = Float64_To_F64(f64); - TEST_TRUE(runner, *(int64_t*)&got64 == *(int64_t*)&wanted64, - "Float64_To_F64"); + OK(*(int64_t*)&got64 == *(int64_t*)&wanted64, "Float64_To_F64"); Int32_Set_Value(i32, INT32_MIN); TEST_INT_EQ(runner, Int32_Get_Value(i32), INT32_MIN, "I32 Set_Value Get_Value"); Int64_Set_Value(i64, INT64_MIN); - TEST_TRUE(runner, Int64_Get_Value(i64) == INT64_MIN, - "I64 Set_Value Get_Value"); + OK(Int64_Get_Value(i64) == INT64_MIN, "I64 Set_Value Get_Value"); Int32_Set_Value(i32, -1); Int64_Set_Value(i64, -1); - TEST_TRUE(runner, Int32_To_F64(i32) == -1, "Int32_To_F64"); - TEST_TRUE(runner, Int64_To_F64(i64) == -1, "Int64_To_F64"); + OK(Int32_To_F64(i32) == -1, "Int32_To_F64"); + OK(Int64_To_F64(i64) == -1, "Int64_To_F64"); TEST_INT_EQ(runner, Bool_Get_Value(CFISH_TRUE), true, "Bool_Get_Value [true]"); TEST_INT_EQ(runner, Bool_Get_Value(CFISH_FALSE), false, "Bool_Get_Value [false]"); - TEST_TRUE(runner, Bool_To_I64(CFISH_TRUE) == true, - "Bool_To_I64 [true]"); - TEST_TRUE(runner, Bool_To_I64(CFISH_FALSE) == false, - "Bool_To_I64 [false]"); - TEST_TRUE(runner, Bool_To_F64(CFISH_TRUE) == 1.0, - "Bool_To_F64 [true]"); - TEST_TRUE(runner, Bool_To_F64(CFISH_FALSE) == 0.0, - "Bool_To_F64 [false]"); + OK(Bool_To_I64(CFISH_TRUE) == true, "Bool_To_I64 [true]"); + OK(Bool_To_I64(CFISH_FALSE) == false, "Bool_To_I64 [false]"); + OK(Bool_To_F64(CFISH_TRUE) == 1.0, "Bool_To_F64 [true]"); + OK(Bool_To_F64(CFISH_FALSE) == 0.0, "Bool_To_F64 [false]"); DECREF(i64); DECREF(i32); @@ -139,63 +132,58 @@ Integer32 *i32 = Int32_new(INT32_MAX); Integer64 *i64 = Int64_new(INT64_MAX); - TEST_TRUE(runner, Float32_Compare_To(f32, (Obj*)f64) == 0, - "F32_Compare_To equal"); - TEST_TRUE(runner, Float32_Equals(f32, (Obj*)f64), - "F32_Equals equal"); + OK(Float32_Compare_To(f32, (Obj*)f64) == 0, "F32_Compare_To equal"); + OK(Float32_Equals(f32, (Obj*)f64), "F32_Equals equal"); Float64_Set_Value(f64, 2.0); - TEST_TRUE(runner, Float32_Compare_To(f32, (Obj*)f64) < 0, - "F32_Compare_To less than"); + OK(Float32_Compare_To(f32, (Obj*)f64) < 0, "F32_Compare_To less than"); TEST_FALSE(runner, Float32_Equals(f32, (Obj*)f64), "F32_Equals less than"); Float64_Set_Value(f64, 0.0); - TEST_TRUE(runner, Float32_Compare_To(f32, (Obj*)f64) > 0, - "F32_Compare_To greater than"); + OK(Float32_Compare_To(f32, (Obj*)f64) > 0, + "F32_Compare_To greater than"); TEST_FALSE(runner, Float32_Equals(f32, (Obj*)f64), "F32_Equals greater than"); Float64_Set_Value(f64, 1.0); Float32_Set_Value(f32, 1.0); - TEST_TRUE(runner, Float64_Compare_To(f64, (Obj*)f32) == 0, - "F64_Compare_To equal"); - TEST_TRUE(runner, Float64_Equals(f64, (Obj*)f32), - "F64_Equals equal"); + OK(Float64_Compare_To(f64, (Obj*)f32) == 0, "F64_Compare_To equal"); + OK(Float64_Equals(f64, (Obj*)f32), "F64_Equals equal"); Float32_Set_Value(f32, 2.0); - TEST_TRUE(runner, Float64_Compare_To(f64, (Obj*)f32) < 0, - "F64_Compare_To less than"); + OK(Float64_Compare_To(f64, (Obj*)f32) < 0, + "F64_Compare_To less than"); TEST_FALSE(runner, Float64_Equals(f64, (Obj*)f32), "F64_Equals less than"); Float32_Set_Value(f32, 0.0); - TEST_TRUE(runner, Float64_Compare_To(f64, (Obj*)f32) > 0, - "F64_Compare_To greater than"); + OK(Float64_Compare_To(f64, (Obj*)f32) > 0, + "F64_Compare_To greater than"); TEST_FALSE(runner, Float64_Equals(f64, (Obj*)f32), "F64_Equals greater than"); Float64_Set_Value(f64, INT64_MAX * 2.0); - TEST_TRUE(runner, Float64_Compare_To(f64, (Obj*)i64) > 0, - "Float64 comparison to Integer64"); - TEST_TRUE(runner, Int64_Compare_To(i64, (Obj*)f64) < 0, - "Integer64 comparison to Float64"); + OK(Float64_Compare_To(f64, (Obj*)i64) > 0, + "Float64 comparison to Integer64"); + OK(Int64_Compare_To(i64, (Obj*)f64) < 0, + "Integer64 comparison to Float64"); Float32_Set_Value(f32, INT32_MAX * 2.0f); - TEST_TRUE(runner, Float32_Compare_To(f32, (Obj*)i32) > 0, - "Float32 comparison to Integer32"); - TEST_TRUE(runner, Int32_Compare_To(i32, (Obj*)f32) < 0, - "Integer32 comparison to Float32"); + OK(Float32_Compare_To(f32, (Obj*)i32) > 0, + "Float32 comparison to Integer32"); + OK(Int32_Compare_To(i32, (Obj*)f32) < 0, + "Integer32 comparison to Float32"); Int64_Set_Value(i64, INT64_C(0x6666666666666666)); Integer64 *i64_copy = Int64_new(INT64_C(0x6666666666666666)); - TEST_TRUE(runner, Int64_Compare_To(i64, (Obj*)i64_copy) == 0, - "Integer64 comparison to same number"); + OK(Int64_Compare_To(i64, (Obj*)i64_copy) == 0, + "Integer64 comparison to same number"); - TEST_TRUE(runner, Bool_Equals(CFISH_TRUE, (Obj*)CFISH_TRUE), - "CFISH_TRUE Equals itself"); - TEST_TRUE(runner, Bool_Equals(CFISH_FALSE, (Obj*)CFISH_FALSE), - "CFISH_FALSE Equals itself"); + OK(Bool_Equals(CFISH_TRUE, (Obj*)CFISH_TRUE), + "CFISH_TRUE Equals itself"); + OK(Bool_Equals(CFISH_FALSE, (Obj*)CFISH_FALSE), + "CFISH_FALSE Equals itself"); TEST_FALSE(runner, Bool_Equals(CFISH_FALSE, (Obj*)CFISH_TRUE), "CFISH_FALSE not Equals CFISH_TRUE "); TEST_FALSE(runner, Bool_Equals(CFISH_TRUE, (Obj*)CFISH_FALSE), @@ -220,16 +208,12 @@ Float64 *f64_dupe = Float64_Clone(f64); Integer32 *i32_dupe = Int32_Clone(i32); Integer64 *i64_dupe = Int64_Clone(i64); - TEST_TRUE(runner, Float32_Equals(f32, (Obj*)f32_dupe), - "Float32 Clone"); - TEST_TRUE(runner, Float64_Equals(f64, (Obj*)f64_dupe), - "Float64 Clone"); - TEST_TRUE(runner, Int32_Equals(i32, (Obj*)i32_dupe), - "Integer32 Clone"); - TEST_TRUE(runner, Int64_Equals(i64, (Obj*)i64_dupe), - "Integer64 Clone"); - TEST_TRUE(runner, Bool_Equals(CFISH_TRUE, (Obj*)Bool_Clone(CFISH_TRUE)), - "BoolNum Clone"); + OK(Float32_Equals(f32, (Obj*)f32_dupe), "Float32 Clone"); + OK(Float64_Equals(f64, (Obj*)f64_dupe), "Float64 Clone"); + OK(Int32_Equals(i32, (Obj*)i32_dupe), "Integer32 Clone"); + OK(Int64_Equals(i64, (Obj*)i64_dupe), "Integer64 Clone"); + OK(Bool_Equals(CFISH_TRUE, (Obj*)Bool_Clone(CFISH_TRUE)), + "BoolNum Clone"); DECREF(i64_dupe); DECREF(i32_dupe); DECREF(f64_dupe); @@ -254,14 +238,10 @@ Float64_Mimic(f64_dupe, (Obj*)f64); Int32_Mimic(i32_dupe, (Obj*)i32); Int64_Mimic(i64_dupe, (Obj*)i64); - TEST_TRUE(runner, Float32_Equals(f32, (Obj*)f32_dupe), - "Float32 Mimic"); - TEST_TRUE(runner, Float64_Equals(f64, (Obj*)f64_dupe), - "Float64 Mimic"); - TEST_TRUE(runner, Int32_Equals(i32, (Obj*)i32_dupe), - "Integer32 Mimic"); - TEST_TRUE(runner, Int64_Equals(i64, (Obj*)i64_dupe), - "Integer64 Mimic"); + OK(Float32_Equals(f32, (Obj*)f32_dupe), "Float32 Mimic"); + OK(Float64_Equals(f64, (Obj*)f64_dupe), "Float64 Mimic"); + OK(Int32_Equals(i32, (Obj*)i32_dupe), "Integer32 Mimic"); + OK(Int64_Equals(i64, (Obj*)i64_dupe), "Integer64 Mimic"); DECREF(i64_dupe); DECREF(i32_dupe); DECREF(f64_dupe);
diff --git a/runtime/core/Clownfish/Test/TestObj.c b/runtime/core/Clownfish/Test/TestObj.c index 63e2bae..836225f 100644 --- a/runtime/core/Clownfish/Test/TestObj.c +++ b/runtime/core/Clownfish/Test/TestObj.c
@@ -67,7 +67,7 @@ test_To_String(TestBatchRunner *runner) { Obj *testobj = S_new_testobj(); String *string = Obj_To_String(testobj); - TEST_TRUE(runner, Str_Find_Utf8(string, "TestObj", 7) >= 0, "To_String"); + OK(Str_Find_Utf8(string, "TestObj", 7) >= 0, "To_String"); DECREF(string); DECREF(testobj); } @@ -77,8 +77,7 @@ Obj *testobj = S_new_testobj(); Obj *other = S_new_testobj(); - TEST_TRUE(runner, Obj_Equals(testobj, testobj), - "Equals is true for the same object"); + OK(Obj_Equals(testobj, testobj), "Equals is true for the same object"); TEST_FALSE(runner, Obj_Equals(testobj, other), "Distinct objects are not equal"); @@ -91,8 +90,7 @@ Obj *testobj = S_new_testobj(); int64_t address64 = PTR_TO_I64(testobj); int32_t address32 = (int32_t)address64; - TEST_TRUE(runner, (Obj_Hash_Sum(testobj) == address32), - "Hash_Sum uses memory address"); + OK((Obj_Hash_Sum(testobj) == address32), "Hash_Sum uses memory address"); DECREF(testobj); } @@ -102,11 +100,10 @@ VTable *str_vtable = Str_Get_VTable(string); String *klass = Str_Get_Class_Name(string); - TEST_TRUE(runner, Str_Is_A(string, STRING), "String Is_A String."); - TEST_TRUE(runner, Str_Is_A(string, OBJ), "String Is_A Obj."); - TEST_TRUE(runner, str_vtable == STRING, "Get_VTable"); - TEST_TRUE(runner, Str_Equals(VTable_Get_Name(STRING), (Obj*)klass), - "Get_Class_Name"); + OK(Str_Is_A(string, STRING), "String Is_A String."); + OK(Str_Is_A(string, OBJ), "String Is_A Obj."); + OK(str_vtable == STRING, "Get_VTable"); + OK(Str_Equals(VTable_Get_Name(STRING), (Obj*)klass), "Get_Class_Name"); DECREF(string); } @@ -147,10 +144,10 @@ char message[100]; sprintf(message, "%s() is abstract", name); Err *error = Err_trap(routine, context); - TEST_TRUE(runner, error != NULL - && Err_Is_A(error, ERR) - && Str_Find_Utf8(Err_Get_Mess(error), "bstract", 7) != -1, - message); + OK(error != NULL + && Err_Is_A(error, ERR) + && Str_Find_Utf8(Err_Get_Mess(error), "bstract", 7) != -1, + message); DECREF(error); }
diff --git a/runtime/core/Clownfish/Test/TestString.c b/runtime/core/Clownfish/Test/TestString.c index 634154a..5dda883 100644 --- a/runtime/core/Clownfish/Test/TestString.c +++ b/runtime/core/Clownfish/Test/TestString.c
@@ -80,19 +80,19 @@ source = S_get_str(""); got = Str_Cat(source, wanted); - TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat"); + OK(Str_Equals(wanted, (Obj*)got), "Cat"); DECREF(got); DECREF(source); source = S_get_str("a"); got = Str_Cat_Utf8(source, smiley, smiley_len); - TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Utf8"); + OK(Str_Equals(wanted, (Obj*)got), "Cat_Utf8"); DECREF(got); DECREF(source); source = S_get_str("a"); got = Str_Cat_Trusted_Utf8(source, smiley, smiley_len); - TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Trusted_Utf8"); + OK(Str_Equals(wanted, (Obj*)got), "Cat_Trusted_Utf8"); DECREF(got); DECREF(source); @@ -105,7 +105,7 @@ String *got = S_get_str("bar"); got = Str_Clone(wanted); - TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Clone"); + OK(Str_Equals(wanted, (Obj*)got), "Clone"); DECREF(got); DECREF(wanted); @@ -117,22 +117,22 @@ String *substring = S_get_str("foo"); string = S_get_str(""); - TEST_TRUE(runner, Str_Find(string, substring) == -1, "Not in empty string"); + OK(Str_Find(string, substring) == -1, "Not in empty string"); DECREF(string); string = S_get_str("foo"); - TEST_TRUE(runner, Str_Find(string, substring) == 0, "Find complete string"); + OK(Str_Find(string, substring) == 0, "Find complete string"); DECREF(string); string = S_get_str("afoo"); - TEST_TRUE(runner, Str_Find(string, substring) == 1, "Find after first"); + OK(Str_Find(string, substring) == 1, "Find after first"); // TODO: Enable this test when we have real substrings. /*Str_Set_Size(string, 3); - TEST_TRUE(runner, Str_Find(string, substring) == -1, "Don't overrun");*/ + OK(Str_Find(string, substring) == -1, "Don't overrun");*/ DECREF(string); string = S_get_str("afood"); - TEST_TRUE(runner, Str_Find(string, substring) == 1, "Find in middle"); + OK(Str_Find(string, substring) == 1, "Find in middle"); DECREF(string); DECREF(substring); @@ -163,7 +163,7 @@ String *string = Str_newf("a%s%sb%sc", smiley, smiley, smiley); String *wanted = Str_newf("%sb%s", smiley, smiley); String *got = Str_SubString(string, 2, 3); - TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "SubString"); + OK(Str_Equals(wanted, (Obj*)got), "SubString"); DECREF(wanted); DECREF(got); DECREF(string); @@ -178,44 +178,41 @@ String *got; got = Str_Trim(ws_smiley); - TEST_TRUE(runner, Str_Equals_Utf8(got, smiley, smiley_len), "Trim"); + OK(Str_Equals_Utf8(got, smiley, smiley_len), "Trim"); DECREF(got); got = Str_Trim_Top(ws_foo); - TEST_TRUE(runner, Str_Equals_Utf8(got, "foo ", 5), "Trim_Top"); + OK(Str_Equals_Utf8(got, "foo ", 5), "Trim_Top"); DECREF(got); got = Str_Trim_Tail(ws_foo); - TEST_TRUE(runner, Str_Equals_Utf8(got, " foo", 5), "Trim_Tail"); + OK(Str_Equals_Utf8(got, " foo", 5), "Trim_Tail"); DECREF(got); got = Str_Trim(ws_only); - TEST_TRUE(runner, Str_Equals_Utf8(got, "", 0), "Trim with only whitespace"); + OK(Str_Equals_Utf8(got, "", 0), "Trim with only whitespace"); DECREF(got); got = Str_Trim_Top(ws_only); - TEST_TRUE(runner, Str_Equals_Utf8(got, "", 0), - "Trim_Top with only whitespace"); + OK(Str_Equals_Utf8(got, "", 0), "Trim_Top with only whitespace"); DECREF(got); got = Str_Trim_Tail(ws_only); - TEST_TRUE(runner, Str_Equals_Utf8(got, "", 0), - "Trim_Tail with only whitespace"); + OK(Str_Equals_Utf8(got, "", 0), "Trim_Tail with only whitespace"); DECREF(got); got = Str_Trim(trimmed); - TEST_TRUE(runner, Str_Equals(got, (Obj*)trimmed), - "Trim doesn't change trimmed string"); + OK(Str_Equals(got, (Obj*)trimmed), "Trim doesn't change trimmed string"); DECREF(got); got = Str_Trim_Top(trimmed); - TEST_TRUE(runner, Str_Equals(got, (Obj*)trimmed), - "Trim_Top doesn't change trimmed string"); + OK(Str_Equals(got, (Obj*)trimmed), + "Trim_Top doesn't change trimmed string"); DECREF(got); got = Str_Trim_Tail(trimmed); - TEST_TRUE(runner, Str_Equals(got, (Obj*)trimmed), - "Trim_Tail doesn't change trimmed string"); + OK(Str_Equals(got, (Obj*)trimmed), + "Trim_Tail doesn't change trimmed string"); DECREF(got); DECREF(trimmed); @@ -231,13 +228,13 @@ string = S_get_str("1.5"); double difference = 1.5 - Str_To_F64(string); if (difference < 0) { difference = 0 - difference; } - TEST_TRUE(runner, difference < 0.001, "To_F64"); + OK(difference < 0.001, "To_F64"); DECREF(string); string = S_get_str("-1.5"); difference = 1.5 + Str_To_F64(string); if (difference < 0) { difference = 0 - difference; } - TEST_TRUE(runner, difference < 0.001, "To_F64 negative"); + OK(difference < 0.001, "To_F64 negative"); DECREF(string); // TODO: Enable this test when we have real substrings. @@ -245,8 +242,7 @@ double value_full = Str_To_F64(string); Str_Set_Size(string, 3); double value_short = Str_To_F64(string); - TEST_TRUE(runner, value_short < value_full, - "TO_F64 doesn't run past end of string"); + OK(value_short < value_full, "TO_F64 doesn't run past end of string"); DECREF(string);*/ } @@ -255,11 +251,11 @@ String *string; string = S_get_str("10"); - TEST_TRUE(runner, Str_To_I64(string) == 10, "To_I64"); + OK(Str_To_I64(string) == 10, "To_I64"); DECREF(string); string = S_get_str("-10"); - TEST_TRUE(runner, Str_To_I64(string) == -10, "To_I64 negative"); + OK(Str_To_I64(string) == -10, "To_I64 negative"); DECREF(string); } @@ -267,8 +263,7 @@ test_To_Utf8(TestBatchRunner *runner) { String *string = Str_newf("a%s%sb%sc", smiley, smiley, smiley); char *buf = Str_To_Utf8(string); - TEST_TRUE(runner, strcmp(buf, "a" SMILEY SMILEY "b" SMILEY "c") == 0, - "To_Utf8"); + OK(strcmp(buf, "a" SMILEY SMILEY "b" SMILEY "c") == 0, "To_Utf8"); FREEMEM(buf); DECREF(string); } @@ -286,16 +281,11 @@ String *ab = Str_newf("a%s%sb", smiley, smiley); String *ac = Str_newf("a%s%sc", smiley, smiley); - TEST_TRUE(runner, Str_Compare_To(abc, (Obj*)abc) == 0, - "Compare_To abc abc"); - TEST_TRUE(runner, Str_Compare_To(ab, (Obj*)abc) < 0, - "Compare_To ab abc"); - TEST_TRUE(runner, Str_Compare_To(abc, (Obj*)ab) > 0, - "Compare_To abc ab"); - TEST_TRUE(runner, Str_Compare_To(ab, (Obj*)ac) < 0, - "Compare_To ab ac"); - TEST_TRUE(runner, Str_Compare_To(ac, (Obj*)ab) > 0, - "Compare_To ac ab"); + OK(Str_Compare_To(abc, (Obj*)abc) == 0, "Compare_To abc abc"); + OK(Str_Compare_To(ab, (Obj*)abc) < 0, "Compare_To ab abc"); + OK(Str_Compare_To(abc, (Obj*)ab) > 0, "Compare_To abc ab"); + OK(Str_Compare_To(ab, (Obj*)ac) < 0, "Compare_To ab ac"); + OK(Str_Compare_To(ac, (Obj*)ab) > 0, "Compare_To ac ab"); DECREF(ac); DECREF(ab); @@ -307,7 +297,7 @@ String *source = S_get_str("aXXbXc"); String *got = Str_Swap_Chars(source, 'X', smiley_cp); String *wanted = Str_newf("a%s%sb%sc", smiley, smiley, smiley); - TEST_TRUE(runner, Str_Equals(got, (Obj*)wanted), "Swap_Chars"); + OK(Str_Equals(got, (Obj*)wanted), "Swap_Chars"); DECREF(wanted); DECREF(got); DECREF(source); @@ -346,10 +336,10 @@ "Compare_To top == top"); StringIterator *clone = StrIter_Clone(top); - TEST_TRUE(runner, StrIter_Equals(clone, (Obj*)top), "Clone"); + OK(StrIter_Equals(clone, (Obj*)top), "Clone"); StrIter_Assign(clone, tail); - TEST_TRUE(runner, StrIter_Equals(clone, (Obj*)tail), "Assign"); + OK(StrIter_Equals(clone, (Obj*)tail), "Assign"); DECREF(clone); DECREF(top); @@ -360,18 +350,17 @@ StringIterator *iter = Str_Top(string); for (size_t i = 0; i < num_code_points; ++i) { - TEST_TRUE(runner, StrIter_Has_Next(iter), "Has_Next %d", i); + OK(StrIter_Has_Next(iter), "Has_Next %d", i); int32_t code_point = StrIter_Next(iter); TEST_INT_EQ(runner, code_point, code_points[i], "Next %d", i); } - TEST_TRUE(runner, !StrIter_Has_Next(iter), - "Has_Next at end of string"); + OK(!StrIter_Has_Next(iter), "Has_Next at end of string"); TEST_INT_EQ(runner, StrIter_Next(iter), STRITER_DONE, "Next at end of string"); StringIterator *tail = Str_Tail(string); - TEST_TRUE(runner, StrIter_Equals(iter, (Obj*)tail), "Equals tail"); + OK(StrIter_Equals(iter, (Obj*)tail), "Equals tail"); DECREF(tail); DECREF(iter); @@ -381,18 +370,17 @@ StringIterator *iter = Str_Tail(string); for (int i = num_code_points - 1; i >= 0; --i) { - TEST_TRUE(runner, StrIter_Has_Prev(iter), "Has_Prev %d", i); + OK(StrIter_Has_Prev(iter), "Has_Prev %d", i); int32_t code_point = StrIter_Prev(iter); TEST_INT_EQ(runner, code_point, code_points[i], "Prev %d", i); } - TEST_TRUE(runner, !StrIter_Has_Prev(iter), - "Has_Prev at end of string"); + OK(!StrIter_Has_Prev(iter), "Has_Prev at end of string"); TEST_INT_EQ(runner, StrIter_Prev(iter), STRITER_DONE, "Prev at start of string"); StringIterator *top = Str_Top(string); - TEST_TRUE(runner, StrIter_Equals(iter, (Obj*)top), "Equals top"); + OK(StrIter_Equals(iter, (Obj*)top), "Equals top"); DECREF(top); DECREF(iter); @@ -460,8 +448,8 @@ { String *substring = StrIter_substring(start, end); - TEST_TRUE(runner, Str_Equals(substring, (Obj*)string), - "StrIter_substring whole string"); + OK(Str_Equals(substring, (Obj*)string), + "StrIter_substring whole string"); DECREF(substring); } @@ -471,11 +459,9 @@ { String *substring = StrIter_substring(start, end); String *wanted = Str_newf("b%sc", smiley); - TEST_TRUE(runner, Str_Equals(substring, (Obj*)wanted), - "StrIter_substring"); - - TEST_TRUE(runner, StrIter_Starts_With(start, wanted), "Starts_With"); - TEST_TRUE(runner, StrIter_Ends_With(end, wanted), "Ends_With"); + OK(Str_Equals(substring, (Obj*)wanted), "StrIter_substring"); + OK(StrIter_Starts_With(start, wanted), "Starts_With"); + OK(StrIter_Ends_With(end, wanted), "Ends_With"); DECREF(wanted); DECREF(substring); @@ -484,8 +470,8 @@ { String *substring = StrIter_substring(end, NULL); String *wanted = Str_newf("%sd", smiley); - TEST_TRUE(runner, Str_Equals(substring, (Obj*)wanted), - "StrIter_substring with NULL tail"); + OK(Str_Equals(substring, (Obj*)wanted), + "StrIter_substring with NULL tail"); DECREF(wanted); DECREF(substring); } @@ -493,8 +479,8 @@ { String *substring = StrIter_substring(NULL, start); String *wanted = Str_newf("a%s", smiley); - TEST_TRUE(runner, Str_Equals(substring, (Obj*)wanted), - "StrIter_substring with NULL top"); + OK(Str_Equals(substring, (Obj*)wanted), + "StrIter_substring with NULL top"); DECREF(wanted); DECREF(substring); }
diff --git a/runtime/core/Clownfish/Test/TestVArray.c b/runtime/core/Clownfish/Test/TestVArray.c index 06c1590..4d8787d 100644 --- a/runtime/core/Clownfish/Test/TestVArray.c +++ b/runtime/core/Clownfish/Test/TestVArray.c
@@ -43,24 +43,22 @@ VArray *other = VA_new(0); StackString *stuff = SSTR_WRAP_UTF8("stuff", 5); - TEST_TRUE(runner, VA_Equals(array, (Obj*)other), - "Empty arrays are equal"); + OK(VA_Equals(array, (Obj*)other), "Empty arrays are equal"); VA_Push(array, (Obj*)CFISH_TRUE); TEST_FALSE(runner, VA_Equals(array, (Obj*)other), "Add one elem and Equals returns false"); VA_Push(other, (Obj*)CFISH_TRUE); - TEST_TRUE(runner, VA_Equals(array, (Obj*)other), - "Add a matching elem and Equals returns true"); + OK(VA_Equals(array, (Obj*)other), + "Add a matching elem and Equals returns true"); VA_Store(array, 2, (Obj*)CFISH_TRUE); TEST_FALSE(runner, VA_Equals(array, (Obj*)other), "Add elem after a NULL and Equals returns false"); VA_Store(other, 2, (Obj*)CFISH_TRUE); - TEST_TRUE(runner, VA_Equals(array, (Obj*)other), - "Empty elems don't spoil Equals"); + OK(VA_Equals(array, (Obj*)other), "Empty elems don't spoil Equals"); VA_Store(other, 2, INCREF(stuff)); TEST_FALSE(runner, VA_Equals(array, (Obj*)other), @@ -81,12 +79,12 @@ VArray *array = VA_new(0); String *elem; - TEST_TRUE(runner, VA_Fetch(array, 2) == NULL, "Fetch beyond end"); + OK(VA_Fetch(array, 2) == NULL, "Fetch beyond end"); VA_Store(array, 2, (Obj*)Str_newf("foo")); elem = (String*)CERTIFY(VA_Fetch(array, 2), STRING); TEST_INT_EQ(runner, 3, VA_Get_Size(array), "Store updates size"); - TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Store"); + OK(Str_Equals_Utf8(elem, "foo", 3), "Store"); elem = (String*)INCREF(elem); TEST_INT_EQ(runner, 2, Str_Get_RefCount(elem), @@ -96,7 +94,7 @@ "Displacing elem via Store updates refcount"); DECREF(elem); elem = (String*)CERTIFY(VA_Fetch(array, 2), STRING); - TEST_TRUE(runner, Str_Equals_Utf8(elem, "bar", 3), "Store displacement"); + OK(Str_Equals_Utf8(elem, "bar", 3), "Store displacement"); DECREF(array); } @@ -112,21 +110,21 @@ VA_Push(array, (Obj*)Str_newf("c")); TEST_INT_EQ(runner, VA_Get_Size(array), 3, "size after Push"); - TEST_TRUE(runner, NULL != CERTIFY(VA_Fetch(array, 2), STRING), "Push"); + OK(NULL != CERTIFY(VA_Fetch(array, 2), STRING), "Push"); elem = (String*)CERTIFY(VA_Shift(array), STRING); - TEST_TRUE(runner, Str_Equals_Utf8(elem, "a", 1), "Shift"); + OK(Str_Equals_Utf8(elem, "a", 1), "Shift"); TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Shift"); DECREF(elem); elem = (String*)CERTIFY(VA_Pop(array), STRING); - TEST_TRUE(runner, Str_Equals_Utf8(elem, "c", 1), "Pop"); + OK(Str_Equals_Utf8(elem, "c", 1), "Pop"); TEST_INT_EQ(runner, VA_Get_Size(array), 1, "size after Pop"); DECREF(elem); VA_Unshift(array, (Obj*)Str_newf("foo")); elem = (String*)CERTIFY(VA_Fetch(array, 0), STRING); - TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Unshift"); + OK(Str_Equals_Utf8(elem, "foo", 3), "Unshift"); TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Shift"); DECREF(array); @@ -144,7 +142,7 @@ VA_Store(wanted, 4, (Obj*)Str_newf("4", i)); DECREF(VA_Delete(got, 2)); DECREF(VA_Delete(got, 3)); - TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), "Delete"); + OK(VA_Equals(wanted, (Obj*)got), "Delete"); DECREF(wanted); DECREF(got); @@ -165,7 +163,7 @@ VA_Resize(array, 2); TEST_INT_EQ(runner, VA_Get_Size(array), 2, "Resize down"); - TEST_TRUE(runner, VA_Fetch(array, 2) == NULL, "Resize down zaps elem"); + OK(VA_Fetch(array, 2) == NULL, "Resize down zaps elem"); DECREF(array); } @@ -181,27 +179,23 @@ } VA_Excise(got, 7, 1); - TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), - "Excise outside of range is no-op"); + OK(VA_Equals(wanted, (Obj*)got), "Excise outside of range is no-op"); VA_Excise(got, 2, 2); DECREF(VA_Delete(wanted, 2)); DECREF(VA_Delete(wanted, 3)); VA_Store(wanted, 2, VA_Delete(wanted, 4)); VA_Resize(wanted, 3); - TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), - "Excise multiple elems"); + OK(VA_Equals(wanted, (Obj*)got), "Excise multiple elems"); VA_Excise(got, 2, 2); VA_Resize(wanted, 2); - TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), - "Splicing too many elems truncates"); + OK(VA_Equals(wanted, (Obj*)got), "Splicing too many elems truncates"); VA_Excise(got, 0, 1); VA_Store(wanted, 0, VA_Delete(wanted, 1)); VA_Resize(wanted, 1); - TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), - "Excise first elem"); + OK(VA_Equals(wanted, (Obj*)got), "Excise first elem"); DECREF(got); DECREF(wanted); @@ -219,7 +213,7 @@ for (i = 2; i < 4; i++) { VA_Push(scratch, (Obj*)Str_newf("%u32", i)); } VA_Push_VArray(got, scratch); - TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), "Push_VArray"); + OK(VA_Equals(wanted, (Obj*)got), "Push_VArray"); DECREF(wanted); DECREF(got); @@ -232,39 +226,37 @@ for (uint32_t i = 0; i < 10; i++) { VA_Push(array, (Obj*)Str_newf("%u32", i)); } { VArray *slice = VA_Slice(array, 0, 10); - TEST_TRUE(runner, VA_Equals(array, (Obj*)slice), "Slice entire array"); + OK(VA_Equals(array, (Obj*)slice), "Slice entire array"); DECREF(slice); } { VArray *slice = VA_Slice(array, 0, 11); - TEST_TRUE(runner, VA_Equals(array, (Obj*)slice), - "Exceed length"); + OK(VA_Equals(array, (Obj*)slice), "Exceed length"); DECREF(slice); } { VArray *wanted = VA_new(0); VA_Push(wanted, (Obj*)Str_newf("9")); VArray *slice = VA_Slice(array, 9, 11); - TEST_TRUE(runner, VA_Equals(slice, (Obj*)wanted), - "Exceed length, start near end"); + OK(VA_Equals(slice, (Obj*)wanted), "Exceed length, start near end"); DECREF(slice); DECREF(wanted); } { VArray *slice = VA_Slice(array, 0, 0); - TEST_TRUE(runner, VA_Get_Size(slice) == 0, "empty slice"); + OK(VA_Get_Size(slice) == 0, "empty slice"); DECREF(slice); } { VArray *slice = VA_Slice(array, 20, 1); - TEST_TRUE(runner, VA_Get_Size(slice) == 0, "exceed offset"); + OK(VA_Get_Size(slice) == 0, "exceed offset"); DECREF(slice); } { VArray *wanted = VA_new(0); VA_Push(wanted, (Obj*)Str_newf("9")); VArray *slice = VA_Slice(array, 9, UINT32_MAX - 1); - TEST_TRUE(runner, VA_Get_Size(slice) == 1, "guard against overflow"); + OK(VA_Get_Size(slice) == 1, "guard against overflow"); DECREF(slice); DECREF(wanted); } @@ -281,15 +273,14 @@ VA_Push(array, (Obj*)Int32_new(i)); } twin = VA_Shallow_Copy(array); - TEST_TRUE(runner, VA_Equals(array, (Obj*)twin), "Shallow_Copy"); - TEST_TRUE(runner, VA_Fetch(array, 1) == VA_Fetch(twin, 1), - "Shallow_Copy doesn't clone elements"); + OK(VA_Equals(array, (Obj*)twin), "Shallow_Copy"); + OK(VA_Fetch(array, 1) == VA_Fetch(twin, 1), + "Shallow_Copy doesn't clone elements"); DECREF(twin); twin = VA_Clone(array); - TEST_TRUE(runner, VA_Equals(array, (Obj*)twin), "Clone"); - TEST_TRUE(runner, VA_Fetch(array, 1) != VA_Fetch(twin, 1), - "Clone performs deep clone"); + OK(VA_Equals(array, (Obj*)twin), "Clone"); + OK(VA_Fetch(array, 1) != VA_Fetch(twin, 1), "Clone performs deep clone"); DECREF(array); DECREF(twin);
diff --git a/runtime/core/Clownfish/Test/Util/TestAtomic.c b/runtime/core/Clownfish/Test/Util/TestAtomic.c index 320ff91..845e6b2 100644 --- a/runtime/core/Clownfish/Test/Util/TestAtomic.c +++ b/runtime/core/Clownfish/Test/Util/TestAtomic.c
@@ -37,23 +37,21 @@ int *bar_pointer = &bar; int *target = NULL; - TEST_TRUE(runner, - Atomic_cas_ptr((void**)&target, NULL, foo_pointer), - "cas_ptr returns true on success"); - TEST_TRUE(runner, target == foo_pointer, "cas_ptr sets target"); + OK(Atomic_cas_ptr((void**)&target, NULL, foo_pointer), + "cas_ptr returns true on success"); + OK(target == foo_pointer, "cas_ptr sets target"); target = NULL; TEST_FALSE(runner, Atomic_cas_ptr((void**)&target, bar_pointer, foo_pointer), "cas_ptr returns false when it old_value doesn't match"); - TEST_TRUE(runner, target == NULL, - "cas_ptr doesn't do anything to target when old_value doesn't match"); + OK(target == NULL, + "cas_ptr doesn't do anything to target when old_value doesn't match"); target = foo_pointer; - TEST_TRUE(runner, - Atomic_cas_ptr((void**)&target, foo_pointer, bar_pointer), - "cas_ptr from one value to another"); - TEST_TRUE(runner, target == bar_pointer, "cas_ptr sets target"); + OK(Atomic_cas_ptr((void**)&target, foo_pointer, bar_pointer), + "cas_ptr from one value to another"); + OK(target == bar_pointer, "cas_ptr sets target"); } void
diff --git a/runtime/core/Clownfish/Test/Util/TestMemory.c b/runtime/core/Clownfish/Test/Util/TestMemory.c index 1878242..9513251 100644 --- a/runtime/core/Clownfish/Test/Util/TestMemory.c +++ b/runtime/core/Clownfish/Test/Util/TestMemory.c
@@ -62,19 +62,19 @@ } size = next_size; } - TEST_TRUE(runner, growth_count > 0, "Grew %f times", growth_count); + OK(growth_count > 0, "Grew %f times", growth_count); if (success) { - TEST_TRUE(runner, average_growth_rate > 1.1, - "Growth rate of oversize() averages above 1.1: %.3f", - average_growth_rate); + OK(average_growth_rate > 1.1, + "Growth rate of oversize() averages above 1.1: %.3f", + average_growth_rate); } for (int minimum = 1; minimum < 8; minimum++) { uint64_t next_size = Memory_oversize(minimum, sizeof(void*)); double growth_rate = U64_TO_DOUBLE(next_size) / (double)minimum; - TEST_TRUE(runner, growth_rate > 1.2, - "Growth rate is higher for smaller arrays (%d, %.3f)", minimum, - growth_rate); + OK(growth_rate > 1.2, + "Growth rate is higher for smaller arrays (%d, %.3f)", minimum, + growth_rate); } } @@ -82,11 +82,11 @@ test_oversize__ceiling(TestBatchRunner *runner) { for (int width = 0; width < 10; width++) { size_t size = Memory_oversize(SIZE_MAX, width); - TEST_TRUE(runner, size == SIZE_MAX, - "Memory_oversize hits ceiling at SIZE_MAX (width %d)", width); + OK(size == SIZE_MAX, + "Memory_oversize hits ceiling at SIZE_MAX (width %d)", width); size = Memory_oversize(SIZE_MAX - 1, width); - TEST_TRUE(runner, size == SIZE_MAX, - "Memory_oversize hits ceiling at SIZE_MAX (width %d)", width); + OK(size == SIZE_MAX, + "Memory_oversize hits ceiling at SIZE_MAX (width %d)", width); } }
diff --git a/runtime/core/Clownfish/Test/Util/TestNumberUtils.c b/runtime/core/Clownfish/Test/Util/TestNumberUtils.c index 5840c34..538c5ac 100644 --- a/runtime/core/Clownfish/Test/Util/TestNumberUtils.c +++ b/runtime/core/Clownfish/Test/Util/TestNumberUtils.c
@@ -126,16 +126,16 @@ NumUtil_skip_cint(&skip); if (target > limit) { THROW(ERR, "overrun"); } } - TEST_TRUE(runner, skip == target, "skip %lu == %lu", - (unsigned long)skip, (unsigned long)target); + OK(skip == target, "skip %lu == %lu", + (unsigned long)skip, (unsigned long)target); target = encoded; for (size_t i = 0; i < count; i++) { NumUtil_encode_padded_c32((uint32_t)ints[i], &target); } - TEST_TRUE(runner, target == limit, - "padded c32 uses 5 bytes (%lu == %lu)", (unsigned long)target, - (unsigned long)limit); + OK(target == limit, + "padded c32 uses 5 bytes (%lu == %lu)", (unsigned long)target, + (unsigned long)limit); target = encoded; skip = encoded; for (size_t i = 0; i < count; i++) { @@ -144,8 +144,8 @@ NumUtil_skip_cint(&skip); if (target > limit) { THROW(ERR, "overrun"); } } - TEST_TRUE(runner, skip == target, "skip padded %lu == %lu", - (unsigned long)skip, (unsigned long)target); + OK(skip == target, "skip padded %lu == %lu", + (unsigned long)skip, (unsigned long)target); } target = encoded; @@ -182,13 +182,12 @@ skip = encoded; for (size_t i = 0; i < count; i++) { uint64_t got = NumUtil_decode_c64(&target); - TEST_TRUE(runner, got == ints[i], - "c64 %" PRIu64 " == %" PRIu64, got, ints[i]); + OK(got == ints[i], "c64 %" PRIu64 " == %" PRIu64, got, ints[i]); if (target > limit) { THROW(ERR, "overrun"); } NumUtil_skip_cint(&skip); } - TEST_TRUE(runner, skip == target, "skip %lu == %lu", - (unsigned long)skip, (unsigned long)target); + OK(skip == target, "skip %lu == %lu", + (unsigned long)skip, (unsigned long)target); } target = encoded; @@ -196,7 +195,7 @@ target = encoded; uint64_t got = NumUtil_decode_c64(&target); - TEST_TRUE(runner, got == UINT64_MAX, "c64 UINT64_MAX"); + OK(got == UINT64_MAX, "c64 UINT64_MAX"); FREEMEM(encoded); FREEMEM(ints); @@ -276,7 +275,7 @@ target = encoded; for (size_t i = 0; i < count; i++) { uint64_t got = NumUtil_decode_bigend_u64(target); - TEST_TRUE(runner, got == ints[i], "bigend u64"); + OK(got == ints[i], "bigend u64"); target += sizeof(uint64_t); } @@ -305,7 +304,7 @@ target = encoded; for (size_t i = 0; i < count; i++) { float got = NumUtil_decode_bigend_f32(target); - TEST_TRUE(runner, got == source[i], "bigend f32"); + OK(got == source[i], "bigend f32"); target += sizeof(float); } @@ -339,7 +338,7 @@ target = encoded; for (size_t i = 0; i < count; i++) { double got = NumUtil_decode_bigend_f64(target); - TEST_TRUE(runner, got == source[i], "bigend f64"); + OK(got == source[i], "bigend f64"); target += sizeof(double); }
diff --git a/runtime/core/Clownfish/Test/Util/TestStringHelper.c b/runtime/core/Clownfish/Test/Util/TestStringHelper.c index 339de02..7bdf57a 100644 --- a/runtime/core/Clownfish/Test/Util/TestStringHelper.c +++ b/runtime/core/Clownfish/Test/Util/TestStringHelper.c
@@ -201,7 +201,7 @@ FAIL(runner, "Disagreement: %s", description); } else { - TEST_TRUE(runner, sane == expected, "%s", description); + OK(sane == expected, "%s", description); } } @@ -258,13 +258,12 @@ static void test_is_whitespace(TestBatchRunner *runner) { - TEST_TRUE(runner, StrHelp_is_whitespace(' '), "space is whitespace"); - TEST_TRUE(runner, StrHelp_is_whitespace('\n'), "newline is whitespace"); - TEST_TRUE(runner, StrHelp_is_whitespace('\t'), "tab is whitespace"); - TEST_TRUE(runner, StrHelp_is_whitespace('\v'), - "vertical tab is whitespace"); - TEST_TRUE(runner, StrHelp_is_whitespace(0x180E), - "Mongolian vowel separator is whitespace"); + OK(StrHelp_is_whitespace(' '), "space is whitespace"); + OK(StrHelp_is_whitespace('\n'), "newline is whitespace"); + OK(StrHelp_is_whitespace('\t'), "tab is whitespace"); + OK(StrHelp_is_whitespace('\v'), "vertical tab is whitespace"); + OK(StrHelp_is_whitespace(0x180E), + "Mongolian vowel separator is whitespace"); TEST_FALSE(runner, StrHelp_is_whitespace('a'), "'a' isn't whitespace"); TEST_FALSE(runner, StrHelp_is_whitespace(0), "NULL isn't whitespace"); TEST_FALSE(runner, StrHelp_is_whitespace(0x263A), @@ -277,12 +276,11 @@ char *buf = buffer + 1; uint32_t len = StrHelp_encode_utf8_char(0x263A, buffer); char *end = buffer + len; - TEST_TRUE(runner, StrHelp_back_utf8_char(end, buffer) == buffer, - "back_utf8_char"); - TEST_TRUE(runner, StrHelp_back_utf8_char(end, buf) == NULL, - "back_utf8_char returns NULL rather than back up beyond start"); - TEST_TRUE(runner, StrHelp_back_utf8_char(buffer, buffer) == NULL, - "back_utf8_char returns NULL when end == start"); + OK(StrHelp_back_utf8_char(end, buffer) == buffer, "back_utf8_char"); + OK(StrHelp_back_utf8_char(end, buf) == NULL, + "back_utf8_char returns NULL rather than back up beyond start"); + OK(StrHelp_back_utf8_char(buffer, buffer) == NULL, + "back_utf8_char returns NULL when end == start"); } void