From: Kevin Clark Date: Wed, 18 Jun 2008 01:13:58 +0000 (+0000) Subject: Add new spec for properly initializing boolean values X-Git-Tag: 0.2.0~565 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=1cfd693f3e4cbb697c0942299c43c081dfa3c820;p=common%2Fthrift.git Add new spec for properly initializing boolean values git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668985 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/spec/ThriftSpec.thrift b/lib/rb/spec/ThriftSpec.thrift index f22f17dd..101caffe 100644 --- a/lib/rb/spec/ThriftSpec.thrift +++ b/lib/rb/spec/ThriftSpec.thrift @@ -12,3 +12,7 @@ struct Foo { 5: map> complex, 6: set shorts = [5, 17, 239] } + +struct BoolStruct { + 1: bool yesno = 1 +} diff --git a/lib/rb/spec/gen-rb/ThriftSpec_types.rb b/lib/rb/spec/gen-rb/ThriftSpec_types.rb index c4eab4dc..f34b7bc8 100644 --- a/lib/rb/spec/gen-rb/ThriftSpec_types.rb +++ b/lib/rb/spec/gen-rb/ThriftSpec_types.rb @@ -38,4 +38,12 @@ module SpecNamespace } end + class BoolStruct + include Thrift::Struct + attr_accessor :yesno + FIELDS = { + 1 => {:type => Thrift::Types::BOOL, :name => 'yesno', :default => true} + } + end + end diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb index e57d5557..16c3b1f2 100644 --- a/lib/rb/spec/struct_spec.rb +++ b/lib/rb/spec/struct_spec.rb @@ -47,6 +47,11 @@ class ThriftStructSpec < Spec::ExampleGroup end end + it "should properly initialize boolean values" do + struct = BoolStruct.new(:yesno => false) + struct.yesno.should be_false + end + it "should have proper == semantics" do Foo.new.should_not == Hello.new Foo.new.should == Foo.new