lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [2/6] lucy-clownfish git commit: Improve CharBuf test coverage
Date Sun, 26 Apr 2015 10:00:11 GMT
Improve CharBuf test coverage


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/765f8962
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/765f8962
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/765f8962

Branch: refs/heads/master
Commit: 765f89629b2442f47e201663c51e3fac3fb1c999
Parents: 4fcc536
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Aug 9 23:01:29 2014 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Apr 26 11:55:39 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Test/TestCharBuf.c | 51 +++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/765f8962/runtime/core/Clownfish/Test/TestCharBuf.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestCharBuf.c b/runtime/core/Clownfish/Test/TestCharBuf.c
index 39cb09c..22a60aa 100644
--- a/runtime/core/Clownfish/Test/TestCharBuf.c
+++ b/runtime/core/Clownfish/Test/TestCharBuf.c
@@ -59,6 +59,25 @@ S_cb_equals(CharBuf *cb, String *other) {
 }
 
 static void
+test_new(TestBatchRunner *runner) {
+    {
+        String  *str = Str_newf("CharBuf from String");
+        CharBuf *cb  = CB_new_from_str(str);
+        TEST_TRUE(runner, S_cb_equals(cb, str), "CB_new_from_str");
+        DECREF(str);
+        DECREF(cb);
+    }
+
+    {
+        CharBuf *cb     = CB_newf("%i32 %s", 99, "Luftballons");
+        String  *wanted = Str_newf("99 Luftballons");
+        TEST_TRUE(runner, S_cb_equals(cb, wanted), "CB_newf");
+        DECREF(cb);
+        DECREF(wanted);
+    }
+}
+
+static void
 test_Cat(TestBatchRunner *runner) {
     String  *wanted = Str_newf("a%s", smiley);
     CharBuf *got    = S_get_cb("");
@@ -113,6 +132,23 @@ test_Mimic_and_Clone(TestBatchRunner *runner) {
     DECREF(wanted_cb);
 }
 
+static void
+test_Get_Ptr8(TestBatchRunner *runner) {
+    CharBuf *cb = CB_new(64);
+
+    char *ptr8 = CB_Get_Ptr8(cb);
+    strcpy(ptr8, "0123456789");
+    CB_Set_Size(cb, 10);
+
+    TEST_INT_EQ(runner, CB_Get_Size(cb), 10, "Set_Size/Get_Size");
+
+    String *wanted = S_get_str("0123456789");
+    TEST_TRUE(runner, S_cb_equals(cb, wanted), "Get_Ptr8");
+
+    DECREF(cb);
+    DECREF(wanted);
+}
+
 /*
 static void
 test_Truncate(TestBatchRunner *runner) {
@@ -126,6 +162,16 @@ test_Truncate(TestBatchRunner *runner) {
 */
 
 static void
+test_vcatf_percent(TestBatchRunner *runner) {
+    String  *wanted = S_get_str("foo % bar");
+    CharBuf *got = S_get_cb("foo");
+    CB_catf(got, " %% bar");
+    TEST_TRUE(runner, S_cb_equals(got, wanted), "%%%%");
+    DECREF(wanted);
+    DECREF(got);
+}
+
+static void
 test_vcatf_s(TestBatchRunner *runner) {
     String  *wanted = S_get_str("foo bar bizzle baz");
     CharBuf *got = S_get_cb("foo ");
@@ -279,7 +325,9 @@ test_vcatf_x32(TestBatchRunner *runner) {
 
 void
 TestCB_Run_IMP(TestCharBuf *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 21);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 26);
+    test_new(runner);
+    test_vcatf_percent(runner);
     test_vcatf_s(runner);
     test_vcatf_null_string(runner);
     test_vcatf_str(runner);
@@ -295,5 +343,6 @@ TestCB_Run_IMP(TestCharBuf *self, TestBatchRunner *runner) {
     test_vcatf_x32(runner);
     test_Cat(runner);
     test_Mimic_and_Clone(runner);
+    test_Get_Ptr8(runner);
 }
 


Mime
View raw message