summaryrefslogtreecommitdiff
path: root/test/go
diff options
context:
space:
mode:
authorNobuaki Sukegawa <nsukeg@gmail.com>2015-09-21 13:53:25 +0900
committerRoger Meier <roger@apache.org>2015-09-21 23:07:39 +0200
commita649e7473bd0229f160332f0c80407ba49765065 (patch)
tree44dea5abd7123a132851b6e1e181bf6caf3d3a44 /test/go
parent245c347b7374182f8142ac07e43473ddd8c4d0de (diff)
downloadthrift-a649e7473bd0229f160332f0c80407ba49765065.tar.gz
THRIFT-3337 Add testBool method to cross tests
This closes #611
Diffstat (limited to 'test/go')
-rw-r--r--test/go/src/bin/testclient/main.go19
-rw-r--r--test/go/src/common/clientserver_test.go17
-rw-r--r--test/go/src/common/mock_handler.go12
-rw-r--r--test/go/src/common/printing_handler.go11
-rw-r--r--test/go/src/common/simple_handler.go4
5 files changed, 61 insertions, 2 deletions
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index f19743a8e..d0e5ff882 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -75,6 +75,21 @@ func callEverything(client *thrifttest.ThriftTestClient) {
t.Fatalf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
}
+ bl, err := client.TestBool(true)
+ if err != nil {
+ t.Fatalf("Unexpected error in TestBool() call: ", err)
+ }
+ if !bl {
+ t.Fatalf("Unexpected TestBool() result expected true, got %f ", bl)
+ }
+ bl, err = client.TestBool(false)
+ if err != nil {
+ t.Fatalf("Unexpected error in TestBool() call: ", err)
+ }
+ if bl {
+ t.Fatalf("Unexpected TestBool() result expected false, got %f ", bl)
+ }
+
b, err := client.TestByte(42)
if err != nil {
t.Fatalf("Unexpected error in TestByte() call: ", err)
@@ -186,10 +201,10 @@ func callEverything(client *thrifttest.ThriftTestClient) {
mapmap, err := client.TestMapMap(42)
if err != nil {
- t.Fatalf("Unexpected error in TestMapmap() call: ", err)
+ t.Fatalf("Unexpected error in TestMapMap() call: ", err)
}
if !reflect.DeepEqual(mapmap, rmapmap) {
- t.Fatalf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
+ t.Fatalf("Unexpected TestMapMap() result expected %#v, got %#v ", rmapmap, mapmap)
}
crazy := thrifttest.NewInsanity()
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index a7bd46c4e..5c8915ab3 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -89,6 +89,8 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
gomock.InOrder(
handler.EXPECT().TestVoid(),
handler.EXPECT().TestString("thing").Return("thing", nil),
+ handler.EXPECT().TestBool(true).Return(true, nil),
+ handler.EXPECT().TestBool(false).Return(false, nil),
handler.EXPECT().TestByte(int8(42)).Return(int8(42), nil),
handler.EXPECT().TestI32(int32(4242)).Return(int32(4242), nil),
handler.EXPECT().TestI64(int64(424242)).Return(int64(424242), nil),
@@ -125,6 +127,21 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
t.Errorf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
}
+ bl, err := client.TestBool(true)
+ if err != nil {
+ t.Errorf("Unexpected error in TestBool() call: ", err)
+ }
+ if !bl {
+ t.Errorf("Unexpected TestBool() result expected true, got %f ", bl)
+ }
+ bl, err = client.TestBool(false)
+ if err != nil {
+ t.Errorf("Unexpected error in TestBool() call: ", err)
+ }
+ if bl {
+ t.Errorf("Unexpected TestBool() result expected false, got %f ", bl)
+ }
+
b, err := client.TestByte(42)
if err != nil {
t.Errorf("Unexpected error in TestByte() call: ", err)
diff --git a/test/go/src/common/mock_handler.go b/test/go/src/common/mock_handler.go
index ec7e051be..7495fc66f 100644
--- a/test/go/src/common/mock_handler.go
+++ b/test/go/src/common/mock_handler.go
@@ -48,6 +48,18 @@ func (_m *MockThriftTest) EXPECT() *_MockThriftTestRecorder {
return _m.recorder
}
+func (_m *MockThriftTest) TestBool(_param0 bool) (bool, error) {
+ ret := _m.ctrl.Call(_m, "TestBool", _param0)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestBool(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBool", arg0)
+}
+
+
func (_m *MockThriftTest) TestByte(_param0 int8) (int8, error) {
ret := _m.ctrl.Call(_m, "TestByte", _param0)
ret0, _ := ret[0].(int8)
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
index 8c902d1e8..bc308b614 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -48,6 +48,17 @@ func (p *printingHandler) TestString(thing string) (r string, err error) {
return thing, nil
}
+// Prints 'testBool("%d")' with thing as 'true' or 'false'
+// @param bool thing - the bool to print
+// @return bool - returns the bool 'thing'
+//
+// Parameters:
+// - Thing
+func (p *printingHandler) TestBool(thing bool) (r bool, err error) {
+ fmt.Printf("testBool(%d)\n", thing)
+ return thing, nil
+}
+
// Prints 'testByte("%d")' with thing as '%d'
// @param byte thing - the byte to print
// @return byte - returns the byte 'thing'
diff --git a/test/go/src/common/simple_handler.go b/test/go/src/common/simple_handler.go
index 97ff52d46..944f11c1b 100644
--- a/test/go/src/common/simple_handler.go
+++ b/test/go/src/common/simple_handler.go
@@ -37,6 +37,10 @@ func (p *simpleHandler) TestString(thing string) (r string, err error) {
return thing, nil
}
+func (p *simpleHandler) TestBool(thing []byte) (r []byte, err error) {
+ return thing, nil
+}
+
func (p *simpleHandler) TestByte(thing int8) (r int8, err error) {
return thing, nil
}