ffi 1.9.5-x86-mingw32 → 1.9.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +15 -7
  2. data/Rakefile +13 -6
  3. data/ext/ffi_c/extconf.rb +2 -2
  4. data/lib/1.8/ffi_c.so +0 -0
  5. data/lib/1.9/ffi_c.so +0 -0
  6. data/lib/2.0/ffi_c.so +0 -0
  7. data/lib/2.1/ffi_c.so +0 -0
  8. data/lib/ffi.rb +2 -0
  9. data/lib/ffi/version.rb +1 -1
  10. data/spec/ffi/async_callback_spec.rb +4 -5
  11. data/spec/ffi/bool_spec.rb +9 -8
  12. data/spec/ffi/buffer_spec.rb +64 -37
  13. data/spec/ffi/callback_spec.rb +195 -116
  14. data/spec/ffi/custom_param_type.rb +1 -1
  15. data/spec/ffi/custom_type_spec.rb +5 -6
  16. data/spec/ffi/dup_spec.rb +6 -8
  17. data/spec/ffi/enum_spec.rb +135 -129
  18. data/spec/ffi/errno_spec.rb +2 -2
  19. data/spec/ffi/ffi.log +5833 -0
  20. data/spec/ffi/ffi_spec.rb +4 -6
  21. data/spec/ffi/function_spec.rb +22 -11
  22. data/spec/ffi/io_spec.rb +0 -1
  23. data/spec/ffi/library_spec.rb +71 -36
  24. data/spec/ffi/long_double.rb +3 -4
  25. data/spec/ffi/managed_struct_spec.rb +14 -4
  26. data/spec/ffi/memorypointer_spec.rb +7 -1
  27. data/spec/ffi/number_spec.rb +43 -34
  28. data/spec/ffi/platform_spec.rb +76 -59
  29. data/spec/ffi/pointer_spec.rb +35 -31
  30. data/spec/ffi/rbx/attach_function_spec.rb +3 -4
  31. data/spec/ffi/rbx/memory_pointer_spec.rb +24 -22
  32. data/spec/ffi/rbx/spec_helper.rb +0 -1
  33. data/spec/ffi/rbx/struct_spec.rb +1 -2
  34. data/spec/ffi/spec_helper.rb +5 -2
  35. data/spec/ffi/string_spec.rb +22 -14
  36. data/spec/ffi/strptr_spec.rb +6 -7
  37. data/spec/ffi/struct_by_ref_spec.rb +4 -5
  38. data/spec/ffi/struct_by_ref_spec.rb.orig +43 -0
  39. data/spec/ffi/struct_callback_spec.rb +6 -7
  40. data/spec/ffi/struct_initialize_spec.rb +2 -3
  41. data/spec/ffi/struct_packed_spec.rb +12 -14
  42. data/spec/ffi/struct_spec.rb +203 -129
  43. data/spec/ffi/typedef_spec.rb +11 -10
  44. data/spec/ffi/union_spec.rb +8 -7
  45. data/spec/ffi/variadic_spec.rb +13 -10
  46. metadata +150 -139
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 8388c8504e5777a39e69727d10ecf13670674e85
4
- data.tar.gz: a3fbbcb12431244e647cb40f93b9366da87212ed
5
- SHA512:
6
- metadata.gz: 9b3ed3e25e37a153054936c60fcb63e700555477842c8be209c3ad6390151e1adb3ba97e6fb4c27b4644ba319160cccb332b1ea92957f103dbe3a394252420f2
7
- data.tar.gz: 2415657adfd8815c3f478f40e8a531a6345a53b8b12487def0c8736f64bfe200aa20affd0a13500b767b37c517d177cbd12dce95c0cd5ef7cf54db8b4c6e8c06
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWU3ZWQwZWZhZTgxODViMjdiNTY0ZGI5MjI1NGMxNTg2NjQ1YWZhNg==
5
+ data.tar.gz: !binary |-
6
+ OThkY2E3MmM3YjY3NDgwYzdhNjRkODUyMmU0YjE1ZTNhMGVhOGRiOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZWVjMDdiMDRiOGY3MzQzMDM1ZGMwMjYyOTQ5MTM1Zjk5ZGNmZjg4ZGE5NTU5
10
+ ZTVlY2E0NDFiZjFhMjI5NDQwYjg4NGVhZjMzMjM0YWM5ZTIxNWVkOTBiMDRk
11
+ YmY1NDVlZjRlZTNkMTJlNTk1N2MzNjZiNDk2ZjUyMmNmMjdiOTQ=
12
+ data.tar.gz: !binary |-
13
+ OTY5ODkxMDNlNDdjYmI4Yjc4NDg5NTAxY2EzZWMxMTViZTE4Yjc5MjlkYjdh
14
+ ZjUxOTZhZWM2YmNkMDkwZDU0YzBhMDZjNTczMTM5ZGQzNzFjNDExOThiNTg0
15
+ MjY3NmMxYmU5ODM2ZTFhOGNmMTg0MDAwMzE3YjM0NTg0NTQ2OTg=
data/Rakefile CHANGED
@@ -150,11 +150,6 @@ task 'spec:specdoc' => TEST_DEPS
150
150
 
151
151
  task :default => :specs
152
152
 
153
- task 'gem:win32' do
154
- sh("rake cross native gem RUBY_CC_VERSION='1.8.7:1.9.3:2.0.0:2.1.3'") || raise("win32 build failed!")
155
- end
156
-
157
-
158
153
  namespace 'java' do
159
154
 
160
155
  java_gem_spec = Gem::Specification.new do |s|
@@ -190,11 +185,23 @@ if USE_RAKE_COMPILER
190
185
  ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
191
186
  end
192
187
 
193
- ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
188
+ task 'gem:win32' => ['gem:win32-x64', 'gem:win32-i386']
189
+
190
+ task 'gem:win32-x86' do
191
+ sh("rake cross native:i386-mingw32 gem RUBY_CC_VERSION='1.8.7:1.9.3:2.0.0:2.1.3'") || raise("win32-i386 build failed!")
192
+ end
193
+
194
+ task 'gem:win32-x64' do
195
+ sh("rake cross native:x64-mingw32 gem RUBY_CC_VERSION='2.0.0:2.1.3'") || raise("win32-x64 build failed!")
196
+ end
197
+
198
+ (ENV['RUBY_CC_VERSION'] || '1.8.7:1.9.3:2.0.0:2.1.3' ).to_s.split(':').each do |ruby_version|
194
199
  task "copy:ffi_c:i386-mingw32:#{ruby_version}" do |t|
195
200
  sh "i686-w64-mingw32-strip -S #{BUILD_DIR}/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
196
201
  end
202
+ end
197
203
 
204
+ (ENV['RUBY_CC_VERSION'] || '2.0.0:2.1.3' ).to_s.split(':').each do |ruby_version|
198
205
  task "copy:ffi_c:x64-mingw32:#{ruby_version}" do |t|
199
206
  sh "x86_64-w64-mingw32-strip -S #{BUILD_DIR}/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
200
207
  end
@@ -9,8 +9,8 @@ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
9
9
  $warnflags = ''
10
10
  $CFLAGS.gsub!(/[\s+]-ansi/, '')
11
11
  $CFLAGS.gsub!(/[\s+]-std=[^\s]+/, '')
12
- # solaris needs -c99 for <stdbool.h>
13
- $CFLAGS << " -std=c99" if RbConfig::CONFIG['host_os'] =~ /solaris/
12
+ # solaris 10 needs -c99 for <stdbool.h>
13
+ $CFLAGS << " -std=c99" if RbConfig::CONFIG['host_os'] =~ /solaris(!?2\.11)/
14
14
 
15
15
  if ENV['RUBY_CC_VERSION'].nil? && (pkg_config("libffi") ||
16
16
  have_header("ffi.h") ||
Binary file
Binary file
Binary file
Binary file
data/lib/ffi.rb CHANGED
@@ -7,6 +7,8 @@ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
7
7
  require '1.9/ffi_c'
8
8
  elsif RUBY_VERSION =~ /2.0/
9
9
  require '2.0/ffi_c'
10
+ elsif RUBY_VERSION =~ /2.1/
11
+ require '2.1/ffi_c'
10
12
  else
11
13
  require 'ffi_c'
12
14
  end
@@ -1,4 +1,4 @@
1
1
  module FFI
2
- VERSION = '1.9.5'
2
+ VERSION = '1.9.6'
3
3
  end
4
4
 
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "async callback" do
10
9
  module LibTest
@@ -21,8 +20,8 @@ describe "async callback" do
21
20
  called = false
22
21
  cb = Proc.new {|i| v = i; called = true }
23
22
  LibTest.testAsyncCallback(cb, 0x7fffffff)
24
- called.should be_true
25
- v.should == 0x7fffffff
23
+ expect(called).to be true
24
+ expect(v).to eq(0x7fffffff)
26
25
  end
27
26
 
28
27
  it "called a second time" do
@@ -30,7 +29,7 @@ describe "async callback" do
30
29
  called = false
31
30
  cb = Proc.new {|i| v = i; called = true }
32
31
  LibTest.testAsyncCallback(cb, 0x7fffffff)
33
- called.should be_true
34
- v.should == 0x7fffffff
32
+ expect(called).to be true
33
+ expect(v).to eq(0x7fffffff)
35
34
  end
36
35
  end
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "Function with primitive boolean arguments and return values" do
10
9
  module LibTest
@@ -15,17 +14,19 @@ describe "Function with primitive boolean arguments and return values" do
15
14
  attach_function :bool_return_val, [ :bool ], :bool
16
15
  attach_function :bool_reverse_val, [ :bool ], :bool
17
16
  end
17
+
18
18
  it "bools" do
19
- LibTest.bool_return_true.should == true
20
- LibTest.bool_return_false.should == false
19
+ expect(LibTest.bool_return_true).to be true
20
+ expect(LibTest.bool_return_false).to be false
21
21
 
22
- LibTest.bool_return_val(true).should == true
23
- LibTest.bool_return_val(false).should == false
22
+ expect(LibTest.bool_return_val(true)).to be true
23
+ expect(LibTest.bool_return_val(false)).to be false
24
24
 
25
- LibTest.bool_reverse_val(true).should == false
26
- LibTest.bool_reverse_val(false).should == true
25
+ expect(LibTest.bool_reverse_val(true)).to be false
26
+ expect(LibTest.bool_reverse_val(false)).to be true
27
27
  end
28
+
28
29
  it "raise error on invalid types" do
29
- lambda { LibTest.bool_return_val(nil) }.should raise_error(::TypeError)
30
+ expect { LibTest.bool_return_val(nil) }.to raise_error(::TypeError)
30
31
  end
31
32
  end
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "Buffer#total" do
10
9
  [1,2,3].each do |i|
@@ -12,14 +11,17 @@ describe "Buffer#total" do
12
11
  :uint => 4, :long => FFI::Type::LONG.size, :ulong => FFI::Type::ULONG.size,
13
12
  :long_long => 8, :ulong_long => 8, :float => 4, :double => 8
14
13
  }.each_pair do |t, s|
14
+
15
15
  it "Buffer.alloc_in(#{t}, #{i}).total == #{i * s}" do
16
- FFI::Buffer.alloc_in(t, i).total.should == i * s
16
+ expect(FFI::Buffer.alloc_in(t, i).total).to eq(i * s)
17
17
  end
18
+
18
19
  it "Buffer.alloc_out(#{t}, #{i}).total == #{i * s}" do
19
- FFI::Buffer.alloc_out(t, i).total.should == i * s
20
+ expect(FFI::Buffer.alloc_out(t, i).total).to eq(i * s)
20
21
  end
22
+
21
23
  it "Buffer.alloc_inout(#{t}, #{i}).total == #{i * s}" do
22
- FFI::Buffer.alloc_inout(t, i).total.should == i * s
24
+ expect(FFI::Buffer.alloc_inout(t, i).total).to eq(i * s)
23
25
  end
24
26
  end
25
27
  end
@@ -30,214 +32,239 @@ describe "Buffer#put_char" do
30
32
  (0..127).each do |i|
31
33
  (0..bufsize-1).each do |offset|
32
34
  it "put_char(#{offset}, #{i}).get_char(#{offset}) == #{i}" do
33
- FFI::Buffer.alloc_in(bufsize).put_char(offset, i).get_char(offset).should == i
35
+ expect(FFI::Buffer.alloc_in(bufsize).put_char(offset, i).get_char(offset)).to eq(i)
34
36
  end
35
37
  end
36
38
  end
37
39
  end
40
+
38
41
  describe "Buffer#put_uchar" do
39
42
  bufsize = 4
40
43
  (0..255).each do |i|
41
44
  (0..bufsize-1).each do |offset|
42
45
  it "Buffer.put_uchar(#{offset}, #{i}).get_uchar(#{offset}) == #{i}" do
43
- FFI::Buffer.alloc_in(bufsize).put_uchar(offset, i).get_uchar(offset).should == i
46
+ expect(FFI::Buffer.alloc_in(bufsize).put_uchar(offset, i).get_uchar(offset)).to eq(i)
44
47
  end
45
48
  end
46
49
  end
47
50
  end
51
+
48
52
  describe "Buffer#put_short" do
49
53
  bufsize = 4
50
54
  [0, 1, 128, 32767].each do |i|
51
55
  (0..bufsize-2).each do |offset|
52
56
  it "put_short(#{offset}, #{i}).get_short(#{offset}) == #{i}" do
53
- FFI::Buffer.alloc_in(bufsize).put_short(offset, i).get_short(offset).should == i
57
+ expect(FFI::Buffer.alloc_in(bufsize).put_short(offset, i).get_short(offset)).to eq(i)
54
58
  end
55
59
  end
56
60
  end
57
61
  end
62
+
58
63
  describe "Buffer#put_ushort" do
59
64
  bufsize = 4
60
65
  [ 0, 1, 128, 32767, 65535, 0xfee1, 0xdead, 0xbeef, 0xcafe ].each do |i|
61
66
  (0..bufsize-2).each do |offset|
62
67
  it "put_ushort(#{offset}, #{i}).get_ushort(#{offset}) == #{i}" do
63
- FFI::Buffer.alloc_in(bufsize).put_ushort(offset, i).get_ushort(offset).should == i
68
+ expect(FFI::Buffer.alloc_in(bufsize).put_ushort(offset, i).get_ushort(offset)).to eq(i)
64
69
  end
65
70
  end
66
71
  end
67
72
  end
73
+
68
74
  describe "Buffer#put_int" do
69
75
  bufsize = 8
70
76
  [0, 1, 128, 32767, 0x7ffffff ].each do |i|
71
77
  (0..bufsize-4).each do |offset|
72
78
  it "put_int(#{offset}, #{i}).get_int(#{offset}) == #{i}" do
73
- FFI::Buffer.alloc_in(bufsize).put_int(offset, i).get_int(offset).should == i
79
+ expect(FFI::Buffer.alloc_in(bufsize).put_int(offset, i).get_int(offset)).to eq(i)
74
80
  end
75
81
  end
76
82
  end
77
83
  end
84
+
78
85
  describe "Buffer#put_uint" do
79
86
  bufsize = 8
80
87
  [ 0, 1, 128, 32767, 65535, 0xfee1dead, 0xcafebabe, 0xffffffff ].each do |i|
81
88
  (0..bufsize-4).each do |offset|
82
89
  it "put_uint(#{offset}, #{i}).get_uint(#{offset}) == #{i}" do
83
- FFI::Buffer.alloc_in(bufsize).put_uint(offset, i).get_uint(offset).should == i
90
+ expect(FFI::Buffer.alloc_in(bufsize).put_uint(offset, i).get_uint(offset)).to eq(i)
84
91
  end
85
92
  end
86
93
  end
87
94
  end
95
+
88
96
  describe "Buffer#put_long" do
89
97
  bufsize = 16
90
98
  [0, 1, 128, 32767, 0x7ffffff ].each do |i|
91
99
  (0..bufsize-FFI::Type::LONG.size).each do |offset|
92
100
  it "put_long(#{offset}, #{i}).get_long(#{offset}) == #{i}" do
93
- FFI::Buffer.alloc_in(bufsize).put_long(offset, i).get_long(offset).should == i
101
+ expect(FFI::Buffer.alloc_in(bufsize).put_long(offset, i).get_long(offset)).to eq(i)
94
102
  end
95
103
  end
96
104
  end
97
105
  end
106
+
98
107
  describe "Buffer#put_ulong" do
99
108
  bufsize = 16
100
109
  [ 0, 1, 128, 32767, 65535, 0xfee1dead, 0xcafebabe, 0xffffffff ].each do |i|
101
110
  (0..bufsize-FFI::Type::LONG.size).each do |offset|
102
111
  it "put_ulong(#{offset}, #{i}).get_ulong(#{offset}) == #{i}" do
103
- FFI::Buffer.alloc_in(bufsize).put_ulong(offset, i).get_ulong(offset).should == i
112
+ expect(FFI::Buffer.alloc_in(bufsize).put_ulong(offset, i).get_ulong(offset)).to eq(i)
104
113
  end
105
114
  end
106
115
  end
107
116
  end
117
+
108
118
  describe "Buffer#put_long_long" do
109
119
  bufsize = 16
110
120
  [0, 1, 128, 32767, 0x7ffffffffffffff ].each do |i|
111
121
  (0..bufsize-8).each do |offset|
112
122
  it "put_long_long(#{offset}, #{i}).get_long_long(#{offset}) == #{i}" do
113
- FFI::Buffer.alloc_in(bufsize).put_long_long(offset, i).get_long_long(offset).should == i
123
+ expect(FFI::Buffer.alloc_in(bufsize).put_long_long(offset, i).get_long_long(offset)).to eq(i)
114
124
  end
115
125
  end
116
126
  end
117
127
  end
128
+
118
129
  describe "Buffer#put_ulong_long" do
119
130
  bufsize = 16
120
131
  [ 0, 1, 128, 32767, 65535, 0xdeadcafebabe, 0x7fffffffffffffff ].each do |i|
121
132
  (0..bufsize-8).each do |offset|
122
133
  it "put_ulong_long(#{offset}, #{i}).get_ulong_long(#{offset}) == #{i}" do
123
- FFI::Buffer.alloc_in(bufsize).put_ulong_long(offset, i).get_ulong_long(offset).should == i
134
+ expect(FFI::Buffer.alloc_in(bufsize).put_ulong_long(offset, i).get_ulong_long(offset)).to eq(i)
124
135
  end
125
136
  end
126
137
  end
127
138
  end
139
+
128
140
  describe "Reading/Writing binary strings" do
129
141
  it "Buffer#put_bytes" do
130
142
  str = "hello\0world"
131
143
  buf = FFI::Buffer.new 1024
132
144
  buf.put_bytes(0, str);
133
145
  s2 = buf.get_bytes(0, 11);
134
- s2.should == str
146
+ expect(s2).to eq(str)
135
147
  end
148
+
136
149
  it "Buffer#put_bytes with index and length" do
137
150
  str = "hello\0world"
138
151
  buf = FFI::Buffer.new 1024
139
152
  buf.put_bytes(0, str, 5, 6);
140
153
  s2 = buf.get_bytes(0, 6);
141
- s2.should == str[5..-1]
154
+ expect(s2).to eq(str[5..-1])
142
155
  end
156
+
143
157
  it "Buffer#put_bytes with only index" do
144
158
  str = "hello\0world"
145
159
  buf = FFI::Buffer.new 1024
146
160
  buf.put_bytes(0, str, 5);
147
161
  s2 = buf.get_bytes(0, 6);
148
- s2.should == str[5..-1]
162
+ expect(s2).to eq(str[5..-1])
149
163
  end
164
+
150
165
  it "Buffer#put_bytes with index > str.length" do
151
166
  str = "hello\0world"
152
167
  buf = FFI::Buffer.new 1024
153
- lambda { buf.put_bytes(0, str, 12); }.should raise_error
168
+ expect { buf.put_bytes(0, str, 12); }.to raise_error
154
169
  end
170
+
155
171
  it "Buffer#put_bytes with length > str.length" do
156
172
  str = "hello\0world"
157
173
  buf = FFI::Buffer.new 1024
158
- lambda { buf.put_bytes(0, str, 0, 12); }.should raise_error
174
+ expect { buf.put_bytes(0, str, 0, 12); }.to raise_error
159
175
  end
160
- it "Buffer#put_bytes with negative index" do
176
+
177
+ it "Buffer#put_bytes with negative index" do
161
178
  str = "hello\0world"
162
179
  buf = FFI::Buffer.new 1024
163
- lambda { buf.put_bytes(0, str, -1, 12); }.should raise_error
164
- end
180
+ expect { buf.put_bytes(0, str, -1, 12); }.to raise_error
181
+ end
165
182
 
166
183
  it "Buffer#write_bytes" do
167
184
  str = "hello\0world"
168
185
  buf = FFI::Buffer.new 1024
169
186
  buf.write_bytes(str)
170
187
  s2 = buf.get_bytes(0, 11)
171
- s2.should == str
188
+ expect(s2).to eq(str)
172
189
  end
190
+
173
191
  it "Buffer#write_bytes with index and length" do
174
192
  str = "hello\0world"
175
193
  buf = FFI::Buffer.new 1024
176
194
  buf.write_bytes(str, 5, 6)
177
195
  s2 = buf.get_bytes(0, 6)
178
- s2.should == str[5..-1]
196
+ expect(s2).to eq(str[5..-1])
179
197
  end
198
+
180
199
  it "Buffer#write_bytes with only index" do
181
200
  str = "hello\0world"
182
201
  buf = FFI::Buffer.new 1024
183
202
  buf.write_bytes(str, 5)
184
203
  s2 = buf.get_bytes(0, 6)
185
- s2.should == str[5..-1]
204
+ expect(s2).to eq(str[5..-1])
186
205
  end
206
+
187
207
  it "Buffer#write_bytes with index > str.length" do
188
208
  str = "hello\0world"
189
209
  buf = FFI::Buffer.new 1024
190
- lambda { buf.write_bytes(str, 12) }.should raise_error
210
+ expect { buf.write_bytes(str, 12) }.to raise_error
191
211
  end
212
+
192
213
  it "Buffer#put_bytes with length > str.length" do
193
214
  str = "hello\0world"
194
215
  buf = FFI::Buffer.new 1024
195
- lambda { buf.put_bytes(0, str, 0, 12) }.should raise_error
216
+ expect { buf.put_bytes(0, str, 0, 12) }.to raise_error
196
217
  end
197
- it "Buffer#write_bytes with negative index" do
218
+
219
+ it "Buffer#write_bytes with negative index" do
198
220
  str = "hello\0world"
199
221
  buf = FFI::Buffer.new 1024
200
- lambda { buf.write_bytes(str, -1, 12) }.should raise_error
222
+ expect { buf.write_bytes(str, -1, 12) }.to raise_error
201
223
  end
202
224
  end
225
+
203
226
  describe "Reading/Writing ascii strings" do
204
227
  it "Buffer#put_string with string containing zero byte" do
205
228
  str = "hello\0world"
206
229
  buf = FFI::Buffer.new 1024
207
230
  buf.put_string(0, str);
208
231
  s2 = buf.get_bytes(0, 11);
209
- s2.should == str
232
+ expect(s2).to eq(str)
210
233
  end
234
+
211
235
  it "Buffer#get_string with string containing zero byte" do
212
236
  str = "hello\0world"
213
237
  buf = FFI::Buffer.new 1024
214
238
  buf.put_bytes(0, str);
215
239
  s2 = buf.get_string(0, 11);
216
- s2.should == "hello"
240
+ expect(s2).to eq("hello")
217
241
  end
242
+
218
243
  it "Buffer#put_string without length should NUL terminate" do
219
244
  str = "hello"
220
245
  buf = FFI::Buffer.new 1024
221
246
  buf.put_string(0, str);
222
247
  s2 = buf.get_bytes(0, 6);
223
- s2.should == "hello\0"
248
+ expect(s2).to eq("hello\0")
224
249
  end
225
250
  end
251
+
226
252
  describe "Buffer#put_pointer" do
227
253
  it "put_pointer(0, p).get_pointer(0) == p" do
228
254
  p = FFI::MemoryPointer.new :ulong_long
229
255
  p.put_uint(0, 0xdeadbeef)
230
256
  buf = FFI::Buffer.alloc_inout 8
231
257
  p2 = buf.put_pointer(0, p).get_pointer(0)
232
- p2.should_not be_nil
233
- p2.should == p
234
- p2.get_uint(0).should == 0xdeadbeef
258
+ expect(p2).not_to be_nil
259
+ expect(p2).to eq(p)
260
+ expect(p2.get_uint(0)).to eq(0xdeadbeef)
235
261
  end
236
262
  end
263
+
237
264
  describe "Buffer#size" do
238
265
  it "should return size" do
239
266
  buf = FFI::Buffer.new 14
240
- buf.size.should == 14
267
+ expect(buf.size).to eq(14)
241
268
  end
242
269
  end
243
270
 
@@ -247,6 +274,6 @@ describe "Buffer#initialize" do
247
274
  FFI::Buffer.new(:pointer) do |ptr|
248
275
  block_executed = true
249
276
  end
250
- block_executed.should be_true
277
+ expect(block_executed).to be true
251
278
  end
252
279
  end