You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/08/14 20:06:16 UTC

[09/14] lucy-clownfish git commit: Tests for CharBuf Go bindings.

Tests for CharBuf Go bindings.


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

Branch: refs/heads/master
Commit: 7ef5eaf34d1caa8a3c6569599425da67ca5e26f0
Parents: cd8ca2c
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sat Aug 8 18:08:38 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sun Aug 9 19:00:36 2015 -0700

----------------------------------------------------------------------
 runtime/go/clownfish/charbuf_test.go | 77 +++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ef5eaf3/runtime/go/clownfish/charbuf_test.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/charbuf_test.go b/runtime/go/clownfish/charbuf_test.go
new file mode 100644
index 0000000..1ade2f2
--- /dev/null
+++ b/runtime/go/clownfish/charbuf_test.go
@@ -0,0 +1,77 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clownfish
+
+import "testing"
+
+func TestCharBufCat(t *testing.T) {
+	cb := NewCharBuf(0)
+	cb.Cat("foo")
+	if got := cb.ToString(); got != "foo" {
+		t.Errorf("Expected foo, got %v", got)
+	}
+}
+
+func TestCharBufMimic(t *testing.T) {
+	cb := NewCharBuf(0)
+	other := NewCharBuf(0)
+	other.Cat("foo")
+	cb.Mimic(other)
+	if got := cb.ToString(); got != "foo" {
+		t.Errorf("Expected foo, got %v", got)
+	}
+}
+
+func TestCharBufCatChar(t *testing.T) {
+	cb := NewCharBuf(0)
+	cb.CatChar('x')
+	if got := cb.ToString(); got != "x" {
+		t.Errorf("Expected x, got %v", got)
+	}
+}
+
+func TestCharBufSetSizeGetSize(t *testing.T) {
+	cb := NewCharBuf(0)
+	cb.Cat("abc")
+	cb.SetSize(2)
+	if got := cb.GetSize(); got != 2 {
+		t.Errorf("Size should be 2 but got %d", got)
+	}
+	if got := cb.ToString(); got != "ab" {
+		t.Errorf("Expected ab, got %v", got)
+	}
+}
+
+func TestCharBufClone(t *testing.T) {
+	cb := NewCharBuf(0)
+	cb.Cat("foo")
+	clone := cb.Clone()
+	if got := clone.ToString(); got != "foo" {
+		t.Errorf("Expected foo, got %v", got)
+	}
+}
+
+func TestCharBufYieldString(t *testing.T) {
+	cb := NewCharBuf(0)
+	cb.Cat("foo")
+	if got := cb.YieldString(); got != "foo" {
+		t.Errorf("Should yield foo, got %v", got)
+	}
+	if got := cb.YieldString(); got != "" {
+		t.Errorf("Should yield empty string, got %v", got)
+	}
+}