summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/ffi/async_callback_spec.rb4
-rw-r--r--spec/ffi/bool_spec.rb12
-rw-r--r--spec/ffi/buffer_spec.rb46
-rw-r--r--spec/ffi/callback_spec.rb190
-rw-r--r--spec/ffi/dup_spec.rb14
-rw-r--r--spec/ffi/enum_spec.rb254
-rw-r--r--spec/ffi/errno_spec.rb4
-rw-r--r--spec/ffi/ffi_spec.rb6
-rw-r--r--spec/ffi/function_spec.rb10
-rw-r--r--spec/ffi/library_spec.rb36
-rw-r--r--spec/ffi/managed_struct_spec.rb2
-rw-r--r--spec/ffi/number_spec.rb80
-rw-r--r--spec/ffi/pointer_spec.rb10
-rw-r--r--spec/ffi/rbx/memory_pointer_spec.rb34
-rw-r--r--spec/ffi/rbx/struct_spec.rb4
-rw-r--r--spec/ffi/string_spec.rb16
-rw-r--r--spec/ffi/strptr_spec.rb2
-rw-r--r--spec/ffi/struct_callback_spec.rb4
-rw-r--r--spec/ffi/struct_initialize_spec.rb4
-rw-r--r--spec/ffi/struct_packed_spec.rb12
-rw-r--r--spec/ffi/struct_spec.rb162
-rw-r--r--spec/ffi/typedef_spec.rb8
-rw-r--r--spec/ffi/union_spec.rb6
-rw-r--r--spec/ffi/variadic_spec.rb31
24 files changed, 477 insertions, 474 deletions
diff --git a/spec/ffi/async_callback_spec.rb b/spec/ffi/async_callback_spec.rb
index 6e73453..4bae6ea 100644
--- a/spec/ffi/async_callback_spec.rb
+++ b/spec/ffi/async_callback_spec.rb
@@ -32,7 +32,7 @@ describe "async callback" do
cb = Proc.new {|i| v = i; called = true }
LibTest.testAsyncCallback(cb, 0x7fffffff)
called.should be_true
- v.should == 0x7fffffff
+ v.should eq 0x7fffffff
end
it "called a second time" do
@@ -41,6 +41,6 @@ describe "async callback" do
cb = Proc.new {|i| v = i; called = true }
LibTest.testAsyncCallback(cb, 0x7fffffff)
called.should be_true
- v.should == 0x7fffffff
+ v.should eq 0x7fffffff
end
end
diff --git a/spec/ffi/bool_spec.rb b/spec/ffi/bool_spec.rb
index 68e8419..3b27274 100644
--- a/spec/ffi/bool_spec.rb
+++ b/spec/ffi/bool_spec.rb
@@ -25,14 +25,14 @@ describe "Function with primitive boolean arguments and return values" do
attach_function :bool_reverse_val, [ :bool ], :bool
end
it "bools" do
- LibTest.bool_return_true.should == true
- LibTest.bool_return_false.should == false
+ LibTest.bool_return_true.should eq true
+ LibTest.bool_return_false.should eq false
- LibTest.bool_return_val(true).should == true
- LibTest.bool_return_val(false).should == false
+ LibTest.bool_return_val(true).should eq true
+ LibTest.bool_return_val(false).should eq false
- LibTest.bool_reverse_val(true).should == false
- LibTest.bool_reverse_val(false).should == true
+ LibTest.bool_reverse_val(true).should eq false
+ LibTest.bool_reverse_val(false).should eq true
end
it "raise error on invalid types" do
lambda { LibTest.bool_return_val(nil) }.should raise_error(::TypeError)
diff --git a/spec/ffi/buffer_spec.rb b/spec/ffi/buffer_spec.rb
index beefa12..096d44a 100644
--- a/spec/ffi/buffer_spec.rb
+++ b/spec/ffi/buffer_spec.rb
@@ -23,13 +23,13 @@ describe "Buffer#total" do
:long_long => 8, :ulong_long => 8, :float => 4, :double => 8
}.each_pair do |t, s|
it "Buffer.alloc_in(#{t}, #{i}).total == #{i * s}" do
- FFI::Buffer.alloc_in(t, i).total.should == i * s
+ FFI::Buffer.alloc_in(t, i).total.should eq i * s
end
it "Buffer.alloc_out(#{t}, #{i}).total == #{i * s}" do
- FFI::Buffer.alloc_out(t, i).total.should == i * s
+ FFI::Buffer.alloc_out(t, i).total.should eq i * s
end
it "Buffer.alloc_inout(#{t}, #{i}).total == #{i * s}" do
- FFI::Buffer.alloc_inout(t, i).total.should == i * s
+ FFI::Buffer.alloc_inout(t, i).total.should eq i * s
end
end
end
@@ -40,7 +40,7 @@ describe "Buffer#put_char" do
(0..127).each do |i|
(0..bufsize-1).each do |offset|
it "put_char(#{offset}, #{i}).get_char(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_char(offset, i).get_char(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_char(offset, i).get_char(offset).should eq i
end
end
end
@@ -50,7 +50,7 @@ describe "Buffer#put_uchar" do
(0..255).each do |i|
(0..bufsize-1).each do |offset|
it "Buffer.put_uchar(#{offset}, #{i}).get_uchar(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_uchar(offset, i).get_uchar(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_uchar(offset, i).get_uchar(offset).should eq i
end
end
end
@@ -60,7 +60,7 @@ describe "Buffer#put_short" do
[0, 1, 128, 32767].each do |i|
(0..bufsize-2).each do |offset|
it "put_short(#{offset}, #{i}).get_short(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_short(offset, i).get_short(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_short(offset, i).get_short(offset).should eq i
end
end
end
@@ -70,7 +70,7 @@ describe "Buffer#put_ushort" do
[ 0, 1, 128, 32767, 65535, 0xfee1, 0xdead, 0xbeef, 0xcafe ].each do |i|
(0..bufsize-2).each do |offset|
it "put_ushort(#{offset}, #{i}).get_ushort(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_ushort(offset, i).get_ushort(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_ushort(offset, i).get_ushort(offset).should eq i
end
end
end
@@ -80,7 +80,7 @@ describe "Buffer#put_int" do
[0, 1, 128, 32767, 0x7ffffff ].each do |i|
(0..bufsize-4).each do |offset|
it "put_int(#{offset}, #{i}).get_int(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_int(offset, i).get_int(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_int(offset, i).get_int(offset).should eq i
end
end
end
@@ -90,7 +90,7 @@ describe "Buffer#put_uint" do
[ 0, 1, 128, 32767, 65535, 0xfee1dead, 0xcafebabe, 0xffffffff ].each do |i|
(0..bufsize-4).each do |offset|
it "put_uint(#{offset}, #{i}).get_uint(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_uint(offset, i).get_uint(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_uint(offset, i).get_uint(offset).should eq i
end
end
end
@@ -100,7 +100,7 @@ describe "Buffer#put_long" do
[0, 1, 128, 32767, 0x7ffffff ].each do |i|
(0..bufsize-FFI::Type::LONG.size).each do |offset|
it "put_long(#{offset}, #{i}).get_long(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_long(offset, i).get_long(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_long(offset, i).get_long(offset).should eq i
end
end
end
@@ -110,7 +110,7 @@ describe "Buffer#put_ulong" do
[ 0, 1, 128, 32767, 65535, 0xfee1dead, 0xcafebabe, 0xffffffff ].each do |i|
(0..bufsize-FFI::Type::LONG.size).each do |offset|
it "put_ulong(#{offset}, #{i}).get_ulong(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_ulong(offset, i).get_ulong(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_ulong(offset, i).get_ulong(offset).should eq i
end
end
end
@@ -120,7 +120,7 @@ describe "Buffer#put_long_long" do
[0, 1, 128, 32767, 0x7ffffffffffffff ].each do |i|
(0..bufsize-8).each do |offset|
it "put_long_long(#{offset}, #{i}).get_long_long(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_long_long(offset, i).get_long_long(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_long_long(offset, i).get_long_long(offset).should eq i
end
end
end
@@ -130,7 +130,7 @@ describe "Buffer#put_ulong_long" do
[ 0, 1, 128, 32767, 65535, 0xdeadcafebabe, 0x7fffffffffffffff ].each do |i|
(0..bufsize-8).each do |offset|
it "put_ulong_long(#{offset}, #{i}).get_ulong_long(#{offset}) == #{i}" do
- FFI::Buffer.alloc_in(bufsize).put_ulong_long(offset, i).get_ulong_long(offset).should == i
+ FFI::Buffer.alloc_in(bufsize).put_ulong_long(offset, i).get_ulong_long(offset).should eq i
end
end
end
@@ -141,21 +141,21 @@ describe "Reading/Writing binary strings" do
buf = FFI::Buffer.new 1024
buf.put_bytes(0, str);
s2 = buf.get_bytes(0, 11);
- s2.should == str
+ s2.should eq str
end
it "Buffer#put_bytes with index and length" do
str = "hello\0world"
buf = FFI::Buffer.new 1024
buf.put_bytes(0, str, 5, 6);
s2 = buf.get_bytes(0, 6);
- s2.should == str[5..-1]
+ s2.should eq str[5..-1]
end
it "Buffer#put_bytes with only index" do
str = "hello\0world"
buf = FFI::Buffer.new 1024
buf.put_bytes(0, str, 5);
s2 = buf.get_bytes(0, 6);
- s2.should == str[5..-1]
+ s2.should eq str[5..-1]
end
it "Buffer#put_bytes with index > str.length" do
str = "hello\0world"
@@ -179,21 +179,21 @@ describe "Reading/Writing ascii strings" do
buf = FFI::Buffer.new 1024
buf.put_string(0, str);
s2 = buf.get_bytes(0, 11);
- s2.should == str
+ s2.should eq str
end
it "Buffer#get_string with string containing zero byte" do
str = "hello\0world"
buf = FFI::Buffer.new 1024
buf.put_bytes(0, str);
s2 = buf.get_string(0, 11);
- s2.should == "hello"
+ s2.should eq "hello"
end
it "Buffer#put_string without length should NUL terminate" do
str = "hello"
buf = FFI::Buffer.new 1024
buf.put_string(0, str);
s2 = buf.get_bytes(0, 6);
- s2.should == "hello\0"
+ s2.should eq "hello\0"
end
end
describe "Buffer#put_pointer" do
@@ -203,13 +203,13 @@ describe "Buffer#put_pointer" do
buf = FFI::Buffer.alloc_inout 8
p2 = buf.put_pointer(0, p).get_pointer(0)
p2.should_not be_nil
- p2.should == p
- p2.get_uint(0).should == 0xdeadbeef
+ p2.should eq p
+ p2.get_uint(0).should eq 0xdeadbeef
end
end
describe "Buffer#size" do
it "should return size" do
buf = FFI::Buffer.new 14
- buf.size.should == 14
+ buf.size.should eq 14
end
-end \ No newline at end of file
+end
diff --git a/spec/ffi/callback_spec.rb b/spec/ffi/callback_spec.rb
index 8a0f29c..5684437 100644
--- a/spec/ffi/callback_spec.rb
+++ b/spec/ffi/callback_spec.rb
@@ -29,7 +29,7 @@ describe "Callback" do
# cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end
# # this is a bit dodgey, as it relies on qsort passing the args in order
# LibC.qsort(p, 2, 4, cmp)
-# args.should == [ 1, 2 ]
+# args.should eq [ 1, 2 ]
# end
#
# it "Block can be substituted for Callback as last argument" do
@@ -42,7 +42,7 @@ describe "Callback" do
# args.push(p2.get_int(0))
# 0
# end
-# args.should == [ 1, 2 ]
+# args.should eq [ 1, 2 ]
# end
module LibTest
extend FFI::Library
@@ -100,138 +100,138 @@ describe "Callback" do
lambda { LibTest.testCallbackCrV { |*a| }}.should raise_error
end
it "returning :char (0)" do
- LibTest.testCallbackVrS8 { 0 }.should == 0
+ LibTest.testCallbackVrS8 { 0 }.should eq 0
end
it "returning :char (127)" do
- LibTest.testCallbackVrS8 { 127 }.should == 127
+ LibTest.testCallbackVrS8 { 127 }.should eq 127
end
it "returning :char (-128)" do
- LibTest.testCallbackVrS8 { -128 }.should == -128
+ LibTest.testCallbackVrS8 { -128 }.should eq(-128)
end
# test wrap around
it "returning :char (128)" do
- LibTest.testCallbackVrS8 { 128 }.should == -128
+ LibTest.testCallbackVrS8 { 128 }.should eq(-128)
end
it "returning :char (255)" do
- LibTest.testCallbackVrS8 { 0xff }.should == -1
+ LibTest.testCallbackVrS8 { 0xff }.should eq(-1)
end
it "returning :uchar (0)" do
- LibTest.testCallbackVrU8 { 0 }.should == 0
+ LibTest.testCallbackVrU8 { 0 }.should eq 0
end
it "returning :uchar (0xff)" do
- LibTest.testCallbackVrU8 { 0xff }.should == 0xff
+ LibTest.testCallbackVrU8 { 0xff }.should eq 0xff
end
it "returning :uchar (-1)" do
- LibTest.testCallbackVrU8 { -1 }.should == 0xff
+ LibTest.testCallbackVrU8 { -1 }.should eq 0xff
end
it "returning :uchar (128)" do
- LibTest.testCallbackVrU8 { 128 }.should == 128
+ LibTest.testCallbackVrU8 { 128 }.should eq 128
end
it "returning :uchar (-128)" do
- LibTest.testCallbackVrU8 { -128 }.should == 128
+ LibTest.testCallbackVrU8 { -128 }.should eq 128
end
it "returning :short (0)" do
- LibTest.testCallbackVrS16 { 0 }.should == 0
+ LibTest.testCallbackVrS16 { 0 }.should eq 0
end
it "returning :short (0x7fff)" do
- LibTest.testCallbackVrS16 { 0x7fff }.should == 0x7fff
+ LibTest.testCallbackVrS16 { 0x7fff }.should eq 0x7fff
end
# test wrap around
it "returning :short (0x8000)" do
- LibTest.testCallbackVrS16 { 0x8000 }.should == -0x8000
+ LibTest.testCallbackVrS16 { 0x8000 }.should eq(-0x8000)
end
it "returning :short (0xffff)" do
- LibTest.testCallbackVrS16 { 0xffff }.should == -1
+ LibTest.testCallbackVrS16 { 0xffff }.should eq(-1)
end
it "returning :ushort (0)" do
- LibTest.testCallbackVrU16 { 0 }.should == 0
+ LibTest.testCallbackVrU16 { 0 }.should eq 0
end
it "returning :ushort (0x7fff)" do
- LibTest.testCallbackVrU16 { 0x7fff }.should == 0x7fff
+ LibTest.testCallbackVrU16 { 0x7fff }.should eq 0x7fff
end
it "returning :ushort (0x8000)" do
- LibTest.testCallbackVrU16 { 0x8000 }.should == 0x8000
+ LibTest.testCallbackVrU16 { 0x8000 }.should eq 0x8000
end
it "returning :ushort (0xffff)" do
- LibTest.testCallbackVrU16 { 0xffff }.should == 0xffff
+ LibTest.testCallbackVrU16 { 0xffff }.should eq 0xffff
end
it "returning :ushort (-1)" do
- LibTest.testCallbackVrU16 { -1 }.should == 0xffff
+ LibTest.testCallbackVrU16 { -1 }.should eq 0xffff
end
it "returning :int (0)" do
- LibTest.testCallbackVrS32 { 0 }.should == 0
+ LibTest.testCallbackVrS32 { 0 }.should eq 0
end
it "returning :int (0x7fffffff)" do
- LibTest.testCallbackVrS32 { 0x7fffffff }.should == 0x7fffffff
+ LibTest.testCallbackVrS32 { 0x7fffffff }.should eq 0x7fffffff
end
# test wrap around
it "returning :int (-0x80000000)" do
- LibTest.testCallbackVrS32 { -0x80000000 }.should == -0x80000000
+ LibTest.testCallbackVrS32 { -0x80000000 }.should eq(-0x80000000)
end
it "returning :int (-1)" do
- LibTest.testCallbackVrS32 { -1 }.should == -1
+ LibTest.testCallbackVrS32 { -1 }.should eq(-1)
end
it "returning :uint (0)" do
- LibTest.testCallbackVrU32 { 0 }.should == 0
+ LibTest.testCallbackVrU32 { 0 }.should eq 0
end
it "returning :uint (0x7fffffff)" do
- LibTest.testCallbackVrU32 { 0x7fffffff }.should == 0x7fffffff
+ LibTest.testCallbackVrU32 { 0x7fffffff }.should eq 0x7fffffff
end
# test wrap around
it "returning :uint (0x80000000)" do
- LibTest.testCallbackVrU32 { 0x80000000 }.should == 0x80000000
+ LibTest.testCallbackVrU32 { 0x80000000 }.should eq 0x80000000
end
it "returning :uint (0xffffffff)" do
- LibTest.testCallbackVrU32 { 0xffffffff }.should == 0xffffffff
+ LibTest.testCallbackVrU32 { 0xffffffff }.should eq 0xffffffff
end
it "returning :uint (-1)" do
- LibTest.testCallbackVrU32 { -1 }.should == 0xffffffff
+ LibTest.testCallbackVrU32 { -1 }.should eq 0xffffffff
end
it "returning :long (0)" do
- LibTest.testCallbackVrL { 0 }.should == 0
+ LibTest.testCallbackVrL { 0 }.should eq 0
end
it "returning :long (0x7fffffff)" do
- LibTest.testCallbackVrL { 0x7fffffff }.should == 0x7fffffff
+ LibTest.testCallbackVrL { 0x7fffffff }.should eq 0x7fffffff
end
# test wrap around
it "returning :long (-0x80000000)" do
- LibTest.testCallbackVrL { -0x80000000 }.should == -0x80000000
+ LibTest.testCallbackVrL { -0x80000000 }.should eq(-0x80000000)
end
it "returning :long (-1)" do
- LibTest.testCallbackVrL { -1 }.should == -1
+ LibTest.testCallbackVrL { -1 }.should eq(-1)
end
it "returning :ulong (0)" do
- LibTest.testCallbackVrUL { 0 }.should == 0
+ LibTest.testCallbackVrUL { 0 }.should eq 0
end
it "returning :ulong (0x7fffffff)" do
- LibTest.testCallbackVrUL { 0x7fffffff }.should == 0x7fffffff
+ LibTest.testCallbackVrUL { 0x7fffffff }.should eq 0x7fffffff
end
# test wrap around
it "returning :ulong (0x80000000)" do
- LibTest.testCallbackVrUL { 0x80000000 }.should == 0x80000000
+ LibTest.testCallbackVrUL { 0x80000000 }.should eq 0x80000000
end
it "returning :ulong (0xffffffff)" do
- LibTest.testCallbackVrUL { 0xffffffff }.should == 0xffffffff
+ LibTest.testCallbackVrUL { 0xffffffff }.should eq 0xffffffff
end
it "Callback returning :ulong (-1)" do
if FFI::Platform::LONG_SIZE == 32
- LibTest.testCallbackVrUL { -1 }.should == 0xffffffff
+ LibTest.testCallbackVrUL { -1 }.should eq 0xffffffff
else
- LibTest.testCallbackVrUL { -1 }.should == 0xffffffffffffffff
+ LibTest.testCallbackVrUL { -1 }.should eq 0xffffffffffffffff
end
end
it "returning :long_long (0)" do
- LibTest.testCallbackVrS64 { 0 }.should == 0
+ LibTest.testCallbackVrS64 { 0 }.should eq 0
end
it "returning :long_long (0x7fffffffffffffff)" do
- LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should == 0x7fffffffffffffff
+ LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should eq 0x7fffffffffffffff
end
# test wrap around
it "returning :long_long (-0x8000000000000000)" do
- LibTest.testCallbackVrS64 { -0x8000000000000000 }.should == -0x8000000000000000
+ LibTest.testCallbackVrS64 { -0x8000000000000000 }.should eq(-0x8000000000000000)
end
it "returning :long_long (-1)" do
- LibTest.testCallbackVrS64 { -1 }.should == -1
+ LibTest.testCallbackVrS64 { -1 }.should eq(-1)
end
it "returning bool" do
LibTest.testCallbackVrZ { true }.should be_true
@@ -241,7 +241,7 @@ describe "Callback" do
end
it "returning :pointer (MemoryPointer)" do
p = FFI::MemoryPointer.new :long
- LibTest.testCallbackVrP { p }.should == p
+ LibTest.testCallbackVrP { p }.should eq p
end
@@ -251,9 +251,9 @@ describe "Callback" do
s[:s32] = 0x1eefbeef
s[:f32] = 1.234567
ret = LibTest.testCallbackVrT { s }
- ret[:s8].should == s[:s8]
- ret[:f32].should == s[:f32]
- ret[:s32].should == s[:s32]
+ ret[:s8].should eq s[:s8]
+ ret[:f32].should eq s[:f32]
+ ret[:s32].should eq s[:s32]
end
@@ -274,7 +274,7 @@ describe "Callback" do
it "global variable" do
proc = Proc.new { 0x1e }
LibTest.cbVrS8 = proc
- LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should == 0x1e
+ LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should eq 0x1e
end
describe "When the callback is considered optional by the underlying library" do
@@ -290,7 +290,7 @@ describe "Callback" do
ffi_lib TestLibrary::PATH
attach_function :testCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
end
- LibTest.testCallbackVrS8 { 0 }.should == 0
+ LibTest.testCallbackVrS8 { 0 }.should eq 0
end
end
@@ -328,7 +328,7 @@ describe "Callback" do
end
val = LibTest.testReturnsCallback(lookup_proc, 0x1234)
- val.should == 0x1234 * 2
+ val.should eq 0x1234 * 2
lookup_proc_called.should be_true
return_proc_called.should be_true
end
@@ -350,7 +350,7 @@ describe "Callback" do
end
end
- LibTest.testReturnsCallback(MethodCallback.method(:lookup), 0x1234).should == 0x2468
+ LibTest.testReturnsCallback(MethodCallback.method(:lookup), 0x1234).should eq 0x2468
end
it 'should not blow up when a callback takes a callback as argument' do
@@ -381,7 +381,7 @@ describe "Callback" do
cb.call(val)
end
val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
- val.should == 0xff1 * 2
+ val.should eq 0xff1 * 2
callback_arg_called.should be_true
callback_with_callback_arg_called.should be_true
end
@@ -393,7 +393,7 @@ describe "Callback" do
attach_function :testReturnsFunctionPointer, [ ], :funcptr
end
f = LibTest.testReturnsFunctionPointer
- f.call(3).should == 6
+ f.call(3).should eq 6
end
end
@@ -447,83 +447,83 @@ describe "Callback with " do
it ":char (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackCrV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":char (127) argument" do
v = 0xdeadbeef
LibTest.testCallbackCrV(127) { |i| v = i }
- v.should == 127
+ v.should eq 127
end
it ":char (-128) argument" do
v = 0xdeadbeef
LibTest.testCallbackCrV(-128) { |i| v = i }
- v.should == -128
+ v.should eq(-128)
end
it ":char (-1) argument" do
v = 0xdeadbeef
LibTest.testCallbackCrV(-1) { |i| v = i }
- v.should == -1
+ v.should eq(-1)
end
it ":uchar (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackU8rV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":uchar (127) argument" do
v = 0xdeadbeef
LibTest.testCallbackU8rV(127) { |i| v = i }
- v.should == 127
+ v.should eq 127
end
it ":uchar (128) argument" do
v = 0xdeadbeef
LibTest.testCallbackU8rV(128) { |i| v = i }
- v.should == 128
+ v.should eq 128
end
it ":uchar (255) argument" do
v = 0xdeadbeef
LibTest.testCallbackU8rV(255) { |i| v = i }
- v.should == 255
+ v.should eq 255
end
it ":short (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackSrV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":short (0x7fff) argument" do
v = 0xdeadbeef
LibTest.testCallbackSrV(0x7fff) { |i| v = i }
- v.should == 0x7fff
+ v.should eq 0x7fff
end
it ":short (-0x8000) argument" do
v = 0xdeadbeef
LibTest.testCallbackSrV(-0x8000) { |i| v = i }
- v.should == -0x8000
+ v.should eq(-0x8000)
end
it ":short (-1) argument" do
v = 0xdeadbeef
LibTest.testCallbackSrV(-1) { |i| v = i }
- v.should == -1
+ v.should eq(-1)
end
it ":ushort (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackU16rV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":ushort (0x7fff) argument" do
v = 0xdeadbeef
LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
- v.should == 0x7fff
+ v.should eq 0x7fff
end
it ":ushort (0x8000) argument" do
v = 0xdeadbeef
LibTest.testCallbackU16rV(0x8000) { |i| v = i }
- v.should == 0x8000
+ v.should eq 0x8000
end
it ":ushort (0xffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackU16rV(0xffff) { |i| v = i }
- v.should == 0xffff
+ v.should eq 0xffff
end
it ":bool (true) argument" do
v = false
@@ -533,107 +533,107 @@ describe "Callback with " do
it ":int (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackIrV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":int (0x7fffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
- v.should == 0x7fffffff
+ v.should eq 0x7fffffff
end
it ":int (-0x80000000) argument" do
v = 0xdeadbeef
LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
- v.should == -0x80000000
+ v.should eq(-0x80000000)
end
it ":int (-1) argument" do
v = 0xdeadbeef
LibTest.testCallbackIrV(-1) { |i| v = i }
- v.should == -1
+ v.should eq(-1)
end
it ":uint (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackU32rV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":uint (0x7fffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
- v.should == 0x7fffffff
+ v.should eq 0x7fffffff
end
it ":uint (0x80000000) argument" do
v = 0xdeadbeef
LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
- v.should == 0x80000000
+ v.should eq 0x80000000
end
it ":uint (0xffffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
- v.should == 0xffffffff
+ v.should eq 0xffffffff
end
it ":long (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackLrV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":long (0x7fffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
- v.should == 0x7fffffff
+ v.should eq 0x7fffffff
end
it ":long (-0x80000000) argument" do
v = 0xdeadbeef
LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
- v.should == -0x80000000
+ v.should eq(-0x80000000)
end
it ":long (-1) argument" do
v = 0xdeadbeef
LibTest.testCallbackLrV(-1) { |i| v = i }
- v.should == -1
+ v.should eq(-1)
end
it ":ulong (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackULrV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":ulong (0x7fffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
- v.should == 0x7fffffff
+ v.should eq 0x7fffffff
end
it ":ulong (0x80000000) argument" do
v = 0xdeadbeef
LibTest.testCallbackULrV(0x80000000) { |i| v = i }
- v.should == 0x80000000
+ v.should eq 0x80000000
end
it ":ulong (0xffffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
- v.should == 0xffffffff
+ v.should eq 0xffffffff
end
it ":long_long (0) argument" do
v = 0xdeadbeef
LibTest.testCallbackLLrV(0) { |i| v = i }
- v.should == 0
+ v.should eq 0
end
it ":long_long (0x7fffffffffffffff) argument" do
v = 0xdeadbeef
LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
- v.should == 0x7fffffffffffffff
+ v.should eq 0x7fffffffffffffff
end
it ":long_long (-0x8000000000000000) argument" do
v = 0xdeadbeef
LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
- v.should == -0x8000000000000000
+ v.should eq(-0x8000000000000000)
end
it ":long_long (-1) argument" do
v = 0xdeadbeef
LibTest.testCallbackLLrV(-1) { |i| v = i }
- v.should == -1
+ v.should eq(-1)
end
it ":string argument" do
v = nil
LibTest.testCallbackArV("Hello, World") { |i| v = i }
- v.should == "Hello, World"
+ v.should eq "Hello, World"
end
it ":string (nil) argument" do
v = "Hello, World"
@@ -644,18 +644,18 @@ describe "Callback with " do
v = nil
magic = FFI::Pointer.new(0xdeadbeef)
LibTest.testCallbackPrV(magic) { |i| v = i }
- v.should == magic
+ v.should eq magic
end
it ":pointer (nil) argument" do
v = "Hello, World"
LibTest.testCallbackPrV(nil) { |i| v = i }
- v.should == FFI::Pointer::NULL
+ v.should eq FFI::Pointer::NULL
end
it "struct by reference argument" do
v = nil
magic = LibTest::S8F32S32.new
LibTest.testCallbackYrV(magic) { |i| v = i }
- v.class.should == magic.class
+ v.class.should eq magic.class
v.pointer == magic.pointer
end
@@ -663,7 +663,7 @@ describe "Callback with " do
v = LibTest::S8F32S32.new
LibTest.testCallbackYrV(nil) { |i| v = i }
v.is_a?(FFI::Struct).should be_true
- v.pointer.should == FFI::Pointer::NULL
+ v.pointer.should eq FFI::Pointer::NULL
end
end # unless true
diff --git a/spec/ffi/dup_spec.rb b/spec/ffi/dup_spec.rb
index 8966efb..d5bf4d6 100644
--- a/spec/ffi/dup_spec.rb
+++ b/spec/ffi/dup_spec.rb
@@ -24,7 +24,7 @@ describe "Pointer#dup" do
p2 = p1.dup
p1.put_string(0, "deadbeef")
- p2.get_string(0).should == "test123"
+ p2.get_string(0).should eq "test123"
end
it "sliced pointer can be cloned" do
@@ -33,8 +33,8 @@ describe "Pointer#dup" do
p2 = p1[1].dup
# first char will be excised
- p2.get_string(0).should == "est123"
- p1.get_string(0).should == "test123"
+ p2.get_string(0).should eq "est123"
+ p1.get_string(0).should eq "test123"
end
it "sliced pointer when cloned is independent" do
@@ -44,7 +44,7 @@ describe "Pointer#dup" do
p1.put_string(0, "deadbeef")
# first char will be excised
- p2.get_string(0).should == "est123"
+ p2.get_string(0).should eq "est123"
end
end
@@ -58,8 +58,8 @@ describe "Struct#dup" do
s1[:i] = 0x12345
s2 = s1.dup
s1[:i] = 0x98765
- s2[:i].should == 0x12345
- s1[:i].should == 0x98765
+ s2[:i].should eq 0x12345
+ s1[:i].should eq 0x98765
end
-end \ No newline at end of file
+end
diff --git a/spec/ffi/enum_spec.rb b/spec/ffi/enum_spec.rb
index 72796a0..db6d6d2 100644
--- a/spec/ffi/enum_spec.rb
+++ b/spec/ffi/enum_spec.rb
@@ -49,179 +49,179 @@ end
describe "A library with no enum defined" do
it "returns nil when asked for an enum" do
- TestEnum0.enum_type(:foo).should == nil
+ TestEnum0.enum_type(:foo).should eq nil
end
end
describe "An untagged enum" do
it "constants can be used as function parameters and return value" do
- TestEnum1.test_untagged_enum(:c1).should == 0
- TestEnum1.test_untagged_enum(:c2).should == 1
- TestEnum1.test_untagged_enum(:c3).should == 2
- TestEnum1.test_untagged_enum(:c4).should == 3
- TestEnum1.test_untagged_enum(:c5).should == 42
- TestEnum1.test_untagged_enum(:c6).should == 43
- TestEnum1.test_untagged_enum(:c7).should == 44
- TestEnum1.test_untagged_enum(:c8).should == 45
- TestEnum1.test_untagged_enum(:c9).should == 42
- TestEnum1.test_untagged_enum(:c10).should == 43
- TestEnum1.test_untagged_enum(:c11).should == 4242
- TestEnum1.test_untagged_enum(:c12).should == 4243
- TestEnum1.test_untagged_enum(:c13).should == 42
- TestEnum1.test_untagged_enum(:c14).should == 4242
- TestEnum1.test_untagged_enum(:c15).should == 424242
- TestEnum1.test_untagged_enum(:c16).should == 42424242
+ TestEnum1.test_untagged_enum(:c1).should eq 0
+ TestEnum1.test_untagged_enum(:c2).should eq 1
+ TestEnum1.test_untagged_enum(:c3).should eq 2
+ TestEnum1.test_untagged_enum(:c4).should eq 3
+ TestEnum1.test_untagged_enum(:c5).should eq 42
+ TestEnum1.test_untagged_enum(:c6).should eq 43
+ TestEnum1.test_untagged_enum(:c7).should eq 44
+ TestEnum1.test_untagged_enum(:c8).should eq 45
+ TestEnum1.test_untagged_enum(:c9).should eq 42
+ TestEnum1.test_untagged_enum(:c10).should eq 43
+ TestEnum1.test_untagged_enum(:c11).should eq 4242
+ TestEnum1.test_untagged_enum(:c12).should eq 4243
+ TestEnum1.test_untagged_enum(:c13).should eq 42
+ TestEnum1.test_untagged_enum(:c14).should eq 4242
+ TestEnum1.test_untagged_enum(:c15).should eq 424242
+ TestEnum1.test_untagged_enum(:c16).should eq 42424242
end
end
describe "A tagged typedef enum" do
it "is accessible through its tag" do
- TestEnum3.enum_type(:enum_type1).should_not == nil
- TestEnum3.enum_type(:enum_type2).should_not == nil
- TestEnum3.enum_type(:enum_type3).should_not == nil
- TestEnum3.enum_type(:enum_type4).should_not == nil
+ TestEnum3.enum_type(:enum_type1).should_not eq nil
+ TestEnum3.enum_type(:enum_type2).should_not eq nil
+ TestEnum3.enum_type(:enum_type3).should_not eq nil
+ TestEnum3.enum_type(:enum_type4).should_not eq nil
end
it "contains enum constants" do
- TestEnum3.enum_type(:enum_type1).symbols.length.should == 4
- TestEnum3.enum_type(:enum_type2).symbols.length.should == 4
- TestEnum3.enum_type(:enum_type3).symbols.length.should == 4
- TestEnum3.enum_type(:enum_type4).symbols.length.should == 4
+ TestEnum3.enum_type(:enum_type1).symbols.length.should eq 4
+ TestEnum3.enum_type(:enum_type2).symbols.length.should eq 4
+ TestEnum3.enum_type(:enum_type3).symbols.length.should eq 4
+ TestEnum3.enum_type(:enum_type4).symbols.length.should eq 4
end
it "constants can be used as function parameters and return value" do
- TestEnum3.test_tagged_typedef_enum1(:c1).should == :c1
- TestEnum3.test_tagged_typedef_enum1(:c2).should == :c2
- TestEnum3.test_tagged_typedef_enum1(:c3).should == :c3
- TestEnum3.test_tagged_typedef_enum1(:c4).should == :c4
- TestEnum3.test_tagged_typedef_enum2(:c5).should == :c5
- TestEnum3.test_tagged_typedef_enum2(:c6).should == :c6
- TestEnum3.test_tagged_typedef_enum2(:c7).should == :c7
- TestEnum3.test_tagged_typedef_enum2(:c8).should == :c8
- TestEnum3.test_tagged_typedef_enum3(:c9).should == :c9
- TestEnum3.test_tagged_typedef_enum3(:c10).should == :c10
- TestEnum3.test_tagged_typedef_enum3(:c11).should == :c11
- TestEnum3.test_tagged_typedef_enum3(:c12).should == :c12
- TestEnum3.test_tagged_typedef_enum4(:c13).should == :c13
- TestEnum3.test_tagged_typedef_enum4(:c14).should == :c14
- TestEnum3.test_tagged_typedef_enum4(:c15).should == :c15
- TestEnum3.test_tagged_typedef_enum4(:c16).should == :c16
+ TestEnum3.test_tagged_typedef_enum1(:c1).should eq :c1
+ TestEnum3.test_tagged_typedef_enum1(:c2).should eq :c2
+ TestEnum3.test_tagged_typedef_enum1(:c3).should eq :c3
+ TestEnum3.test_tagged_typedef_enum1(:c4).should eq :c4
+ TestEnum3.test_tagged_typedef_enum2(:c5).should eq :c5
+ TestEnum3.test_tagged_typedef_enum2(:c6).should eq :c6
+ TestEnum3.test_tagged_typedef_enum2(:c7).should eq :c7
+ TestEnum3.test_tagged_typedef_enum2(:c8).should eq :c8
+ TestEnum3.test_tagged_typedef_enum3(:c9).should eq :c9
+ TestEnum3.test_tagged_typedef_enum3(:c10).should eq :c10
+ TestEnum3.test_tagged_typedef_enum3(:c11).should eq :c11
+ TestEnum3.test_tagged_typedef_enum3(:c12).should eq :c12
+ TestEnum3.test_tagged_typedef_enum4(:c13).should eq :c13
+ TestEnum3.test_tagged_typedef_enum4(:c14).should eq :c14
+ TestEnum3.test_tagged_typedef_enum4(:c15).should eq :c15
+ TestEnum3.test_tagged_typedef_enum4(:c16).should eq :c16
end
it "integers can be used instead of constants" do
- TestEnum3.test_tagged_typedef_enum1(0).should == :c1
- TestEnum3.test_tagged_typedef_enum1(1).should == :c2
- TestEnum3.test_tagged_typedef_enum1(2).should == :c3
- TestEnum3.test_tagged_typedef_enum1(3).should == :c4
- TestEnum3.test_tagged_typedef_enum2(42).should == :c5
- TestEnum3.test_tagged_typedef_enum2(43).should == :c6
- TestEnum3.test_tagged_typedef_enum2(44).should == :c7
- TestEnum3.test_tagged_typedef_enum2(45).should == :c8
- TestEnum3.test_tagged_typedef_enum3(42).should == :c9
- TestEnum3.test_tagged_typedef_enum3(43).should == :c10
- TestEnum3.test_tagged_typedef_enum3(4242).should == :c11
- TestEnum3.test_tagged_typedef_enum3(4243).should == :c12
- TestEnum3.test_tagged_typedef_enum4(42).should == :c13
- TestEnum3.test_tagged_typedef_enum4(4242).should == :c14
- TestEnum3.test_tagged_typedef_enum4(424242).should == :c15
- TestEnum3.test_tagged_typedef_enum4(42424242).should == :c16
+ TestEnum3.test_tagged_typedef_enum1(0).should eq :c1
+ TestEnum3.test_tagged_typedef_enum1(1).should eq :c2
+ TestEnum3.test_tagged_typedef_enum1(2).should eq :c3
+ TestEnum3.test_tagged_typedef_enum1(3).should eq :c4
+ TestEnum3.test_tagged_typedef_enum2(42).should eq :c5
+ TestEnum3.test_tagged_typedef_enum2(43).should eq :c6
+ TestEnum3.test_tagged_typedef_enum2(44).should eq :c7
+ TestEnum3.test_tagged_typedef_enum2(45).should eq :c8
+ TestEnum3.test_tagged_typedef_enum3(42).should eq :c9
+ TestEnum3.test_tagged_typedef_enum3(43).should eq :c10
+ TestEnum3.test_tagged_typedef_enum3(4242).should eq :c11
+ TestEnum3.test_tagged_typedef_enum3(4243).should eq :c12
+ TestEnum3.test_tagged_typedef_enum4(42).should eq :c13
+ TestEnum3.test_tagged_typedef_enum4(4242).should eq :c14
+ TestEnum3.test_tagged_typedef_enum4(424242).should eq :c15
+ TestEnum3.test_tagged_typedef_enum4(42424242).should eq :c16
end
end
describe "All enums" do
it "have autonumbered constants when defined with names only" do
- TestEnum1.enum_value(:c1).should == 0
- TestEnum1.enum_value(:c2).should == 1
- TestEnum1.enum_value(:c3).should == 2
- TestEnum1.enum_value(:c4).should == 3
-
- TestEnum3.enum_value(:c1).should == 0
- TestEnum3.enum_value(:c2).should == 1
- TestEnum3.enum_value(:c3).should == 2
- TestEnum3.enum_value(:c4).should == 3
+ TestEnum1.enum_value(:c1).should eq 0
+ TestEnum1.enum_value(:c2).should eq 1
+ TestEnum1.enum_value(:c3).should eq 2
+ TestEnum1.enum_value(:c4).should eq 3
+
+ TestEnum3.enum_value(:c1).should eq 0
+ TestEnum3.enum_value(:c2).should eq 1
+ TestEnum3.enum_value(:c3).should eq 2
+ TestEnum3.enum_value(:c4).should eq 3
end
it "can have an explicit first constant and autonumbered subsequent constants" do
- TestEnum1.enum_value(:c5).should == 42
- TestEnum1.enum_value(:c6).should == 43
- TestEnum1.enum_value(:c7).should == 44
- TestEnum1.enum_value(:c8).should == 45
-
- TestEnum3.enum_value(:c5).should == 42
- TestEnum3.enum_value(:c6).should == 43
- TestEnum3.enum_value(:c7).should == 44
- TestEnum3.enum_value(:c8).should == 45
+ TestEnum1.enum_value(:c5).should eq 42
+ TestEnum1.enum_value(:c6).should eq 43
+ TestEnum1.enum_value(:c7).should eq 44
+ TestEnum1.enum_value(:c8).should eq 45
+
+ TestEnum3.enum_value(:c5).should eq 42
+ TestEnum3.enum_value(:c6).should eq 43
+ TestEnum3.enum_value(:c7).should eq 44
+ TestEnum3.enum_value(:c8).should eq 45
end
it "can have a mix of explicit and autonumbered constants" do
- TestEnum1.enum_value(:c9).should == 42
- TestEnum1.enum_value(:c10).should == 43
- TestEnum1.enum_value(:c11).should == 4242
- TestEnum1.enum_value(:c12).should == 4243
-
- TestEnum3.enum_value(:c9).should == 42
- TestEnum3.enum_value(:c10).should == 43
- TestEnum3.enum_value(:c11).should == 4242
- TestEnum3.enum_value(:c12).should == 4243
+ TestEnum1.enum_value(:c9).should eq 42
+ TestEnum1.enum_value(:c10).should eq 43
+ TestEnum1.enum_value(:c11).should eq 4242
+ TestEnum1.enum_value(:c12).should eq 4243
+
+ TestEnum3.enum_value(:c9).should eq 42
+ TestEnum3.enum_value(:c10).should eq 43
+ TestEnum3.enum_value(:c11).should eq 4242
+ TestEnum3.enum_value(:c12).should eq 4243
end
it "can have all its constants explicitely valued" do
- TestEnum1.enum_value(:c13).should == 42
- TestEnum1.enum_value(:c14).should == 4242
- TestEnum1.enum_value(:c15).should == 424242
- TestEnum1.enum_value(:c16).should == 42424242
+ TestEnum1.enum_value(:c13).should eq 42
+ TestEnum1.enum_value(:c14).should eq 4242
+ TestEnum1.enum_value(:c15).should eq 424242
+ TestEnum1.enum_value(:c16).should eq 42424242
- TestEnum3.enum_value(:c13).should == 42
- TestEnum3.enum_value(:c14).should == 4242
- TestEnum3.enum_value(:c15).should == 424242
- TestEnum3.enum_value(:c16).should == 42424242
+ TestEnum3.enum_value(:c13).should eq 42
+ TestEnum3.enum_value(:c14).should eq 4242
+ TestEnum3.enum_value(:c15).should eq 424242
+ TestEnum3.enum_value(:c16).should eq 42424242
end
it "return the constant corresponding to a specific value" do
enum = TestEnum3.enum_type(:enum_type1)
- enum[0].should == :c1
- enum[1].should == :c2
- enum[2].should == :c3
- enum[3].should == :c4
+ enum[0].should eq :c1
+ enum[1].should eq :c2
+ enum[2].should eq :c3
+ enum[3].should eq :c4
enum = TestEnum3.enum_type(:enum_type2)
- enum[42].should == :c5
- enum[43].should == :c6
- enum[44].should == :c7
- enum[45].should == :c8
+ enum[42].should eq :c5
+ enum[43].should eq :c6
+ enum[44].should eq :c7
+ enum[45].should eq :c8
enum = TestEnum3.enum_type(:enum_type3)
- enum[42].should == :c9
- enum[43].should == :c10
- enum[4242].should == :c11
- enum[4243].should == :c12
+ enum[42].should eq :c9
+ enum[43].should eq :c10
+ enum[4242].should eq :c11
+ enum[4243].should eq :c12
enum = TestEnum3.enum_type(:enum_type4)
- enum[42].should == :c13
- enum[4242].should == :c14
- enum[424242].should == :c15
- enum[42424242].should == :c16
+ enum[42].should eq :c13
+ enum[4242].should eq :c14
+ enum[424242].should eq :c15
+ enum[42424242].should eq :c16
end
it "return nil for values that don't have a symbol" do
enum = TestEnum3.enum_type(:enum_type1)
- enum[-1].should == nil
- enum[4].should == nil
+ enum[-1].should eq nil
+ enum[4].should eq nil
enum = TestEnum3.enum_type(:enum_type2)
- enum[0].should == nil
- enum[41].should == nil
- enum[46].should == nil
+ enum[0].should eq nil
+ enum[41].should eq nil
+ enum[46].should eq nil
enum = TestEnum3.enum_type(:enum_type3)
- enum[0].should == nil
- enum[41].should == nil
- enum[44].should == nil
- enum[4241].should == nil
- enum[4244].should == nil
+ enum[0].should eq nil
+ enum[41].should eq nil
+ enum[44].should eq nil
+ enum[4241].should eq nil
+ enum[4244].should eq nil
enum = TestEnum3.enum_type(:enum_type4)
- enum[0].should == nil
- enum[41].should == nil
- enum[43].should == nil
- enum[4241].should == nil
- enum[4243].should == nil
- enum[424241].should == nil
- enum[424243].should == nil
- enum[42424241].should == nil
- enum[42424243].should == nil
+ enum[0].should eq nil
+ enum[41].should eq nil
+ enum[43].should eq nil
+ enum[4241].should eq nil
+ enum[4243].should eq nil
+ enum[424241].should eq nil
+ enum[424243].should eq nil
+ enum[42424241].should eq nil
+ enum[42424243].should eq nil
end
end
diff --git a/spec/ffi/errno_spec.rb b/spec/ffi/errno_spec.rb
index d9a0b86..db212ad 100644
--- a/spec/ffi/errno_spec.rb
+++ b/spec/ffi/errno_spec.rb
@@ -24,6 +24,6 @@ describe "FFI.errno" do
it "FFI.errno contains errno from last function" do
LibTest.setLastError(0)
LibTest.setLastError(0x12345678)
- FFI.errno.should == 0x12345678
+ FFI.errno.should eq 0x12345678
end
-end \ No newline at end of file
+end
diff --git a/spec/ffi/ffi_spec.rb b/spec/ffi/ffi_spec.rb
index e28446a..af52625 100644
--- a/spec/ffi/ffi_spec.rb
+++ b/spec/ffi/ffi_spec.rb
@@ -24,15 +24,15 @@ describe "FFI" do
let(:suffix) { FFI::Platform::LIBSUFFIX }
it "should add platform library extension if not present" do
- FFI.map_library_name("#{prefix}dummy").should == "#{prefix}dummy.#{suffix}"
+ FFI.map_library_name("#{prefix}dummy").should eq "#{prefix}dummy.#{suffix}"
end
it "should add platform library extension even if lib suffix is present in name" do
- FFI.map_library_name("#{prefix}dummy_with_#{suffix}").should == "#{prefix}dummy_with_#{suffix}.#{suffix}"
+ FFI.map_library_name("#{prefix}dummy_with_#{suffix}").should eq "#{prefix}dummy_with_#{suffix}.#{suffix}"
end
it "should return Platform::LIBC when called with 'c'" do
- FFI.map_library_name('c').should == FFI::Library::LIBC
+ FFI.map_library_name('c').should eq FFI::Library::LIBC
end
end
diff --git a/spec/ffi/function_spec.rb b/spec/ffi/function_spec.rb
index 89ea126..684962a 100644
--- a/spec/ffi/function_spec.rb
+++ b/spec/ffi/function_spec.rb
@@ -37,20 +37,20 @@ describe FFI::Function do
end
it 'can be used as callback from C passing to it a block' do
function_add = FFI::Function.new(:int, [:int, :int]) { |a, b| a + b }
- LibTest.testFunctionAdd(10, 10, function_add).should == 20
+ LibTest.testFunctionAdd(10, 10, function_add).should eq 20
end
it 'can be used as callback from C passing to it a Proc object' do
function_add = FFI::Function.new(:int, [:int, :int], Proc.new { |a, b| a + b })
- LibTest.testFunctionAdd(10, 10, function_add).should == 20
+ LibTest.testFunctionAdd(10, 10, function_add).should eq 20
end
it 'can be used to wrap an existing function pointer' do
- FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd')).call(10, 10).should == 20
+ FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd')).call(10, 10).should eq 20
end
it 'can be attached to a module' do
module Foo; end
fp = FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd'))
fp.attach(Foo, 'add')
- Foo.add(10, 10).should == 20
+ Foo.add(10, 10).should eq 20
end
it 'can be used to extend an object' do
fp = FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd'))
@@ -61,7 +61,7 @@ describe FFI::Function do
end
end
fp.attach(foo.singleton_class, 'add')
- foo.add(10, 10).should == 20
+ foo.add(10, 10).should eq 20
end
it 'can wrap a blocking function' do
fp = FFI::Function.new(:void, [ :int ], @libtest.find_function('testBlocking'), :blocking => true)
diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb
index 1b68bd5..5cfab93 100644
--- a/spec/ffi/library_spec.rb
+++ b/spec/ffi/library_spec.rb
@@ -18,20 +18,20 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
describe "Library" do
describe "#ffi_convention" do
it "defaults to :default" do
- Module.new do
+ m = Module.new do
extend FFI::Library
- ffi_convention.should == :default
end
+ m.ffi_convention.should eq :default
end
it "should be settable" do
- Module.new do
+ m = Module.new do
extend FFI::Library
-
- ffi_convention.should == :default
- ffi_convention :stdcall
- ffi_convention.should == :stdcall
end
+
+ m.ffi_convention.should eq :default
+ m.ffi_convention :stdcall
+ m.ffi_convention.should eq :stdcall
end
end
@@ -50,7 +50,7 @@ describe "Library" do
m.extend FFI::Library
ffi_lib FFI::Library::CURRENT_PROCESS
attach_function :getpid, [ ], :uint
- end.getpid.should == Process.pid
+ end.getpid.should eq Process.pid
}.should_not raise_error
end
it "attach_function :getpid from [ 'c', 'libc.so.6'] " do
@@ -59,7 +59,7 @@ describe "Library" do
m.extend FFI::Library
ffi_lib [ 'c', 'libc.so.6' ]
attach_function :getpid, [ ], :uint
- end.getpid.should == Process.pid
+ end.getpid.should eq Process.pid
}.should_not raise_error
end
it "attach_function :getpid from [ 'libc.so.6', 'c' ] " do
@@ -68,7 +68,7 @@ describe "Library" do
m.extend FFI::Library
ffi_lib [ 'libc.so.6', 'c' ]
attach_function :getpid, [ ], :uint
- end.getpid.should == Process.pid
+ end.getpid.should eq Process.pid
}.should_not raise_error
end
it "attach_function :getpid from [ 'libfubar.so.0xdeadbeef', nil, 'c' ] " do
@@ -77,7 +77,7 @@ describe "Library" do
m.extend FFI::Library
ffi_lib [ 'libfubar.so.0xdeadbeef', nil, 'c' ]
attach_function :getpid, [ ], :uint
- end.getpid.should == Process.pid
+ end.getpid.should eq Process.pid
}.should_not raise_error
end
it "attach_function :getpid from [ 'libfubar.so.0xdeadbeef' ] " do
@@ -86,7 +86,7 @@ describe "Library" do
m.extend FFI::Library
ffi_lib 'libfubar.so.0xdeadbeef'
attach_function :getpid, [ ], :uint
- end.getpid.should == Process.pid
+ end.getpid.should eq Process.pid
}.should raise_error(LoadError)
end
end
@@ -103,10 +103,10 @@ describe "Library" do
def gvar_test(name, type, val)
lib = gvar_lib(name, type)
lib.set(val)
- lib.gvar.should == val
+ lib.gvar.should eq val
lib.set(0)
lib.gvar = val
- lib.get.should == val
+ lib.get.should eq val
end
[ 0, 127, -128, -1 ].each do |i|
it ":char variable" do
@@ -175,10 +175,10 @@ describe "Library" do
lib = gvar_lib("pointer", :pointer)
val = FFI::MemoryPointer.new :long
lib.set(val)
- lib.gvar.should == val
+ lib.gvar.should eq val
lib.set(nil)
lib.gvar = val
- lib.get.should == val
+ lib.get.should eq val
end
[ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
@@ -198,11 +198,11 @@ describe "Library" do
val = GlobalStruct.new
val[:data] = i
lib.set(val)
- lib.gvar[:data].should == i
+ lib.gvar[:data].should eq i
val[:data] = 0
lib.gvar[:data] = i
val = GlobalStruct.new(lib.get)
- val[:data].should == i
+ val[:data].should eq i
end
end
end
diff --git a/spec/ffi/managed_struct_spec.rb b/spec/ffi/managed_struct_spec.rb
index 9cdd736..5713eee 100644
--- a/spec/ffi/managed_struct_spec.rb
+++ b/spec/ffi/managed_struct_spec.rb
@@ -36,7 +36,7 @@ describe "Managed Struct" do
end
end
- WhatClassAmI.new(LibTest.ptr_from_address(0x12345678)).class.should == WhatClassAmI
+ WhatClassAmI.new(LibTest.ptr_from_address(0x12345678)).class.should eq WhatClassAmI
end
it "should release memory properly" do
diff --git a/spec/ffi/number_spec.rb b/spec/ffi/number_spec.rb
index ffca8f8..b1fa7d3 100644
--- a/spec/ffi/number_spec.rb
+++ b/spec/ffi/number_spec.rb
@@ -37,95 +37,95 @@ describe "Function with primitive integer arguments" do
attach_function :get_double, [ ], :double
end
it "int8.size" do
- FFI::TYPE_INT8.size.should == 1
+ FFI::TYPE_INT8.size.should eq 1
end
it "uint8.size" do
- FFI::TYPE_UINT8.size.should == 1
+ FFI::TYPE_UINT8.size.should eq 1
end
it "int16.size" do
- FFI::TYPE_INT16.size.should == 2
+ FFI::TYPE_INT16.size.should eq 2
end
it "uint16.size" do
- FFI::TYPE_UINT16.size.should == 2
+ FFI::TYPE_UINT16.size.should eq 2
end
it "int32.size" do
- FFI::TYPE_INT32.size.should == 4
+ FFI::TYPE_INT32.size.should eq 4
end
it "uint32.size" do
- FFI::TYPE_UINT32.size.should == 4
+ FFI::TYPE_UINT32.size.should eq 4
end
it "int64.size" do
- FFI::TYPE_INT64.size.should == 8
+ FFI::TYPE_INT64.size.should eq 8
end
it "uint64.size" do
- FFI::TYPE_UINT64.size.should == 8
+ FFI::TYPE_UINT64.size.should eq 8
end
it "float.size" do
- FFI::TYPE_FLOAT32.size.should == 4
+ FFI::TYPE_FLOAT32.size.should eq 4
end
it "double.size" do
- FFI::TYPE_FLOAT64.size.should == 8
+ FFI::TYPE_FLOAT64.size.should eq 8
end
[ 0, 127, -128, -1 ].each do |i|
it ":char call(:char (#{i}))" do
- LibTest.ret_s8(i).should == i
+ LibTest.ret_s8(i).should eq i
end
end
[ 0, 0x7f, 0x80, 0xff ].each do |i|
it ":uchar call(:uchar (#{i}))" do
- LibTest.ret_u8(i).should == i
+ LibTest.ret_u8(i).should eq i
end
end
[ 0, 0x7fff, -0x8000, -1 ].each do |i|
it ":short call(:short (#{i}))" do
- LibTest.ret_s16(i).should == i
+ LibTest.ret_s16(i).should eq i
end
end
[ 0, 0x7fff, 0x8000, 0xffff ].each do |i|
it ":ushort call(:ushort (#{i}))" do
- LibTest.ret_u16(i).should == i
+ LibTest.ret_u16(i).should eq i
end
end
[ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
it ":int call(:int (#{i}))" do
- LibTest.ret_s32(i).should == i
+ LibTest.ret_s32(i).should eq i
end
end
[ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
it ":uint call(:uint (#{i}))" do
- LibTest.ret_u32(i).should == i
+ LibTest.ret_u32(i).should eq i
end
end
[ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
it ":long_long call(:long_long (#{i}))" do
- LibTest.ret_s64(i).should == i
+ LibTest.ret_s64(i).should eq i
end
end
[ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
it ":ulong_long call(:ulong_long (#{i}))" do
- LibTest.ret_u64(i).should == i
+ LibTest.ret_u64(i).should eq i
end
end
if FFI::Platform::LONG_SIZE == 32
[ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
it ":long call(:long (#{i}))" do
- LibTest.ret_long(i).should == i
+ LibTest.ret_long(i).should eq i
end
end
[ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
it ":ulong call(:ulong (#{i}))" do
- LibTest.ret_ulong(i).should == i
+ LibTest.ret_ulong(i).should eq i
end
end
else
[ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
it ":long call(:long (#{i}))" do
- LibTest.ret_long(i).should == i
+ LibTest.ret_long(i).should eq i
end
end
[ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
it ":ulong call(:ulong (#{i}))" do
- LibTest.ret_ulong(i).should == i
+ LibTest.ret_ulong(i).should eq i
end
end
[ 0.0, 0.1, 1.1, 1.23 ].each do |f|
@@ -145,32 +145,32 @@ end
describe "Integer parameter range checking" do
[ 128, -129 ].each do |i|
it ":char call(:char (#{i}))" do
- lambda { LibTest.ret_int8_t(i).should == i }.should raise_error
+ lambda { LibTest.ret_int8_t(i).should eq i }.should raise_error
end
end
[ -1, 256 ].each do |i|
it ":uchar call(:uchar (#{i}))" do
- lambda { LibTest.ret_u_int8_t(i).should == i }.should raise_error
+ lambda { LibTest.ret_u_int8_t(i).should eq i }.should raise_error
end
end
[ 0x8000, -0x8001 ].each do |i|
it ":short call(:short (#{i}))" do
- lambda { LibTest.ret_int16_t(i).should == i }.should raise_error
+ lambda { LibTest.ret_int16_t(i).should eq i }.should raise_error
end
end
[ -1, 0x10000 ].each do |i|
it ":ushort call(:ushort (#{i}))" do
- lambda { LibTest.ret_u_int16_t(i).should == i }.should raise_error
+ lambda { LibTest.ret_u_int16_t(i).should eq i }.should raise_error
end
end
[ 0x80000000, -0x80000001 ].each do |i|
it ":int call(:int (#{i}))" do
- lambda { LibTest.ret_int32_t(i).should == i }.should raise_error
+ lambda { LibTest.ret_int32_t(i).should eq i }.should raise_error
end
end
[ -1, 0x100000000 ].each do |i|
it ":ushort call(:ushort (#{i}))" do
- lambda { LibTest.ret_u_int32_t(i).should == i }.should raise_error
+ lambda { LibTest.ret_u_int32_t(i).should eq i }.should raise_error
end
end
end
@@ -214,17 +214,17 @@ describe "Three different size Integer arguments" do
# 'f32' => [ 1.234567 ],
'f64' => [ 9.87654321 ]
}
- module Number
- def self.verify(p, off, t, v)
- if t == 'f32'
- p.get_float32(off).should == v
- elsif t == 'f64'
- p.get_float64(off).should == v
- else
- p.get_int64(off).should == v
- end
+
+ def verify(p, off, t, v)
+ if t == 'f32'
+ p.get_float32(off).should eq v
+ elsif t == 'f64'
+ p.get_float64(off).should eq v
+ else
+ p.get_int64(off).should eq v
end
end
+
PACK_VALUES.keys.each do |t1|
PACK_VALUES.keys.each do |t2|
PACK_VALUES.keys.each do |t3|
@@ -234,9 +234,9 @@ describe "Three different size Integer arguments" do
it "call(#{TYPE_MAP[t1]} (#{v1}), #{TYPE_MAP[t2]} (#{v2}), #{TYPE_MAP[t3]} (#{v3}))" do
p = FFI::Buffer.new :long_long, 3
LibTest.send("pack_#{t1}#{t2}#{t3}_s64", v1, v2, v3, p)
- Number.verify(p, 0, t1, v1)
- Number.verify(p, 8, t2, v2)
- Number.verify(p, 16, t3, v3)
+ verify(p, 0, t1, v1)
+ verify(p, 8, t2, v2)
+ verify(p, 16, t3, v3)
end
end
end
diff --git a/spec/ffi/pointer_spec.rb b/spec/ffi/pointer_spec.rb
index 26dcfc1..56b791a 100644
--- a/spec/ffi/pointer_spec.rb
+++ b/spec/ffi/pointer_spec.rb
@@ -40,7 +40,7 @@ describe "Pointer" do
magic = 0x12345678
memory.put_int32(0, magic)
tp = ToPtrTest.new(memory)
- PointerTestLib.ptr_ret_int32_t(tp, 0).should == magic
+ PointerTestLib.ptr_ret_int32_t(tp, 0).should eq magic
end
class PointerDelegate < DelegateClass(FFI::Pointer)
def initialize(ptr)
@@ -55,7 +55,7 @@ describe "Pointer" do
magic = 0x12345678
memory.put_int32(0, magic)
ptr = PointerDelegate.new(memory)
- PointerTestLib.ptr_ret_int32_t(ptr, 0).should == magic
+ PointerTestLib.ptr_ret_int32_t(ptr, 0).should eq magic
end
it "Fixnum cannot be used as a Pointer argument" do
lambda { PointerTestLib.ptr_ret_int32(0, 0) }.should raise_error
@@ -69,13 +69,13 @@ describe "Pointer" do
it "#read_pointer" do
memory = FFI::MemoryPointer.new :pointer
PointerTestLib.ptr_set_pointer(memory, 0, PointerTestLib.ptr_from_address(0xdeadbeef))
- memory.read_pointer.address.should == 0xdeadbeef
+ memory.read_pointer.address.should eq 0xdeadbeef
end
it "#write_pointer" do
memory = FFI::MemoryPointer.new :pointer
memory.write_pointer(PointerTestLib.ptr_from_address(0xdeadbeef))
- PointerTestLib.ptr_ret_pointer(memory, 0).address.should == 0xdeadbeef
+ PointerTestLib.ptr_ret_pointer(memory, 0).address.should eq 0xdeadbeef
end
it "#read_array_of_pointer" do
@@ -86,7 +86,7 @@ describe "Pointer" do
end
array = memory.read_array_of_pointer(values.size)
values.each_with_index do |address, j|
- array[j].address.should == address
+ array[j].address.should eq address
end
end
diff --git a/spec/ffi/rbx/memory_pointer_spec.rb b/spec/ffi/rbx/memory_pointer_spec.rb
index 9a92e0c..ec3c5fc 100644
--- a/spec/ffi/rbx/memory_pointer_spec.rb
+++ b/spec/ffi/rbx/memory_pointer_spec.rb
@@ -12,44 +12,44 @@ end
describe "MemoryPointer" do
it "makes a pointer from a string" do
m = FFI::MemoryPointer.from_string("FFI is Awesome")
- m.total.should == 15
- m.type_size.should == 1
+ m.total.should eq 15
+ m.type_size.should eq 1
end
it "makes a pointer from a string with multibyte characters" do
m = FFI::MemoryPointer.from_string("ぱんだ")
- m.total.should == 10
- m.type_size.should == 1
+ m.total.should eq 10
+ m.type_size.should eq 1
end
it "reads back a string" do
m = FFI::MemoryPointer.from_string("FFI is Awesome")
- m.read_string.should == "FFI is Awesome"
+ m.read_string.should eq "FFI is Awesome"
end
it "makes a pointer for a certain number of bytes" do
m = FFI::MemoryPointer.new(8)
m.write_array_of_int([1,2])
- m.read_array_of_int(2).should == [1,2]
+ m.read_array_of_int(2).should eq [1,2]
end
it "allows access to an element of the pointer (as an array)" do
m = FFI::MemoryPointer.new(:int, 2)
m.write_array_of_int([1,2])
- m[0].read_int.should == 1
- m[1].read_int.should == 2
+ m[0].read_int.should eq 1
+ m[1].read_int.should eq 2
end
it "allows writing as an int" do
m = FFI::MemoryPointer.new(:int)
m.write_int(1)
- m.read_int.should == 1
+ m.read_int.should eq 1
end
it "allows writing as a long" do
m = FFI::MemoryPointer.new(:long)
m.write_long(10)
- m.read_long.should == 10
+ m.read_long.should eq 10
end
it "raises an error if you try putting a long into a pointer of size 1" do
@@ -72,40 +72,40 @@ describe "MemoryPointer" do
it "makes a pointer for a certain type" do
m = FFI::MemoryPointer.new(:int)
m.write_int(10)
- m.read_int.should == 10
+ m.read_int.should eq 10
end
it "makes a memory pointer for a number of a certain type" do
m = FFI::MemoryPointer.new(:int, 2)
m.write_array_of_int([1,2])
- m.read_array_of_int(2).should == [1,2]
+ m.read_array_of_int(2).should eq [1,2]
end
it "makes a pointer for an object responding to #size" do
m = FFI::MemoryPointer.new(Struct.new(:size).new(8))
m.write_array_of_int([1,2])
- m.read_array_of_int(2).should == [1,2]
+ m.read_array_of_int(2).should eq [1,2]
end
it "makes a pointer for a number of an object responding to #size" do
m = FFI::MemoryPointer.new(Struct.new(:size).new(4), 2)
m.write_array_of_int([1,2])
- m.read_array_of_int(2).should == [1,2]
+ m.read_array_of_int(2).should eq [1,2]
end
it "MemoryPointer#address returns correct value" do
m = FFI::MemoryPointer.new(:long_long)
magic = 0x12345678
m.write_long(magic)
- m.read_pointer.address.should == magic
+ m.read_pointer.address.should eq magic
end
it "MemoryPointer#null? returns true for zero value" do
m = FFI::MemoryPointer.new(:long_long)
m.write_long(0)
- m.read_pointer.null?.should == true
+ m.read_pointer.null?.should eq true
end
it "MemoryPointer#null? returns false for non-zero value" do
m = FFI::MemoryPointer.new(:long_long)
m.write_long(0x12345678)
- m.read_pointer.null?.should == false
+ m.read_pointer.null?.should eq false
end
end
diff --git a/spec/ffi/rbx/struct_spec.rb b/spec/ffi/rbx/struct_spec.rb
index 092a1a5..7c41bf3 100644
--- a/spec/ffi/rbx/struct_spec.rb
+++ b/spec/ffi/rbx/struct_spec.rb
@@ -8,6 +8,6 @@ describe FFI::Struct do
it "allows setting fields" do
t = Timeval.new
t[:tv_sec] = 12
- t[:tv_sec].should == 12
+ t[:tv_sec].should eq 12
end
-end \ No newline at end of file
+end
diff --git a/spec/ffi/string_spec.rb b/spec/ffi/string_spec.rb
index c16e082..3c66df6 100644
--- a/spec/ffi/string_spec.rb
+++ b/spec/ffi/string_spec.rb
@@ -29,7 +29,7 @@ describe "String tests" do
mp = FFI::MemoryPointer.new 1024
mp.put_string(0, "test\0")
str = mp.get_string(0)
- str.tainted?.should == true
+ str.tainted?.should eq true
end
it "String returned by a method is tainted" do
mp = FFI::MemoryPointer.new :pointer
@@ -37,8 +37,8 @@ describe "String tests" do
sp.put_string(0, "test")
mp.put_pointer(0, sp)
str = StrLibTest.ptr_ret_pointer(mp, 0)
- str.should == "test"
- str.tainted?.should == true
+ str.should eq "test"
+ str.tainted?.should eq true
end
it "Poison null byte raises error" do
s = "123\0abc"
@@ -49,7 +49,7 @@ describe "String tests" do
str = "test"
str.taint
begin
- LibTest.string_equals(str, str).should == false
+ LibTest.string_equals(str, str).should eq false
rescue SecurityError
end
end if false
@@ -57,7 +57,7 @@ describe "String tests" do
StrLibTest.string_dummy(nil)
end
it "return nil for NULL char*" do
- StrLibTest.string_null.should == nil
+ StrLibTest.string_null.should eq nil
end
it "reads an array of strings until encountering a NULL pointer" do
strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -69,7 +69,7 @@ describe "String tests" do
end
ary.insert(3, nil)
ptrary.write_array_of_pointer(ary)
- ptrary.get_array_of_string(0).should == ["foo", "bar", "baz"]
+ ptrary.get_array_of_string(0).should eq ["foo", "bar", "baz"]
end
it "reads an array of strings of the size specified, substituting nil when a pointer is NULL" do
strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -81,7 +81,7 @@ describe "String tests" do
end
ary.insert(2, nil)
ptrary.write_array_of_pointer(ary)
- ptrary.get_array_of_string(0, 4).should == ["foo", "bar", nil, "baz"]
+ ptrary.get_array_of_string(0, 4).should eq ["foo", "bar", nil, "baz"]
end
it "reads an array of strings, taking a memory offset parameter" do
strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -92,7 +92,7 @@ describe "String tests" do
a << f
end
ptrary.write_array_of_pointer(ary)
- ptrary.get_array_of_string(2 * FFI.type_size(:pointer), 3).should == ["baz", "testing", "ffi"]
+ ptrary.get_array_of_string(2 * FFI.type_size(:pointer), 3).should eq ["baz", "testing", "ffi"]
end
it "raises an IndexError when trying to read an array of strings out of bounds" do
strings = ["foo", "bar", "baz", "testing", "ffi"]
diff --git a/spec/ffi/strptr_spec.rb b/spec/ffi/strptr_spec.rb
index 839fc0f..2c82c9a 100644
--- a/spec/ffi/strptr_spec.rb
+++ b/spec/ffi/strptr_spec.rb
@@ -51,7 +51,7 @@ describe "functions returning :strptr" do
it "should return the correct value" do
result = StrPtr.strdup("test")
- result[0].should == "test"
+ result[0].should eq "test"
end
it "should return non-NULL pointer" do
diff --git a/spec/ffi/struct_callback_spec.rb b/spec/ffi/struct_callback_spec.rb
index 1e6d4be..50f1a70 100644
--- a/spec/ffi/struct_callback_spec.rb
+++ b/spec/ffi/struct_callback_spec.rb
@@ -53,7 +53,7 @@ describe FFI::Struct, ' with inline callback functions' do
ts = CallbackMember::TestStruct.new
ts[:add] = StructCallbacks.method(:add)
- CallbackMember.struct_call_add_cb(ts, 1, 2).should == 3
+ CallbackMember.struct_call_add_cb(ts, 1, 2).should eq 3
end
it 'should return callable object from []' do
@@ -74,7 +74,7 @@ describe FFI::Struct, ' with inline callback functions' do
s[:add] = add
fn = s[:add]
fn.respond_to?(:call).should be_true
- fn.call(1, 2).should == 3
+ fn.call(1, 2).should eq 3
end
end
diff --git a/spec/ffi/struct_initialize_spec.rb b/spec/ffi/struct_initialize_spec.rb
index 816718a..403535c 100644
--- a/spec/ffi/struct_initialize_spec.rb
+++ b/spec/ffi/struct_initialize_spec.rb
@@ -26,7 +26,7 @@ describe FFI::Struct, ' with an initialize function' do
self.magic = 42
end
end
- StructWithInitialize.new.magic.should == 42
+ StructWithInitialize.new.magic.should eq 42
end
end
@@ -41,6 +41,6 @@ describe FFI::ManagedStruct, ' with an initialize function' do
end
def self.release;end
end
- ManagedStructWithInitialize.new.magic.should == 42
+ ManagedStructWithInitialize.new.magic.should eq 42
end
end
diff --git a/spec/ffi/struct_packed_spec.rb b/spec/ffi/struct_packed_spec.rb
index fd4ebcd..a2f3da3 100644
--- a/spec/ffi/struct_packed_spec.rb
+++ b/spec/ffi/struct_packed_spec.rb
@@ -21,42 +21,42 @@ describe FFI::Struct do
Class.new(FFI::Struct) do
packed
layout :c, :char, :i, :int
- end.size.should == 5
+ end.size.should eq 5
end
it "packed :char followed by :int should have alignment of 1" do
Class.new(FFI::Struct) do
packed
layout :c, :char, :i, :int
- end.alignment.should == 1
+ end.alignment.should eq 1
end
it "packed(2) :char followed by :int should have size of 6" do
Class.new(FFI::Struct) do
packed 2
layout :c, :char, :i, :int
- end.size.should == 6
+ end.size.should eq 6
end
it "packed(2) :char followed by :int should have alignment of 2" do
Class.new(FFI::Struct) do
packed 2
layout :c, :char, :i, :int
- end.alignment.should == 2
+ end.alignment.should eq 2
end
it "packed :short followed by int should have size of 6" do
Class.new(FFI::Struct) do
packed
layout :s, :short, :i, :int
- end.size.should == 6
+ end.size.should eq 6
end
it "packed :short followed by int should have alignment of 1" do
Class.new(FFI::Struct) do
packed
layout :s, :short, :i, :int
- end.alignment.should == 1
+ end.alignment.should eq 1
end
end
diff --git a/spec/ffi/struct_spec.rb b/spec/ffi/struct_spec.rb
index 3b69034..3aaac99 100644
--- a/spec/ffi/struct_spec.rb
+++ b/spec/ffi/struct_spec.rb
@@ -49,7 +49,7 @@ describe "Struct tests" do
smp = FFI::MemoryPointer.new :pointer
smp.put_pointer(0, mp)
s = PointerMember.new smp
- s[:pointer].should == mp
+ s[:pointer].should eq mp
end
it "Struct#[:pointer].nil? for NULL value" do
magic = 0x12345678
@@ -58,7 +58,7 @@ describe "Struct tests" do
smp = FFI::MemoryPointer.new :pointer
smp.put_pointer(0, nil)
s = PointerMember.new smp
- s[:pointer].null?.should == true
+ s[:pointer].null?.should eq true
end
it "Struct#[:pointer]=" do
magic = 0x12345678
@@ -67,7 +67,7 @@ describe "Struct tests" do
smp = FFI::MemoryPointer.new :pointer
s = PointerMember.new smp
s[:pointer] = mp
- smp.get_pointer(0).should == mp
+ smp.get_pointer(0).should eq mp
end
it "Struct#[:pointer]=struct" do
smp = FFI::MemoryPointer.new :pointer
@@ -78,7 +78,7 @@ describe "Struct tests" do
smp = FFI::MemoryPointer.new :pointer
s = PointerMember.new smp
s[:pointer] = nil
- smp.get_pointer(0).null?.should == true
+ smp.get_pointer(0).null?.should eq true
end
it "Struct#[:string]" do
magic = "test"
@@ -87,50 +87,50 @@ describe "Struct tests" do
smp = FFI::MemoryPointer.new :pointer
smp.put_pointer(0, mp)
s = StringMember.new smp
- s[:string].should == magic
+ s[:string].should eq magic
end
it "Struct#[:string].nil? for NULL value" do
smp = FFI::MemoryPointer.new :pointer
smp.put_pointer(0, nil)
s = StringMember.new smp
- s[:string].nil?.should == true
+ s[:string].nil?.should eq true
end
it "Struct#layout works with :name, :type pairs" do
class PairLayout < FFI::Struct
layout :a, :int, :b, :long_long
end
ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8)
- PairLayout.size.should == (ll_off + 8)
+ PairLayout.size.should eq(ll_off + 8)
mp = FFI::MemoryPointer.new(PairLayout.size)
s = PairLayout.new mp
s[:a] = 0x12345678
- mp.get_int(0).should == 0x12345678
+ mp.get_int(0).should eq 0x12345678
s[:b] = 0xfee1deadbeef
- mp.get_int64(ll_off).should == 0xfee1deadbeef
+ mp.get_int64(ll_off).should eq 0xfee1deadbeef
end
it "Struct#layout works with :name, :type, offset tuples" do
class PairLayout < FFI::Struct
layout :a, :int, 0, :b, :long_long, 4
end
- PairLayout.size.should == (FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
+ PairLayout.size.should eq(FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
mp = FFI::MemoryPointer.new(PairLayout.size)
s = PairLayout.new mp
s[:a] = 0x12345678
- mp.get_int(0).should == 0x12345678
+ mp.get_int(0).should eq 0x12345678
s[:b] = 0xfee1deadbeef
- mp.get_int64(4).should == 0xfee1deadbeef
+ mp.get_int64(4).should eq 0xfee1deadbeef
end
it "Struct#layout works with mixed :name,:type and :name,:type,offset" do
class MixedLayout < FFI::Struct
layout :a, :int, :b, :long_long, 4
end
- MixedLayout.size.should == (FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
+ MixedLayout.size.should eq(FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
mp = FFI::MemoryPointer.new(MixedLayout.size)
s = MixedLayout.new mp
s[:a] = 0x12345678
- mp.get_int(0).should == 0x12345678
+ mp.get_int(0).should eq 0x12345678
s[:b] = 0xfee1deadbeef
- mp.get_int64(4).should == 0xfee1deadbeef
+ mp.get_int64(4).should eq 0xfee1deadbeef
end
rb_maj, rb_min = RUBY_VERSION.split('.')
if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/
@@ -139,13 +139,13 @@ describe "Struct tests" do
layout :a => :int, :b => :long_long
end
ll_off = (FFI::TYPE_UINT64.alignment == 4? 4 : 8)
- HashLayout.size.should == (ll_off + 8)
+ HashLayout.size.should eq(ll_off + 8)
mp = FFI::MemoryPointer.new(HashLayout.size)
s = HashLayout.new mp
s[:a] = 0x12345678
- mp.get_int(0).should == 0x12345678
+ mp.get_int(0).should eq 0x12345678
s[:b] = 0xfee1deadbeef
- mp.get_int64(ll_off).should == 0xfee1deadbeef
+ mp.get_int64(ll_off).should eq 0xfee1deadbeef
end
end
@@ -162,8 +162,8 @@ describe "Struct tests" do
end
s = InitializeWithoutSuper.new(0x1eefbeef, 0xdeadcafebabe)
- s[:a].should == 0x1eefbeef
- s[:b].should == 0xdeadcafebabe
+ s[:a].should eq 0x1eefbeef
+ s[:b].should eq 0xdeadcafebabe
end
it "Can use Struct subclass as parameter type" do
@@ -202,7 +202,7 @@ describe "Struct tests" do
end
s = TestStruct.new
s[:i] = 0x12
- LibTest.ptr_ret_int32_t(s, 0).should == 0x12
+ LibTest.ptr_ret_int32_t(s, 0).should eq 0x12
end
it ":char member aligned correctly" do
class AlignChar < FFI::Struct
@@ -210,7 +210,7 @@ describe "Struct tests" do
end
s = AlignChar.new
s[:v] = 0x12
- LibTest.struct_align_s8(s.pointer).should == 0x12
+ LibTest.struct_align_s8(s.pointer).should eq 0x12
end
it ":short member aligned correctly" do
class AlignShort < FFI::Struct
@@ -218,7 +218,7 @@ describe "Struct tests" do
end
s = AlignShort.alloc_in
s[:v] = 0x1234
- LibTest.struct_align_s16(s.pointer).should == 0x1234
+ LibTest.struct_align_s16(s.pointer).should eq 0x1234
end
it ":int member aligned correctly" do
class AlignInt < FFI::Struct
@@ -226,7 +226,7 @@ describe "Struct tests" do
end
s = AlignInt.alloc_in
s[:v] = 0x12345678
- LibTest.struct_align_s32(s.pointer).should == 0x12345678
+ LibTest.struct_align_s32(s.pointer).should eq 0x12345678
end
it ":long_long member aligned correctly" do
class AlignLongLong < FFI::Struct
@@ -234,7 +234,7 @@ describe "Struct tests" do
end
s = AlignLongLong.alloc_in
s[:v] = 0x123456789abcdef0
- LibTest.struct_align_s64(s.pointer).should == 0x123456789abcdef0
+ LibTest.struct_align_s64(s.pointer).should eq 0x123456789abcdef0
end
it ":long member aligned correctly" do
class AlignLong < FFI::Struct
@@ -242,7 +242,7 @@ describe "Struct tests" do
end
s = AlignLong.alloc_in
s[:v] = 0x12345678
- LibTest.struct_align_long(s.pointer).should == 0x12345678
+ LibTest.struct_align_long(s.pointer).should eq 0x12345678
end
it ":float member aligned correctly" do
class AlignFloat < FFI::Struct
@@ -267,7 +267,7 @@ describe "Struct tests" do
s = ULPStruct.alloc_in
s[:ul] = 0xdeadbeef
s[:p] = LibTest.ptr_from_address(0x12345678)
- s.pointer.get_ulong(0).should == 0xdeadbeef
+ s.pointer.get_ulong(0).should eq 0xdeadbeef
end
def test_num_field(type, v)
klass = Class.new(FFI::Struct)
@@ -275,9 +275,9 @@ describe "Struct tests" do
s = klass.new
s[:v] = v
- s.pointer.send("get_#{type.to_s}", 0).should == v
+ s.pointer.send("get_#{type.to_s}", 0).should eq v
s.pointer.send("put_#{type.to_s}", 0, 0)
- s[:v].should == 0
+ s[:v].should eq 0
end
def self.int_field_test(type, values)
values.each do |v|
@@ -332,8 +332,8 @@ describe "Struct tests" do
s = EnumFields::TestStruct.new
s[:c] = :c3
- s.pointer.get_uint(FFI::Type::INT32.size).should == 30
- s[:c].should == :c3
+ s.pointer.get_uint(FFI::Type::INT32.size).should eq 30
+ s[:c].should eq :c3
end
it "array of :enum field" do
@@ -343,11 +343,11 @@ describe "Struct tests" do
end
EnumFields::TestEnum.symbols.each_with_index do |val, i|
- s.pointer.get_uint(FFI::Type::INT32.size * (2 + i)).should == EnumFields::TestEnum[val]
+ s.pointer.get_uint(FFI::Type::INT32.size * (2 + i)).should eq EnumFields::TestEnum[val]
end
s[:d].each_with_index do |val, i|
- val.should == EnumFields::TestEnum.symbols[i]
+ val.should eq EnumFields::TestEnum.symbols[i]
end
end
@@ -369,8 +369,8 @@ describe "Struct tests" do
sub_proc = lambda { |a, b| a-b }
s[:add] = add_proc
s[:sub] = sub_proc
- CallbackMember.struct_call_add_cb(s, 40, 2).should == 42
- CallbackMember.struct_call_sub_cb(s, 44, 2).should == 42
+ CallbackMember.struct_call_add_cb(s, 40, 2).should eq 42
+ CallbackMember.struct_call_sub_cb(s, 44, 2).should eq 42
end
it "Can return its members as a list" do
class TestStruct < FFI::Struct
@@ -394,16 +394,16 @@ describe "Struct tests" do
layout :a, :int, :b, :int, :c, :int
end
s = TestStruct.new
- s.offsets.should == [[:a, 0], [:b, 4], [:c, 8]]
- TestStruct.offsets.should == [[:a, 0], [:b, 4], [:c, 8]]
+ s.offsets.should eq [[:a, 0], [:b, 4], [:c, 8]]
+ TestStruct.offsets.should eq [[:a, 0], [:b, 4], [:c, 8]]
end
it "Struct#offset_of returns offset of field within struct" do
class TestStruct < FFI::Struct
layout :a, :int, :b, :int, :c, :int
end
- TestStruct.offset_of(:a).should == 0
- TestStruct.offset_of(:b).should == 4
- TestStruct.offset_of(:c).should == 8
+ TestStruct.offset_of(:a).should eq 0
+ TestStruct.offset_of(:b).should eq 4
+ TestStruct.offset_of(:c).should eq 8
end
end
@@ -425,22 +425,22 @@ describe FFI::Struct, ' with a nested struct field' do
end
it 'should align correctly nested struct field' do
@cs[:ns][:i] = 123
- LibTest.struct_align_nested_struct(@cs.to_ptr).should == 123
+ LibTest.struct_align_nested_struct(@cs.to_ptr).should eq 123
end
it 'should correctly calculate Container size (in bytes)' do
- LibTest::ContainerStruct.size.should == 8
+ LibTest::ContainerStruct.size.should eq 8
end
it 'should return a Struct object when the field is accessed' do
@cs[:ns].is_a?(FFI::Struct).should be_true
end
it 'should read a value from memory' do
@cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
- @cs[:ns][:i].should == 123
+ @cs[:ns][:i].should eq 123
end
it 'should write a value to memory' do
@cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
@cs[:ns][:i] = 456
- LibTest.struct_align_nested_struct(@cs.to_ptr).should == 456
+ LibTest.struct_align_nested_struct(@cs.to_ptr).should eq 456
end
end
@@ -464,11 +464,11 @@ describe FFI::Struct, ' with a nested array of structs' do
it 'should align correctly nested struct field' do
@cs[:ns][0][:i] = 123
- InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should == 123
+ InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should eq 123
end
it 'should correctly calculate Container size (in bytes)' do
- InlineArrayOfStructs::ContainerStruct.size.should == 8
+ InlineArrayOfStructs::ContainerStruct.size.should eq 8
end
it 'should return a Struct object when the field is accessed' do
@@ -477,20 +477,20 @@ describe FFI::Struct, ' with a nested array of structs' do
it 'should read a value from memory' do
@cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
- @cs[:ns][0][:i].should == 123
+ @cs[:ns][0][:i].should eq 123
end
it 'should write a value to memory' do
@cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
@cs[:ns][0][:i] = 456
- InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should == 456
+ InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should eq 456
end
it 'should support Enumerable#each' do
@cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
ints = []
@cs[:ns].each { |s| ints << s[:i] }
- ints[0].should == 123
+ ints[0].should eq 123
end
end
@@ -518,22 +518,22 @@ describe FFI::Struct, ' by value' do
it 'return using pre-set values' do
s = LibTest.struct_return_s8s32
- s[:s8].should == 0x7f
- s[:s32].should == 0x12345678
+ s[:s8].should eq 0x7f
+ s[:s32].should eq 0x12345678
end
it 'return using passed in values' do
s = LibTest.struct_s8s32_set(123, 456789)
- s[:s8].should == 123
- s[:s32].should == 456789
+ s[:s8].should eq 123
+ s[:s32].should eq 456789
end
it 'parameter' do
s = LibTest::S8S32.new
s[:s8] = 0x12
s[:s32] = 0x34567890
- LibTest.struct_s8s32_get_s8(s).should == 0x12
- LibTest.struct_s8s32_get_s32(s).should == 0x34567890
+ LibTest.struct_s8s32_get_s8(s).should eq 0x12
+ LibTest.struct_s8s32_get_s32(s).should eq 0x34567890
end
it 'parameter with following s32' do
@@ -541,7 +541,7 @@ describe FFI::Struct, ' by value' do
s[:s8] = 0x12
s[:s32] = 0x34567890
- LibTest.struct_s8s32_s32_ret_s32(s, 0x1eefdead).should == 0x1eefdead
+ LibTest.struct_s8s32_s32_ret_s32(s, 0x1eefdead).should eq 0x1eefdead
end
it 'parameter with following s64' do
@@ -549,14 +549,14 @@ describe FFI::Struct, ' by value' do
s[:s8] = 0x12
s[:s32] = 0x34567890
- LibTest.struct_s8s32_s64_ret_s64(s, 0xdeadcafebabe).should == 0xdeadcafebabe
+ LibTest.struct_s8s32_s64_ret_s64(s, 0xdeadcafebabe).should eq 0xdeadcafebabe
end
it 'varargs returning a struct' do
string = "test"
s = LibTest.struct_varargs_ret_struct_string(4, :string, string)
- s[:len].should == string.length
- s[:bytes].should == string
+ s[:len].should eq string.length
+ s[:bytes].should eq string
end
end
@@ -574,26 +574,26 @@ describe FFI::Struct, ' with an array field' do
@s = LibTest::StructWithArray.new
end
it 'should correctly calculate StructWithArray size (in bytes)' do
- LibTest::StructWithArray.size.should == 24
+ LibTest::StructWithArray.size.should eq 24
end
it 'should read values from memory' do
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
- @s[:a].to_a.should == [0, 1, 2, 3, 4]
+ @s[:a].to_a.should eq [0, 1, 2, 3, 4]
end
# it 'should cache array object for successive calls' do
-# @s[:a].object_id.should == @s[:a].object_id
+# @s[:a].object_id.should eq @s[:a].object_id
# end
it 'should return the number of elements in the array field' do
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
- @s[:a].size.should == 5
+ @s[:a].size.should eq 5
end
it 'should allow iteration through the array elements' do
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
- @s[:a].each_with_index { |elem, i| elem.should == i }
+ @s[:a].each_with_index { |elem, i| elem.should eq i }
end
it 'should return the pointer to the array' do
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
- @s[:a].to_ptr.should == LibTest::struct_field_array(@s.to_ptr)
+ @s[:a].to_ptr.should eq LibTest::struct_field_array(@s.to_ptr)
end
end
@@ -613,21 +613,21 @@ describe 'BuggedStruct' do
attach_function :bugged_struct_size, [], :uint
end
it 'should return its correct size' do
- LibTest::BuggedStruct.size.should == LibTest.bugged_struct_size
+ LibTest::BuggedStruct.size.should eq LibTest.bugged_struct_size
end
it "offsets within struct should be correct" do
- LibTest::BuggedStruct.offset_of(:visible).should == 0
- LibTest::BuggedStruct.offset_of(:x).should == 4
- LibTest::BuggedStruct.offset_of(:y).should == 8
- LibTest::BuggedStruct.offset_of(:rx).should == 12
- LibTest::BuggedStruct.offset_of(:ry).should == 14
- LibTest::BuggedStruct.offset_of(:order).should == 16
- LibTest::BuggedStruct.offset_of(:size).should == 17
+ LibTest::BuggedStruct.offset_of(:visible).should eq 0
+ LibTest::BuggedStruct.offset_of(:x).should eq 4
+ LibTest::BuggedStruct.offset_of(:y).should eq 8
+ LibTest::BuggedStruct.offset_of(:rx).should eq 12
+ LibTest::BuggedStruct.offset_of(:ry).should eq 14
+ LibTest::BuggedStruct.offset_of(:order).should eq 16
+ LibTest::BuggedStruct.offset_of(:size).should eq 17
end
it 'should return correct field/offset pairs' do
LibTest::BuggedStruct.offsets.sort do |a, b|
a[1] <=> b[1]
- end.should == [[:visible, 0], [:x, 4], [:y, 8], [:rx, 12], [:ry, 14], [:order, 16], [:size, 17]]
+ end.should eq [[:visible, 0], [:x, 4], [:y, 8], [:rx, 12], [:ry, 14], [:order, 16], [:size, 17]]
end
end
@@ -637,11 +637,11 @@ describe "Struct allocation" do
layout :i, :uint
end
p = FFI::MemoryPointer.new(S, 2)
- p.total.should == 8
- p.type_size.should == 4
+ p.total.should eq 8
+ p.type_size.should eq 4
p.put_uint(4, 0xdeadbeef)
- S.new(p[1])[:i].should == 0xdeadbeef
- p[1].address.should == (p[0].address + 4)
+ S.new(p[1])[:i].should eq 0xdeadbeef
+ p[1].address.should eq(p[0].address + 4)
end
it "Buffer.new(Struct, 2)" do
@@ -649,10 +649,10 @@ describe "Struct allocation" do
layout :i, :uint
end
p = FFI::Buffer.new(S, 2)
- p.total.should == 8
- p.type_size.should == 4
+ p.total.should eq 8
+ p.type_size.should eq 4
p.put_uint(4, 0xdeadbeef)
- S.new(p[1])[:i].should == 0xdeadbeef
+ S.new(p[1])[:i].should eq 0xdeadbeef
end
it "null? should be true when initialized with NULL pointer" do
diff --git a/spec/ffi/typedef_spec.rb b/spec/ffi/typedef_spec.rb
index bf3718f..32659ce 100644
--- a/spec/ffi/typedef_spec.rb
+++ b/spec/ffi/typedef_spec.rb
@@ -23,7 +23,7 @@ describe "Custom type definitions" do
typedef :uint, :fubar_t
attach_function :ret_u32, [ :fubar_t ], :fubar_t
end
- CustomTypedef.ret_u32(0x12345678).should == 0x12345678
+ CustomTypedef.ret_u32(0x12345678).should eq 0x12345678
end
it "variadic invoker with custom typedef" do
module VariadicCustomTypedef
@@ -34,7 +34,7 @@ describe "Custom type definitions" do
end
buf = FFI::Buffer.new :uint, 10
VariadicCustomTypedef.pack_varargs(buf, "i", :fubar_t, 0x12345678)
- buf.get_int64(0).should == 0x12345678
+ buf.get_int64(0).should eq 0x12345678
end
it "Callback with custom typedef parameter" do
module CallbackCustomTypedef
@@ -46,7 +46,7 @@ describe "Custom type definitions" do
end
i = 0
CallbackCustomTypedef.testCallbackU32rV(0xdeadbeef) { |v| i = v }
- i.should == 0xdeadbeef
+ i.should eq 0xdeadbeef
end
module StructCustomTypedef
extend FFI::Library
@@ -59,7 +59,7 @@ describe "Custom type definitions" do
it "Struct with custom typedef field" do
s = StructCustomTypedef::S.new
s[:a] = 0x12345678
- s.pointer.get_uint(0).should == 0x12345678
+ s.pointer.get_uint(0).should eq 0x12345678
end
it "attach_function after a typedef should not reject normal types" do
diff --git a/spec/ffi/union_spec.rb b/spec/ffi/union_spec.rb
index 9b78ea6..6c0eb66 100644
--- a/spec/ffi/union_spec.rb
+++ b/spec/ffi/union_spec.rb
@@ -56,7 +56,7 @@ describe 'Union' do
if k == 'f32' or k == 'f64'
(@u[type[1]] - LibTest.send("union_align_#{k}", @u.to_ptr)).abs.should < 0.00001
else
- @u[type[1]].should == LibTest.send("union_align_#{k}", @u.to_ptr)
+ @u[type[1]].should eq LibTest.send("union_align_#{k}", @u.to_ptr)
end
end
end
@@ -66,11 +66,11 @@ describe 'Union' do
if k == 'f32' or k == 'f64'
(@u[type[1]] - type[2]).abs.should < 0.00001
else
- @u[type[1]].should == type[2]
+ @u[type[1]].should eq type[2]
end
end
end
it 'should return a size equals to the size of the biggest field' do
- LibTest::TestUnion.size.should == LibTest.union_size
+ LibTest::TestUnion.size.should eq LibTest.union_size
end
end
diff --git a/spec/ffi/variadic_spec.rb b/spec/ffi/variadic_spec.rb
index cb2d073..aef05dc 100644
--- a/spec/ffi/variadic_spec.rb
+++ b/spec/ffi/variadic_spec.rb
@@ -25,30 +25,31 @@ describe "Function with variadic arguments" do
it "call variadic with (:char (#{i})) argument" do
buf = FFI::Buffer.new :long_long
LibTest.pack_varargs(buf, "c", :char, i)
- buf.get_int64(0).should == i
+ buf.get_int64(0).should eq i
end
end
[ 0, 0x7f, 0x80, 0xff ].each do |i|
it "call variadic with (:uchar (#{i})) argument" do
buf = FFI::Buffer.new :long_long
LibTest.pack_varargs(buf, "C", :uchar, i)
- buf.get_int64(0).should == i
+ buf.get_int64(0).should eq i
end
end
[ 0, 1.234567, 9.87654321 ].each do |v|
it "call variadic with (:float (#{v})) argument" do
buf = FFI::Buffer.new :long_long
LibTest.pack_varargs(buf, "f", :float, v.to_f)
- buf.get_float64(0).should == v
+ buf.get_float64(0).should eq v
end
end
[ 0, 1.234567, 9.87654321 ].each do |v|
it "call variadic with (:double (#{v})) argument" do
buf = FFI::Buffer.new :long_long
LibTest.pack_varargs(buf, "f", :double, v.to_f)
- buf.get_float64(0).should == v
+ buf.get_float64(0).should eq v
end
end
+
module Varargs
PACK_VALUES = {
'c' => [ 0x12 ],
@@ -68,14 +69,16 @@ describe "Function with variadic arguments" do
'i' => :int, 'I' => :uint, 'j' => :long_long, 'J' => :ulong_long,
'l' => :long, 'L' => :ulong, 'f' => :float, 'd' => :double
}
- def self.verify(p, off, v)
- if v.kind_of?(Float)
- p.get_float64(off).should == v
- else
- p.get_int64(off).should == v
- end
+ end
+
+ def verify(p, off, v)
+ if v.kind_of?(Float)
+ p.get_float64(off).should eq v
+ else
+ p.get_int64(off).should eq v
end
end
+
Varargs::PACK_VALUES.keys.each do |t1|
Varargs::PACK_VALUES.keys.each do |t2|
Varargs::PACK_VALUES.keys.each do |t3|
@@ -87,9 +90,9 @@ describe "Function with variadic arguments" do
it "call(#{fmt}, #{params.join(',')})" do
buf = FFI::Buffer.new :long_long, 3
LibTest.pack_varargs(buf, fmt, *params)
- Varargs.verify(buf, 0, v1)
- Varargs.verify(buf, 8, v2)
- Varargs.verify(buf, 16, v3)
+ verify(buf, 0, v1)
+ verify(buf, 8, v2)
+ verify(buf, 16, v3)
end
end
end
@@ -97,4 +100,4 @@ describe "Function with variadic arguments" do
end
end
end
-end \ No newline at end of file
+end