lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [1/6] lucy-clownfish git commit: Implement CB_Clear
Date Thu, 12 Nov 2015 13:14:48 GMT
Repository: lucy-clownfish
Updated Branches:
  refs/heads/master cada6ca96 -> 71ea0c573


Implement CB_Clear


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

Branch: refs/heads/master
Commit: 3571968857f91a0028f4ef7f56ce0bdd92ac54ba
Parents: ae8edad
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Nov 10 13:11:43 2015 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Thu Nov 12 14:08:17 2015 +0100

----------------------------------------------------------------------
 runtime/core/Clownfish/CharBuf.c          |  5 +++++
 runtime/core/Clownfish/CharBuf.cfh        |  5 +++++
 runtime/core/Clownfish/Test/TestCharBuf.c | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/35719688/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/CharBuf.c b/runtime/core/Clownfish/CharBuf.c
index e5e3aa2..6e54910 100644
--- a/runtime/core/Clownfish/CharBuf.c
+++ b/runtime/core/Clownfish/CharBuf.c
@@ -389,6 +389,11 @@ CB_Cat_IMP(CharBuf *self, String *string) {
 }
 
 void
+CB_Clear_IMP(CharBuf *self) {
+    self->size = 0;
+}
+
+void
 CB_Set_Size_IMP(CharBuf *self, size_t size) {
     if (size >= self->cap) {
         THROW(ERR, "Can't set size of CharBuf beyond capacity");

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/35719688/runtime/core/Clownfish/CharBuf.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/CharBuf.cfh b/runtime/core/Clownfish/CharBuf.cfh
index 788c0d4..0112ae8 100644
--- a/runtime/core/Clownfish/CharBuf.cfh
+++ b/runtime/core/Clownfish/CharBuf.cfh
@@ -117,6 +117,11 @@ final class Clownfish::CharBuf nickname CB
     char*
     Grow(CharBuf *self, size_t size);
 
+    /** Clear the CharBuf.
+     */
+    void
+    Clear(CharBuf *self);
+
     /** Set the CharBuf's `size` attribute.
      */
     void

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/35719688/runtime/core/Clownfish/Test/TestCharBuf.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestCharBuf.c b/runtime/core/Clownfish/Test/TestCharBuf.c
index 30d8c11..5763e99 100644
--- a/runtime/core/Clownfish/Test/TestCharBuf.c
+++ b/runtime/core/Clownfish/Test/TestCharBuf.c
@@ -323,9 +323,20 @@ test_vcatf_x32(TestBatchRunner *runner) {
     DECREF(got);
 }
 
+static void
+test_Clear(TestBatchRunner *runner) {
+    CharBuf *cb = S_get_cb("foo");
+    CB_Clear(cb);
+    CB_Cat_Utf8(cb, "bar", 3);
+    String *string = CB_Yield_String(cb);
+    TEST_TRUE(runner, Str_Equals_Utf8(string, "bar", 3), "Clear");
+    DECREF(string);
+    DECREF(cb);
+}
+
 void
 TestCB_Run_IMP(TestCharBuf *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 26);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 27);
     test_new(runner);
     test_vcatf_percent(runner);
     test_vcatf_s(runner);
@@ -344,5 +355,6 @@ TestCB_Run_IMP(TestCharBuf *self, TestBatchRunner *runner) {
     test_Cat(runner);
     test_Mimic_and_Clone(runner);
     test_Get_Ptr8(runner);
+    test_Clear(runner);
 }
 


Mime
View raw message