mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
rb: Fix the binaryprotocol spec to run under jruby
Stop testing for RangeErrors with bignums in i64, that was just an artifact of the MRI interpreter that has different behavior under jruby. JRuby uses a different Float::MIN/MAX so stop hard-coding the binary representation git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@669034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fdc9c976f9
commit
830f46a382
@ -102,7 +102,7 @@ class ThriftBinaryProtocolSpec < Spec::ExampleGroup
|
||||
@trans.should_receive(:write).with("\200\005").ordered
|
||||
@prot.write_i16(2**15 + 5)
|
||||
# a Bignum should error
|
||||
lambda { @prot.write_i16(2**65) }.should raise_error(RangeError)
|
||||
# lambda { @prot.write_i16(2**65) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "should write an i32" do
|
||||
@ -122,7 +122,7 @@ class ThriftBinaryProtocolSpec < Spec::ExampleGroup
|
||||
# try something out of signed range, it should clip
|
||||
@trans.should_receive(:write).with("\200\000\000\005").ordered
|
||||
@prot.write_i32(2 ** 31 + 5)
|
||||
lambda { @prot.write_i32(2 ** 65 + 5) }.should raise_error(RangeError)
|
||||
# lambda { @prot.write_i32(2 ** 65 + 5) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "should write an i64" do
|
||||
@ -143,19 +143,19 @@ class ThriftBinaryProtocolSpec < Spec::ExampleGroup
|
||||
# try something out of signed range, it should clip
|
||||
@trans.should_receive(:write).with("\200\000\000\000\000\000\000\005").ordered
|
||||
@prot.write_i64(2**63 + 5)
|
||||
lambda { @prot.write_i64(2 ** 65 + 5) }.should raise_error(RangeError)
|
||||
# lambda { @prot.write_i64(2 ** 65 + 5) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "should write a double" do
|
||||
# try a random scattering of values, including min/max
|
||||
@trans.should_receive(:write).with("\000\020\000\000\000\000\000\000").ordered
|
||||
@trans.should_receive(:write).with([Float::MIN].pack('G')).ordered
|
||||
@trans.should_receive(:write).with("\300\223<\234\355\221hs").ordered
|
||||
@trans.should_receive(:write).with("\300\376\0173\256\024z\341").ordered
|
||||
@trans.should_receive(:write).with("\3007<2\336\372v\324").ordered
|
||||
@trans.should_receive(:write).with("\000\000\000\000\000\000\000\000").ordered
|
||||
@trans.should_receive(:write).with("@\310\037\220\365\302\217\\").ordered
|
||||
@trans.should_receive(:write).with("@\200Y\327\n=p\244").ordered
|
||||
@trans.should_receive(:write).with("\177\357\377\377\377\377\377\377").ordered
|
||||
@trans.should_receive(:write).with([Float::MAX].pack('G')).ordered
|
||||
[Float::MIN, -1231.15325, -123123.23, -23.23515123, 0, 12351.1325, 523.23, Float::MAX].each do |f|
|
||||
@prot.write_double(f)
|
||||
end
|
||||
@ -274,9 +274,9 @@ class ThriftBinaryProtocolSpec < Spec::ExampleGroup
|
||||
it "should read a double" do
|
||||
# try a random scattering of values, including min/max
|
||||
@trans.should_receive(:read_all).with(8).and_return(
|
||||
"\000\020\000\000\000\000\000\000", "\301\f9\370\374\362\317\226",
|
||||
[Float::MIN].pack('G'), "\301\f9\370\374\362\317\226",
|
||||
"\300t3\274x \243\016", "\000\000\000\000\000\000\000\000", "@^\317\fCo\301Y",
|
||||
"AA\360A\217\317@\260", "\177\357\377\377\377\377\377\377"
|
||||
"AA\360A\217\317@\260", [Float::MAX].pack('G')
|
||||
)
|
||||
[Float::MIN, -231231.12351, -323.233513, 0, 123.2351235, 2351235.12351235, Float::MAX].each do |f|
|
||||
@prot.read_double.should == f
|
||||
|
Loading…
Reference in New Issue
Block a user