lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [08/15] git commit: refs/heads/cfish-string-prep1 - Eliminate Str_Cat_Char in TestString
Date Mon, 02 Sep 2013 19:16:39 GMT
Eliminate Str_Cat_Char in TestString


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

Branch: refs/heads/cfish-string-prep1
Commit: 6b1837e673178d8be613b713992c1026c9e4b640
Parents: b38218a
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Sep 2 21:05:41 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Sep 2 21:12:30 2013 +0200

----------------------------------------------------------------------
 .../runtime/core/Clownfish/Test/TestString.c    | 22 ++++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/6b1837e6/clownfish/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestString.c b/clownfish/runtime/core/Clownfish/Test/TestString.c
index a3da8ce..5a594a4 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -26,6 +26,7 @@
 #include "Clownfish/Test/TestString.h"
 
 #include "Clownfish/String.h"
+#include "Clownfish/CharBuf.h"
 #include "Clownfish/Num.h"
 #include "Clownfish/Test.h"
 #include "Clownfish/TestHarness/TestBatchRunner.h"
@@ -192,13 +193,15 @@ test_Trim(TestBatchRunner *runner) {
     };
     uint32_t num_spaces = sizeof(spaces) / sizeof(uint32_t);
     uint32_t i;
-    String *got = Str_new(0);
+    String *got;
 
     // Surround a smiley with lots of whitespace.
-    for (i = 0; i < num_spaces; i++) { Str_Cat_Char(got, spaces[i]); }
-    Str_Cat_Char(got, 0x263A);
-    for (i = 0; i < num_spaces; i++) { Str_Cat_Char(got, spaces[i]); }
+    CharBuf *buf = CB_new(0);
+    for (i = 0; i < num_spaces; i++) { CB_Cat_Char(buf, spaces[i]); }
+    CB_Cat_Char(buf, 0x263A);
+    for (i = 0; i < num_spaces; i++) { CB_Cat_Char(buf, spaces[i]); }
 
+    got = CB_To_String(buf);
     TEST_TRUE(runner, Str_Trim_Top(got), "Trim_Top returns true on success");
     TEST_FALSE(runner, Str_Trim_Top(got),
                "Trim_Top returns false on failure");
@@ -207,19 +210,16 @@ test_Trim(TestBatchRunner *runner) {
                "Trim_Tail returns false on failure");
     TEST_TRUE(runner, Str_Equals_Str(got, smiley, smiley_len),
               "Trim_Top and Trim_Tail worked");
+    DECREF(got);
 
-    // Build the spacey smiley again.
-    Str_Truncate(got, 0);
-    for (i = 0; i < num_spaces; i++) { Str_Cat_Char(got, spaces[i]); }
-    Str_Cat_Char(got, 0x263A);
-    for (i = 0; i < num_spaces; i++) { Str_Cat_Char(got, spaces[i]); }
-
+    got = CB_To_String(buf);
     TEST_TRUE(runner, Str_Trim(got), "Trim returns true on success");
     TEST_FALSE(runner, Str_Trim(got), "Trim returns false on failure");
     TEST_TRUE(runner, Str_Equals_Str(got, smiley, smiley_len),
               "Trim worked");
-
     DECREF(got);
+
+    DECREF(buf);
 }
 
 static void


Mime
View raw message