summaryrefslogtreecommitdiff
path: root/lib/go
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2014-05-02 00:24:24 +0200
committerJens Geyer <jensg@apache.org>2014-05-02 00:24:24 +0200
commit731975a645e47c931fbbc42ac51c12b0873a50c2 (patch)
tree690d8771ba7e35c18022c00de53cdb2cacbc2231 /lib/go
parentce79d59144fb5eabba67a28db76580fdb4f6bb89 (diff)
downloadthrift-731975a645e47c931fbbc42ac51c12b0873a50c2.tar.gz
THRIFT-2451: Do not use pointers for optional fields with defaults. Do not write such fields if its value set to default. Also, do not use pointers for any optional fields mapped to go map or slice. generate Get accessors
Client: Go Patch: Aleksey Pesternikov This closes #101 commit e6e5dcf3a07cd931183991ff031179b425e2740b Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-16T14:06:52Z initial change commit f65730e951a4310160a9f7e3e4eeb7e55abd2c55 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-16T14:16:03Z no IsSet for required commit 9865f700eb9354d6053994da989a907766c42d1d Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-17T19:32:13Z inlined required structs commit ca52300c07cefcf553f1ebf35569953c933b2367 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-17T19:44:24Z do not use heap for args struct commit 012ca3e512d2bc8822de8a715b4f3d3cae5c0c42 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-17T19:52:41Z do not use heap for result struct commit 2fc4afc53ff7db43e08eadeaa30e34bc1fd9c889 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-17T21:32:43Z do not set result field on error commit 6e5da0062b139f02dcafe3148cdf02f97c23442a Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net> Date: 2014-04-17T21:57:57Z Jens' thrift source as test case commit 7317957ed708831e280f182f081043fbe9d38a0c Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local> Date: 2014-04-17T23:43:08Z support for cpp.ref commit 1c4f3efc7b54fd335db633f86faf8c426ae9c87d Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local> Date: 2014-04-18T00:13:24Z package flag commit c9d7e54f5c5d29c776f42fb861bc9e82da4e542f Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local> Date: 2014-04-18T00:21:18Z Merge branch 'master' into go_inlines
Diffstat (limited to 'lib/go')
-rw-r--r--lib/go/test/Makefile.am20
-rw-r--r--lib/go/test/OptionalFieldsTest.thrift43
-rw-r--r--lib/go/test/RefAnnotationFieldsTest.thrift58
-rw-r--r--lib/go/test/ServicesTest.thrift109
-rw-r--r--lib/go/test/TypedefFieldTest.thrift39
-rw-r--r--lib/go/test/tests/optional_fields_test.go280
-rw-r--r--lib/go/test/tests/protocol_mock.go511
-rw-r--r--lib/go/thrift/pointerize.go2
8 files changed, 1059 insertions, 3 deletions
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index ca8fa6402..5499fb7a9 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -25,19 +25,33 @@ gopath: $(top_srcdir)/compiler/cpp/thrift $(THRIFTTEST) \
IncludesTest.thrift \
NamespacedTest.thrift \
MultiplexedProtocolTest.thrift \
- OnewayTest.thrift
+ OnewayTest.thrift \
+ OptionalFieldsTest.thrift \
+ ServicesTest.thrift \
+ TypedefFieldTest.thrift \
+ RefAnnotationFieldsTest.thrift
mkdir -p gopath/src
- grep -v list.*map.*list.*map $(THRIFTTEST) > ThriftTest.thrift
+ grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set<Insanity>' > ThriftTest.thrift
$(THRIFT) -r IncludesTest.thrift
$(THRIFT) BinaryKeyTest.thrift
$(THRIFT) MultiplexedProtocolTest.thrift
$(THRIFT) OnewayTest.thrift
+ $(THRIFT) OptionalFieldsTest.thrift
+ $(THRIFT) ServicesTest.thrift
+ $(THRIFT) TypedefFieldTest.thrift
+ $(THRIFT) RefAnnotationFieldsTest.thrift
+ GOPATH=`pwd`/gopath $(GO) get code.google.com/p/gomock/gomock
ln -nfs ../../../thrift gopath/src/thrift
ln -nfs ../../tests gopath/src/tests
touch gopath
check: gopath
- GOPATH=`pwd`/gopath $(GO) build IncludesTest BinaryKeyTest
+ GOPATH=`pwd`/gopath $(GO) build \
+ IncludesTest \
+ BinaryKeyTest \
+ ServicesTest \
+ TypedefFieldTest \
+ RefAnnotationFieldsTest
GOPATH=`pwd`/gopath $(GO) test thrift tests
clean-local:
diff --git a/lib/go/test/OptionalFieldsTest.thrift b/lib/go/test/OptionalFieldsTest.thrift
new file mode 100644
index 000000000..25b0ef648
--- /dev/null
+++ b/lib/go/test/OptionalFieldsTest.thrift
@@ -0,0 +1,43 @@
+#
+# 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.
+#
+
+struct structA {
+ 1: required i64 sa_i
+}
+
+struct all_optional {
+ 1: optional string s = "DEFAULT",
+ 2: optional i64 i = 42,
+ 3: optional bool b = false,
+ 4: optional string s2,
+ 5: optional i64 i2,
+ 6: optional bool b2,
+ 7: optional structA aa,
+ 9: optional list<i64> l,
+ 10: optional list<i64> l2 = [1, 2],
+ 11: optional map<i64, i64> m,
+ 12: optional map<i64, i64> m2 = {1:2, 3:4},
+ 13: optional binary bin,
+ 14: optional binary bin2 = "asdf",
+}
+
+struct structB {
+ 1: required structA required_struct_thing
+ 2: optional structA optional_struct_thing
+}
diff --git a/lib/go/test/RefAnnotationFieldsTest.thrift b/lib/go/test/RefAnnotationFieldsTest.thrift
new file mode 100644
index 000000000..b7f28c28f
--- /dev/null
+++ b/lib/go/test/RefAnnotationFieldsTest.thrift
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+
+struct structA {
+ 1: required i64 sa_i
+}
+
+struct all_referenced {
+ 1: optional string s = "DEFAULT" (cpp.ref = ""),
+ 2: optional i64 i = 42 (cpp.ref = ""),
+ 3: optional bool b = false (cpp.ref = ""),
+ 4: optional string s2 (cpp.ref = ""),
+ 5: optional i64 i2 (cpp.ref = ""),
+ 6: optional bool b2 (cpp.ref = ""),
+ 7: optional structA aa (cpp.ref = ""),
+ 9: optional list<i64> l (cpp.ref = ""),
+ 10: optional list<i64> l2 = [1, 2] (cpp.ref = ""),
+ 11: optional map<i64, i64> m (cpp.ref = ""),
+ 12: optional map<i64, i64> m2 = {1:2, 3:4} (cpp.ref = ""),
+ 13: optional binary bin (cpp.ref = ""),
+ 14: optional binary bin2 = "asdf" (cpp.ref = ""),
+
+ 15: required string ref_s = "DEFAULT" (cpp.ref = ""),
+ 16: required i64 ref_i = 42 (cpp.ref = ""),
+ 17: required bool ref_b = false (cpp.ref = ""),
+ 18: required string ref_s2 (cpp.ref = ""),
+ 19: required i64 ref_i2 (cpp.ref = ""),
+ 20: required bool ref_b2 (cpp.ref = ""),
+ 21: required structA ref_aa (cpp.ref = ""),
+ 22: required list<i64> ref_l (cpp.ref = ""),
+ 23: required list<i64> ref_l2 = [1, 2] (cpp.ref = ""),
+ 24: required map<i64, i64> ref_m (cpp.ref = ""),
+ 25: required map<i64, i64> ref_m2 = {1:2, 3:4} (cpp.ref = ""),
+ 26: required binary ref_bin (cpp.ref = ""),
+ 27: required binary ref_bin2 = "asdf" (cpp.ref = ""),
+
+}
+
+struct structB {
+ 1: required structA required_struct_thing
+ 2: optional structA optional_struct_thing
+}
diff --git a/lib/go/test/ServicesTest.thrift b/lib/go/test/ServicesTest.thrift
new file mode 100644
index 000000000..1b8be3648
--- /dev/null
+++ b/lib/go/test/ServicesTest.thrift
@@ -0,0 +1,109 @@
+#
+# 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.
+#
+
+# We are only testing that generated code compiles, no correctness checking is done
+
+exception moderate_disaster {
+ 1: i32 errorCode,
+ 2: string message
+}
+
+exception total_disaster {
+ 1: string message
+ 2: optional bool president_was_woken_up = false
+}
+
+struct struct_a {
+ 1: required i64 whatever
+}
+
+service a_serv {
+ void voidfunc(),
+ void void_with_1ex() throws(1: moderate_disaster err1)
+ void void_with_2ex() throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ string stringfunc()
+ string stringfunc_1ex() throws(1: moderate_disaster err1)
+ string stringfunc_2ex() throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ i64 i64func()
+ i64 i64func_1ex() throws(1: moderate_disaster err1)
+ i64 i64func_2ex() throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ list<string> list_of_strings_func()
+ list<string> list_of_strings_func_1ex() throws(1: moderate_disaster err1)
+ list<string> list_of_strings_func_2ex() throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ map<i64,string> map_func()
+ map<i64,string> map_func_1ex() throws(1: moderate_disaster err1)
+ map<i64,string> map_func_2ex() throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ struct_a struct_a_func()
+ struct_a struct_a_func_1ex() throws(1: moderate_disaster err1)
+ struct_a struct_a_func_2ex() throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ void voidfunc_1int(1: i64 i),
+ void void_with_1ex_1int(1: i64 i) throws(1: moderate_disaster err1)
+ void void_with_2ex_1int(1: i64 i) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ string stringfunc_1int(1: i64 i)
+ string stringfunc_1ex_1int(1: i64 i) throws(1: moderate_disaster err1)
+ string stringfunc_2ex_1int(1: i64 i) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ i64 i64func_1int(1: i64 i)
+ i64 i64func_1ex_1int(1: i64 i) throws(1: moderate_disaster err1)
+ i64 i64func_2ex_1int(1: i64 i) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ list<string> list_of_strings_func_1int(1: i64 i)
+ list<string> list_of_strings_func_1ex_1int(1: i64 i) throws(1: moderate_disaster err1)
+ list<string> list_of_strings_func_2ex_1int(1: i64 i) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ map<i64,string> map_func_1int(1: i64 i)
+ map<i64,string> map_func_1ex_1int(1: i64 i) throws(1: moderate_disaster err1)
+ map<i64,string> map_func_2ex_1int(1: i64 i) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ struct_a struct_a_func_1int(1: i64 i)
+ struct_a struct_a_func_1ex_1int(1: i64 i) throws(1: moderate_disaster err1)
+ struct_a struct_a_func_2ex_1int(1: i64 i) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ void voidfunc_1int_1s(1: i64 i, 2: string s),
+ void void_with_1ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1)
+ void void_with_2ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ string stringfunc_1int_1s(1: i64 i, 2: string s)
+ string stringfunc_1ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1)
+ string stringfunc_2ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ i64 i64func_1int_1s(1: i64 i, 2: string s)
+ i64 i64func_1ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1)
+ i64 i64func_2ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ list<string> list_of_strings_func_1int_1s(1: i64 i, 2: string s)
+ list<string> list_of_strings_func_1ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1)
+ list<string> list_of_strings_func_2ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ map<i64,string> map_func_1int_1s(1: i64 i, 2: string s)
+ map<i64,string> map_func_1ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1)
+ map<i64,string> map_func_2ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+ struct_a struct_a_func_1int_1s(1: i64 i, 2: string s)
+ struct_a struct_a_func_1ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1)
+ struct_a struct_a_func_2ex_1int_1s(1: i64 i, 2: string s) throws(1: moderate_disaster err1, 2:total_disaster err2)
+
+}
diff --git a/lib/go/test/TypedefFieldTest.thrift b/lib/go/test/TypedefFieldTest.thrift
new file mode 100644
index 000000000..390e8c88e
--- /dev/null
+++ b/lib/go/test/TypedefFieldTest.thrift
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+# We are only testing that generated code compiles, no correctness checking is done
+
+enum Details {
+ Everything = 0
+ StateOnly = 1
+ StateAndOptions = 2
+ SomethingElse = 3
+}
+
+typedef list< Details> DetailsWanted
+
+struct BaseRequest {
+ 1 : optional string RequestID
+}
+
+struct GetMyDetails {
+ 1 : required BaseRequest base_
+ 2 : required string ObjectID
+ 3 : optional DetailsWanted DetailsWanted
+}
diff --git a/lib/go/test/tests/optional_fields_test.go b/lib/go/test/tests/optional_fields_test.go
new file mode 100644
index 000000000..4b0797c42
--- /dev/null
+++ b/lib/go/test/tests/optional_fields_test.go
@@ -0,0 +1,280 @@
+/*
+ * 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 tests
+
+import (
+ "OptionalFieldsTest"
+ "bytes"
+ gomock "code.google.com/p/gomock/gomock"
+ "testing"
+ "thrift"
+)
+
+func TestIsSetReturnFalseOnCreation(t *testing.T) {
+ ao := OptionalFieldsTest.NewAllOptional()
+ if ao.IsSetS() {
+ t.Errorf("Optional field S is set on initialization")
+ }
+ if ao.IsSetI() {
+ t.Errorf("Optional field I is set on initialization")
+ }
+ if ao.IsSetB() {
+ t.Errorf("Optional field B is set on initialization")
+ }
+ if ao.IsSetS2() {
+ t.Errorf("Optional field S2 is set on initialization")
+ }
+ if ao.IsSetI2() {
+ t.Errorf("Optional field I2 is set on initialization")
+ }
+ if ao.IsSetB2() {
+ t.Errorf("Optional field B2 is set on initialization")
+ }
+ if ao.IsSetAa() {
+ t.Errorf("Optional field Aa is set on initialization")
+ }
+ if ao.IsSetL() {
+ t.Errorf("Optional field L is set on initialization")
+ }
+ if ao.IsSetL2() {
+ t.Errorf("Optional field L2 is set on initialization")
+ }
+ if ao.IsSetM() {
+ t.Errorf("Optional field M is set on initialization")
+ }
+ if ao.IsSetM2() {
+ t.Errorf("Optional field M2 is set on initialization")
+ }
+ if ao.IsSetBin() {
+ t.Errorf("Optional field Bin is set on initialization")
+ }
+ if ao.IsSetBin2() {
+ t.Errorf("Optional field Bin2 is set on initialization")
+ }
+}
+
+func TestDefaultValuesOnCreation(t *testing.T) {
+ ao := OptionalFieldsTest.NewAllOptional()
+ if ao.GetS() != "DEFAULT" {
+ t.Errorf("Unexpected default value %#v for field S", ao.GetS())
+ }
+ if ao.GetI() != 42 {
+ t.Errorf("Unexpected default value %#v for field I", ao.GetI())
+ }
+ if ao.GetB() != false {
+ t.Errorf("Unexpected default value %#v for field B", ao.GetB())
+ }
+ if ao.GetS2() != "" {
+ t.Errorf("Unexpected default value %#v for field S2", ao.GetS2())
+ }
+ if ao.GetI2() != 0 {
+ t.Errorf("Unexpected default value %#v for field I2", ao.GetI2())
+ }
+ if ao.GetB2() != false {
+ t.Errorf("Unexpected default value %#v for field B2", ao.GetB2())
+ }
+ if l := ao.GetL(); len(l) != 0 {
+ t.Errorf("Unexpected default value %#v for field L", l)
+ }
+ if l := ao.GetL2(); len(l) != 2 || l[0] != 1 || l[1] != 2 {
+ t.Errorf("Unexpected default value %#v for field L2", l)
+ }
+ //FIXME: should we return empty map here?
+ if m := ao.GetM(); m != nil {
+ t.Errorf("Unexpected default value %#v for field M", m)
+ }
+ if m := ao.GetM2(); len(m) != 2 || m[1] != 2 || m[3] != 4 {
+ t.Errorf("Unexpected default value %#v for field M2", m)
+ }
+ if bv := ao.GetBin(); bv != nil {
+ t.Errorf("Unexpected default value %#v for field Bin", bv)
+ }
+ if bv := ao.GetBin2(); !bytes.Equal(bv, []byte("asdf")) {
+ t.Errorf("Unexpected default value %#v for field Bin2", bv)
+ }
+}
+
+func TestInitialValuesOnCreation(t *testing.T) {
+ ao := OptionalFieldsTest.NewAllOptional()
+ if ao.S != "DEFAULT" {
+ t.Errorf("Unexpected initial value %#v for field S", ao.S)
+ }
+ if ao.I != 42 {
+ t.Errorf("Unexpected initial value %#v for field I", ao.I)
+ }
+ if ao.B != false {
+ t.Errorf("Unexpected initial value %#v for field B", ao.B)
+ }
+ if ao.S2 != nil {
+ t.Errorf("Unexpected initial value %#v for field S2", ao.S2)
+ }
+ if ao.I2 != nil {
+ t.Errorf("Unexpected initial value %#v for field I2", ao.I2)
+ }
+ if ao.B2 != nil {
+ t.Errorf("Unexpected initial value %#v for field B2", ao.B2)
+ }
+ if ao.L != nil || len(ao.L) != 0 {
+ t.Errorf("Unexpected initial value %#v for field L", ao.L)
+ }
+ if ao.L2 != nil {
+ t.Errorf("Unexpected initial value %#v for field L2", ao.L2)
+ }
+ if ao.M != nil {
+ t.Errorf("Unexpected initial value %#v for field M", ao.M)
+ }
+ if ao.M2 != nil {
+ t.Errorf("Unexpected initial value %#v for field M2", ao.M2)
+ }
+ if ao.Bin != nil || len(ao.Bin) != 0 {
+ t.Errorf("Unexpected initial value %#v for field Bin", ao.Bin)
+ }
+ if !bytes.Equal(ao.Bin2, []byte("asdf")) {
+ t.Errorf("Unexpected initial value %#v for field Bin2", ao.Bin2)
+ }
+}
+
+func TestIsSetReturnTrueAfterUpdate(t *testing.T) {
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.S = "somevalue"
+ ao.I = 123
+ ao.B = true
+ ao.Aa = OptionalFieldsTest.NewStructA()
+ if !ao.IsSetS() {
+ t.Errorf("Field S should be set")
+ }
+ if !ao.IsSetI() {
+ t.Errorf("Field I should be set")
+ }
+ if !ao.IsSetB() {
+ t.Errorf("Field B should be set")
+ }
+ if !ao.IsSetAa() {
+ t.Errorf("Field aa should be set")
+ }
+}
+
+func TestListNotEmpty(t *testing.T) {
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.L = []int64{1, 2, 3}
+ if !ao.IsSetL() {
+ t.Errorf("Field L should be set")
+ }
+}
+
+//Make sure that optional fields are not being serialized
+func TestNoOptionalUnsetFieldsOnWire(t *testing.T) {
+ mockCtrl := gomock.NewController(t)
+ defer mockCtrl.Finish()
+ proto := NewMockTProtocol(mockCtrl)
+ gomock.InOrder(
+ proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
+ proto.EXPECT().WriteFieldStop().Return(nil),
+ proto.EXPECT().WriteStructEnd().Return(nil),
+ )
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.Write(proto)
+}
+
+func TestNoSetToDefaultFieldsOnWire(t *testing.T) {
+ mockCtrl := gomock.NewController(t)
+ defer mockCtrl.Finish()
+ proto := NewMockTProtocol(mockCtrl)
+ gomock.InOrder(
+ proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
+ proto.EXPECT().WriteFieldStop().Return(nil),
+ proto.EXPECT().WriteStructEnd().Return(nil),
+ )
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.I = 42
+ ao.Write(proto)
+}
+
+//Make sure that only one field is being serialized when set to non-default
+func TestOneISetFieldOnWire(t *testing.T) {
+ mockCtrl := gomock.NewController(t)
+ defer mockCtrl.Finish()
+ proto := NewMockTProtocol(mockCtrl)
+ gomock.InOrder(
+ proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
+ proto.EXPECT().WriteFieldBegin("i", thrift.TType(thrift.I64), int16(2)).Return(nil),
+ proto.EXPECT().WriteI64(int64(123)).Return(nil),
+ proto.EXPECT().WriteFieldEnd().Return(nil),
+ proto.EXPECT().WriteFieldStop().Return(nil),
+ proto.EXPECT().WriteStructEnd().Return(nil),
+ )
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.I = 123
+ ao.Write(proto)
+}
+
+func TestOneLSetFieldOnWire(t *testing.T) {
+ mockCtrl := gomock.NewController(t)
+ defer mockCtrl.Finish()
+ proto := NewMockTProtocol(mockCtrl)
+ gomock.InOrder(
+ proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
+ proto.EXPECT().WriteFieldBegin("l", thrift.TType(thrift.LIST), int16(9)).Return(nil),
+ proto.EXPECT().WriteListBegin(thrift.TType(thrift.I64), 2).Return(nil),
+ proto.EXPECT().WriteI64(int64(1)).Return(nil),
+ proto.EXPECT().WriteI64(int64(2)).Return(nil),
+ proto.EXPECT().WriteListEnd().Return(nil),
+ proto.EXPECT().WriteFieldEnd().Return(nil),
+ proto.EXPECT().WriteFieldStop().Return(nil),
+ proto.EXPECT().WriteStructEnd().Return(nil),
+ )
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.L = []int64{1, 2}
+ ao.Write(proto)
+}
+
+func TestOneBinSetFieldOnWire(t *testing.T) {
+ mockCtrl := gomock.NewController(t)
+ defer mockCtrl.Finish()
+ proto := NewMockTProtocol(mockCtrl)
+ gomock.InOrder(
+ proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
+ proto.EXPECT().WriteFieldBegin("bin", thrift.TType(thrift.STRING), int16(13)).Return(nil),
+ proto.EXPECT().WriteBinary([]byte("somebytestring")).Return(nil),
+ proto.EXPECT().WriteFieldEnd().Return(nil),
+ proto.EXPECT().WriteFieldStop().Return(nil),
+ proto.EXPECT().WriteStructEnd().Return(nil),
+ )
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.Bin = []byte("somebytestring")
+ ao.Write(proto)
+}
+
+func TestOneEmptyBinSetFieldOnWire(t *testing.T) {
+ mockCtrl := gomock.NewController(t)
+ defer mockCtrl.Finish()
+ proto := NewMockTProtocol(mockCtrl)
+ gomock.InOrder(
+ proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
+ proto.EXPECT().WriteFieldBegin("bin", thrift.TType(thrift.STRING), int16(13)).Return(nil),
+ proto.EXPECT().WriteBinary([]byte{}).Return(nil),
+ proto.EXPECT().WriteFieldEnd().Return(nil),
+ proto.EXPECT().WriteFieldStop().Return(nil),
+ proto.EXPECT().WriteStructEnd().Return(nil),
+ )
+ ao := OptionalFieldsTest.NewAllOptional()
+ ao.Bin = []byte{}
+ ao.Write(proto)
+}
diff --git a/lib/go/test/tests/protocol_mock.go b/lib/go/test/tests/protocol_mock.go
new file mode 100644
index 000000000..d3f4078b6
--- /dev/null
+++ b/lib/go/test/tests/protocol_mock.go
@@ -0,0 +1,511 @@
+/*
+ * 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.
+ */
+
+// Automatically generated by MockGen. DO NOT EDIT!
+// Source: thrift (interfaces: TProtocol)
+
+package tests
+
+import (
+ thrift "thrift"
+ gomock "code.google.com/p/gomock/gomock"
+)
+
+// Mock of TProtocol interface
+type MockTProtocol struct {
+ ctrl *gomock.Controller
+ recorder *_MockTProtocolRecorder
+}
+
+// Recorder for MockTProtocol (not exported)
+type _MockTProtocolRecorder struct {
+ mock *MockTProtocol
+}
+
+func NewMockTProtocol(ctrl *gomock.Controller) *MockTProtocol {
+ mock := &MockTProtocol{ctrl: ctrl}
+ mock.recorder = &_MockTProtocolRecorder{mock}
+ return mock
+}
+
+func (_m *MockTProtocol) EXPECT() *_MockTProtocolRecorder {
+ return _m.recorder
+}
+
+func (_m *MockTProtocol) Flush() error {
+ ret := _m.ctrl.Call(_m, "Flush")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) Flush() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "Flush")
+}
+
+func (_m *MockTProtocol) ReadBinary() ([]byte, error) {
+ ret := _m.ctrl.Call(_m, "ReadBinary")
+ ret0, _ := ret[0].([]byte)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadBinary() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadBinary")
+}
+
+func (_m *MockTProtocol) ReadBool() (bool, error) {
+ ret := _m.ctrl.Call(_m, "ReadBool")
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadBool() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadBool")
+}
+
+func (_m *MockTProtocol) ReadByte() (byte, error) {
+ ret := _m.ctrl.Call(_m, "ReadByte")
+ ret0, _ := ret[0].(byte)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadByte() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadByte")
+}
+
+func (_m *MockTProtocol) ReadDouble() (float64, error) {
+ ret := _m.ctrl.Call(_m, "ReadDouble")
+ ret0, _ := ret[0].(float64)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadDouble() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadDouble")
+}
+
+func (_m *MockTProtocol) ReadFieldBegin() (string, thrift.TType, int16, error) {
+ ret := _m.ctrl.Call(_m, "ReadFieldBegin")
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(thrift.TType)
+ ret2, _ := ret[2].(int16)
+ ret3, _ := ret[3].(error)
+ return ret0, ret1, ret2, ret3
+}
+
+func (_mr *_MockTProtocolRecorder) ReadFieldBegin() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadFieldBegin")
+}
+
+func (_m *MockTProtocol) ReadFieldEnd() error {
+ ret := _m.ctrl.Call(_m, "ReadFieldEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) ReadFieldEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadFieldEnd")
+}
+
+func (_m *MockTProtocol) ReadI16() (int16, error) {
+ ret := _m.ctrl.Call(_m, "ReadI16")
+ ret0, _ := ret[0].(int16)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadI16() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadI16")
+}
+
+func (_m *MockTProtocol) ReadI32() (int32, error) {
+ ret := _m.ctrl.Call(_m, "ReadI32")
+ ret0, _ := ret[0].(int32)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadI32() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadI32")
+}
+
+func (_m *MockTProtocol) ReadI64() (int64, error) {
+ ret := _m.ctrl.Call(_m, "ReadI64")
+ ret0, _ := ret[0].(int64)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadI64() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadI64")
+}
+
+func (_m *MockTProtocol) ReadListBegin() (thrift.TType, int, error) {
+ ret := _m.ctrl.Call(_m, "ReadListBegin")
+ ret0, _ := ret[0].(thrift.TType)
+ ret1, _ := ret[1].(int)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+func (_mr *_MockTProtocolRecorder) ReadListBegin() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadListBegin")
+}
+
+func (_m *MockTProtocol) ReadListEnd() error {
+ ret := _m.ctrl.Call(_m, "ReadListEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) ReadListEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadListEnd")
+}
+
+func (_m *MockTProtocol) ReadMapBegin() (thrift.TType, thrift.TType, int, error) {
+ ret := _m.ctrl.Call(_m, "ReadMapBegin")
+ ret0, _ := ret[0].(thrift.TType)
+ ret1, _ := ret[1].(thrift.TType)
+ ret2, _ := ret[2].(int)
+ ret3, _ := ret[3].(error)
+ return ret0, ret1, ret2, ret3
+}
+
+func (_mr *_MockTProtocolRecorder) ReadMapBegin() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMapBegin")
+}
+
+func (_m *MockTProtocol) ReadMapEnd() error {
+ ret := _m.ctrl.Call(_m, "ReadMapEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) ReadMapEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMapEnd")
+}
+
+func (_m *MockTProtocol) ReadMessageBegin() (string, thrift.TMessageType, int32, error) {
+ ret := _m.ctrl.Call(_m, "ReadMessageBegin")
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(thrift.TMessageType)
+ ret2, _ := ret[2].(int32)
+ ret3, _ := ret[3].(error)
+ return ret0, ret1, ret2, ret3
+}
+
+func (_mr *_MockTProtocolRecorder) ReadMessageBegin() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMessageBegin")
+}
+
+func (_m *MockTProtocol) ReadMessageEnd() error {
+ ret := _m.ctrl.Call(_m, "ReadMessageEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) ReadMessageEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMessageEnd")
+}
+
+func (_m *MockTProtocol) ReadSetBegin() (thrift.TType, int, error) {
+ ret := _m.ctrl.Call(_m, "ReadSetBegin")
+ ret0, _ := ret[0].(thrift.TType)
+ ret1, _ := ret[1].(int)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+func (_mr *_MockTProtocolRecorder) ReadSetBegin() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadSetBegin")
+}
+
+func (_m *MockTProtocol) ReadSetEnd() error {
+ ret := _m.ctrl.Call(_m, "ReadSetEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) ReadSetEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadSetEnd")
+}
+
+func (_m *MockTProtocol) ReadString() (string, error) {
+ ret := _m.ctrl.Call(_m, "ReadString")
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadString() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadString")
+}
+
+func (_m *MockTProtocol) ReadStructBegin() (string, error) {
+ ret := _m.ctrl.Call(_m, "ReadStructBegin")
+ ret0, _ := ret[0].(string)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+func (_mr *_MockTProtocolRecorder) ReadStructBegin() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadStructBegin")
+}
+
+func (_m *MockTProtocol) ReadStructEnd() error {
+ ret := _m.ctrl.Call(_m, "ReadStructEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) ReadStructEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadStructEnd")
+}
+
+func (_m *MockTProtocol) Skip(_param0 thrift.TType) error {
+ ret := _m.ctrl.Call(_m, "Skip", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) Skip(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "Skip", arg0)
+}
+
+func (_m *MockTProtocol) Transport() thrift.TTransport {
+ ret := _m.ctrl.Call(_m, "Transport")
+ ret0, _ := ret[0].(thrift.TTransport)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) Transport() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "Transport")
+}
+
+func (_m *MockTProtocol) WriteBinary(_param0 []byte) error {
+ ret := _m.ctrl.Call(_m, "WriteBinary", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteBinary(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteBinary", arg0)
+}
+
+func (_m *MockTProtocol) WriteBool(_param0 bool) error {
+ ret := _m.ctrl.Call(_m, "WriteBool", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteBool(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteBool", arg0)
+}
+
+func (_m *MockTProtocol) WriteByte(_param0 byte) error {
+ ret := _m.ctrl.Call(_m, "WriteByte", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteByte(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteByte", arg0)
+}
+
+func (_m *MockTProtocol) WriteDouble(_param0 float64) error {
+ ret := _m.ctrl.Call(_m, "WriteDouble", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteDouble(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteDouble", arg0)
+}
+
+func (_m *MockTProtocol) WriteFieldBegin(_param0 string, _param1 thrift.TType, _param2 int16) error {
+ ret := _m.ctrl.Call(_m, "WriteFieldBegin", _param0, _param1, _param2)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteFieldBegin(arg0, arg1, arg2 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteFieldBegin", arg0, arg1, arg2)
+}
+
+func (_m *MockTProtocol) WriteFieldEnd() error {
+ ret := _m.ctrl.Call(_m, "WriteFieldEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteFieldEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteFieldEnd")
+}
+
+func (_m *MockTProtocol) WriteFieldStop() error {
+ ret := _m.ctrl.Call(_m, "WriteFieldStop")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteFieldStop() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteFieldStop")
+}
+
+func (_m *MockTProtocol) WriteI16(_param0 int16) error {
+ ret := _m.ctrl.Call(_m, "WriteI16", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteI16(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteI16", arg0)
+}
+
+func (_m *MockTProtocol) WriteI32(_param0 int32) error {
+ ret := _m.ctrl.Call(_m, "WriteI32", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteI32(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteI32", arg0)
+}
+
+func (_m *MockTProtocol) WriteI64(_param0 int64) error {
+ ret := _m.ctrl.Call(_m, "WriteI64", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteI64(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteI64", arg0)
+}
+
+func (_m *MockTProtocol) WriteListBegin(_param0 thrift.TType, _param1 int) error {
+ ret := _m.ctrl.Call(_m, "WriteListBegin", _param0, _param1)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteListBegin(arg0, arg1 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteListBegin", arg0, arg1)
+}
+
+func (_m *MockTProtocol) WriteListEnd() error {
+ ret := _m.ctrl.Call(_m, "WriteListEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteListEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteListEnd")
+}
+
+func (_m *MockTProtocol) WriteMapBegin(_param0 thrift.TType, _param1 thrift.TType, _param2 int) error {
+ ret := _m.ctrl.Call(_m, "WriteMapBegin", _param0, _param1, _param2)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteMapBegin(arg0, arg1, arg2 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMapBegin", arg0, arg1, arg2)
+}
+
+func (_m *MockTProtocol) WriteMapEnd() error {
+ ret := _m.ctrl.Call(_m, "WriteMapEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteMapEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMapEnd")
+}
+
+func (_m *MockTProtocol) WriteMessageBegin(_param0 string, _param1 thrift.TMessageType, _param2 int32) error {
+ ret := _m.ctrl.Call(_m, "WriteMessageBegin", _param0, _param1, _param2)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteMessageBegin(arg0, arg1, arg2 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMessageBegin", arg0, arg1, arg2)
+}
+
+func (_m *MockTProtocol) WriteMessageEnd() error {
+ ret := _m.ctrl.Call(_m, "WriteMessageEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteMessageEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMessageEnd")
+}
+
+func (_m *MockTProtocol) WriteSetBegin(_param0 thrift.TType, _param1 int) error {
+ ret := _m.ctrl.Call(_m, "WriteSetBegin", _param0, _param1)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteSetBegin(arg0, arg1 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteSetBegin", arg0, arg1)
+}
+
+func (_m *MockTProtocol) WriteSetEnd() error {
+ ret := _m.ctrl.Call(_m, "WriteSetEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteSetEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteSetEnd")
+}
+
+func (_m *MockTProtocol) WriteString(_param0 string) error {
+ ret := _m.ctrl.Call(_m, "WriteString", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteString(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteString", arg0)
+}
+
+func (_m *MockTProtocol) WriteStructBegin(_param0 string) error {
+ ret := _m.ctrl.Call(_m, "WriteStructBegin", _param0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteStructBegin(arg0 interface{}) *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteStructBegin", arg0)
+}
+
+func (_m *MockTProtocol) WriteStructEnd() error {
+ ret := _m.ctrl.Call(_m, "WriteStructEnd")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+func (_mr *_MockTProtocolRecorder) WriteStructEnd() *gomock.Call {
+ return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteStructEnd")
+}
diff --git a/lib/go/thrift/pointerize.go b/lib/go/thrift/pointerize.go
index c2ae26102..8d6b2c215 100644
--- a/lib/go/thrift/pointerize.go
+++ b/lib/go/thrift/pointerize.go
@@ -46,3 +46,5 @@ func Int64Ptr(v int64) *int64 { return &v }
func StringPtr(v string) *string { return &v }
func Uint32Ptr(v uint32) *uint32 { return &v }
func Uint64Ptr(v uint64) *uint64 { return &v }
+func BoolPtr(v bool) *bool { return &v }
+func ByteSlicePtr(v []byte) *[]byte { return &v }