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/10 03:59:14 UTC
[13/17] lucy-clownfish git commit: Tests for Boolean Go bindings.
Tests for Boolean 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/939b08ff
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/939b08ff
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/939b08ff
Branch: refs/heads/master
Commit: 939b08ff6e76683d3826eefb5f357efa0ba00432
Parents: d947d88
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Wed Aug 5 20:06:49 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Thu Aug 6 19:51:33 2015 -0700
----------------------------------------------------------------------
runtime/go/clownfish/boolean_test.go | 105 ++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/939b08ff/runtime/go/clownfish/boolean_test.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/boolean_test.go b/runtime/go/clownfish/boolean_test.go
new file mode 100644
index 0000000..a1419cb
--- /dev/null
+++ b/runtime/go/clownfish/boolean_test.go
@@ -0,0 +1,105 @@
+/* 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 TestBooleanGetValue(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if !myTrue.GetValue() {
+ t.Errorf("Expected true, got false")
+ }
+ if myFalse.GetValue() {
+ t.Errorf("Expected false, got true")
+ }
+}
+
+func TestBooleanToF64(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if got := myTrue.ToF64(); got != 1.0 {
+ t.Errorf("Expected 1.0, got %v", got)
+ }
+ if got := myFalse.ToF64(); got != 0.0 {
+ t.Errorf("Expected 0.0, got %v", got)
+ }
+}
+
+func TestBooleanToI64(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if got := myTrue.ToI64(); got != 1 {
+ t.Errorf("Expected 1, got %v", got)
+ }
+ if got := myFalse.ToI64(); got != 0 {
+ t.Errorf("Expected 0, got %v", got)
+ }
+}
+
+func TestBooleanToBool(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if !myTrue.ToBool() {
+ t.Errorf("Expected true, got false")
+ }
+ if myFalse.ToBool() {
+ t.Errorf("Expected false, got true")
+ }
+}
+
+func TestBooleanToString(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if got := myTrue.ToString(); got != "true" {
+ t.Errorf("Expected \"true\", got %v", got)
+ }
+ if got := myFalse.ToString(); got != "false" {
+ t.Errorf("Expected \"false\", got %v", got)
+ }
+}
+
+func TestBooleanClone(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if myTrue.TOPTR() != myTrue.Clone().TOPTR() {
+ t.Errorf("Clone should wrap CFISH_TRUE")
+ }
+ if myFalse.TOPTR() != myFalse.Clone().TOPTR() {
+ t.Errorf("Clone should wrap CFISH_FALSE")
+ }
+}
+
+func TestBooleanEquals(t *testing.T) {
+ myTrue := NewBoolean(true)
+ myFalse := NewBoolean(false)
+ if !myTrue.Equals(myTrue) {
+ t.Error("Equal Clownfish Boolean")
+ }
+ if !myTrue.Equals(true) {
+ t.Error("Equal Go bool (true)")
+ }
+ if !myFalse.Equals(false) {
+ t.Error("Equal Go bool (false)")
+ }
+ if myTrue.Equals(myFalse) {
+ t.Error("Non-equal Clownfish Boolean")
+ }
+ if myFalse.Equals(0) {
+ t.Error("Go 0 should not equal Clownfish Boolean false")
+ }
+}