summaryrefslogtreecommitdiff
path: root/test/fiddle/test_import.rb
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2020-07-09 20:19:20 +0900
committerSutou Kouhei <kou@cozmixng.org>2020-11-18 09:05:13 +0900
commitae7b53546ca18b56c23f612b6935e98268a07602 (patch)
tree6669206356ba05e4ee4d0e34dd99901ad1ea268c /test/fiddle/test_import.rb
parent64926d500782cadf578724c3d1e7f59e7aaf200f (diff)
[ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"
Add rb_fiddle_ prefix to conversion functions.h to keep backward compatibility but value_to_generic() isn't safe for TYPE_CONST_STRING and not String src. Use rb_fiddle_value_to_generic() instead. https://github.com/ruby/fiddle/commit/0ffcaa39e5
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3780
Diffstat (limited to 'test/fiddle/test_import.rb')
-rw-r--r--test/fiddle/test_import.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/fiddle/test_import.rb b/test/fiddle/test_import.rb
index c56d81c351..4afd8e5562 100644
--- a/test/fiddle/test_import.rb
+++ b/test/fiddle/test_import.rb
@@ -112,10 +112,17 @@ module Fiddle
Fiddle.constants.grep(/\ATYPE_(?!VOID|VARIADIC\z)(.*)/) do
type = $&
- size = Fiddle.const_get("SIZEOF_#{$1}")
- name = $1.sub(/P\z/,"*").gsub(/_(?!T\z)/, " ").downcase
+ const_type_name = $1
+ size = Fiddle.const_get("SIZEOF_#{const_type_name}")
+ if const_type_name == "CONST_STRING"
+ name = "const_string"
+ type_name = "const char*"
+ else
+ name = $1.sub(/P\z/,"*").gsub(/_(?!T\z)/, " ").downcase
+ type_name = name
+ end
define_method("test_sizeof_#{name}") do
- assert_equal(size, Fiddle::Importer.sizeof(name), type)
+ assert_equal(size, Fiddle::Importer.sizeof(type_name), type)
end
end