rb_raise(rb_eRuntimeError, "too many fields in union!");
}
- // read field end
- default_read_field_end(protocol);
-
// read struct end
default_read_struct_end(protocol);
lambda { union.some_characters }.should raise_error(RuntimeError, "some_characters is not union's set field.")
end
- it "should serialize correctly" do
+ it "should serialize to binary correctly" do
trans = Thrift::MemoryBufferTransport.new
proto = Thrift::BinaryProtocol.new(trans)
other_union.should == union
end
+ it "should serialize to json correctly" do
+ trans = Thrift::MemoryBufferTransport.new
+ proto = Thrift::JsonProtocol.new(trans)
+
+ union = SpecNamespace::My_union.new(:integer32, 25)
+ union.write(proto)
+
+ other_union = SpecNamespace::My_union.new(:integer32, 25)
+ other_union.read(proto)
+ other_union.should == union
+ end
+
it "should raise when validating unset union" do
union = SpecNamespace::My_union.new
lambda { union.validate }.should raise_error(StandardError, "Union fields are not set.")