summaryrefslogtreecommitdiff
path: root/spec/ffi/rbx/memory_pointer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ffi/rbx/memory_pointer_spec.rb')
-rw-r--r--spec/ffi/rbx/memory_pointer_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/ffi/rbx/memory_pointer_spec.rb b/spec/ffi/rbx/memory_pointer_spec.rb
index 3878973..1270c9b 100644
--- a/spec/ffi/rbx/memory_pointer_spec.rb
+++ b/spec/ffi/rbx/memory_pointer_spec.rb
@@ -104,6 +104,18 @@ describe "MemoryPointer" do
expect(m.read FFI::Type::BOOL).to eq(false)
end
+ it "allows definition of a custom typedef" do
+ FFI.typedef :uint32, :fubar_t
+ expect(FFI.find_type(:fubar_t)).to eq(FFI::Type::Builtin::UINT32)
+ end
+
+ it "allows overwriting of a default typedef" do
+ FFI.typedef :uint32, :char
+ expect(FFI.find_type(:char)).to eq(FFI::Type::Builtin::UINT32)
+ ensure
+ FFI.typedef FFI::Type::Builtin::CHAR, :char
+ end
+
it "allows writing a custom typedef" do
FFI.typedef :uint, :fubar_t
FFI.typedef :size_t, :fubar2_t
@@ -189,4 +201,12 @@ describe "MemoryPointer" do
end
expect(block_executed).to be true
end
+
+ it "has a memsize function", skip: RUBY_ENGINE != "ruby" do
+ base_size = ObjectSpace.memsize_of(Object.new)
+
+ pointer = FFI::MemoryPointer.from_string("FFI is Awesome")
+ size = ObjectSpace.memsize_of(pointer)
+ expect(size).to be > base_size
+ end
end