summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/fiddle/lib/fiddle/import.rb2
-rw-r--r--test/fiddle/test_import.rb9
3 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 92ae736..599a55f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Sep 15 09:43:18 2014 Sho Hashimoto <sho.hsmt@gmail.com>
+
+ * ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo,
+ SIZEOF_LONG_LON. [Fix GH-714]
+
Mon Sep 15 08:13:40 2014 Matthew Draper <matthew@trebex.net>
* sprintf.c (rb_str_format): rational 'f' format works for more
diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb
index f1aa712..34f5d7f 100644
--- a/ext/fiddle/lib/fiddle/import.rb
+++ b/ext/fiddle/lib/fiddle/import.rb
@@ -112,7 +112,7 @@ module Fiddle
when TYPE_LONG
return SIZEOF_LONG
when TYPE_LONG_LONG
- return SIZEOF_LONG_LON
+ return SIZEOF_LONG_LONG
when TYPE_FLOAT
return SIZEOF_FLOAT
when TYPE_DOUBLE
diff --git a/test/fiddle/test_import.rb b/test/fiddle/test_import.rb
index 62985cf..d06477b 100644
--- a/test/fiddle/test_import.rb
+++ b/test/fiddle/test_import.rb
@@ -65,6 +65,15 @@ module Fiddle
assert_equal(LIBC::MyStruct.size(), LIBC.sizeof(LIBC::MyStruct.malloc()))
end
+ Fiddle.constants.grep(/\ATYPE_(?!VOID\z)(.*)/) do
+ type = $&
+ size = Fiddle.const_get("SIZEOF_#{$1}")
+ name = $1.sub(/P\z/,"*").gsub(/_(?!T\z)/, " ").downcase
+ define_method("test_sizeof_#{name}") do
+ assert_equal(size, Fiddle::Importer.sizeof(name), type)
+ end
+ end
+
def test_unsigned_result()
d = (2 ** 31) + 1