diff options
author | Sutou Kouhei <[email protected]> | 2020-07-09 21:39:51 +0900 |
---|---|---|
committer | Sutou Kouhei <[email protected]> | 2020-11-18 09:05:13 +0900 |
commit | e2dfc0c26b1f3d3517002ca2645d1b67847fe518 (patch) | |
tree | 943da48b87240b9b32c7885d332ef1488f270b6f /test | |
parent | ae7b53546ca18b56c23f612b6935e98268a07602 (diff) |
[ruby/fiddle] Add support for specifying types by name as String or Symbol
For example, :voidp equals to Fiddle::TYPE_VOID_P.
https://github.com/ruby/fiddle/commit/3b4de54899
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3780
Diffstat (limited to 'test')
-rw-r--r-- | test/fiddle/test_func.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/test/fiddle/test_func.rb b/test/fiddle/test_func.rb index ca9d4ccb34..d3604c79c3 100644 --- a/test/fiddle/test_func.rb +++ b/test/fiddle/test_func.rb @@ -96,22 +96,22 @@ module Fiddle end snprintf = Function.new(snprintf_pointer, [ - TYPE_VOIDP, - TYPE_SIZE_T, - TYPE_CONST_STRING, - TYPE_VARIADIC, + :voidp, + :size_t, + :const_string, + :variadic, ], - TYPE_INT) + :int) output_buffer = " " * 1024 output = Pointer[output_buffer] written = snprintf.call(output, output.size, "int: %d, string: %.*s, const string: %s\n", - TYPE_INT, -29, - TYPE_INT, 4, - TYPE_VOIDP, "Hello", - TYPE_CONST_STRING, "World") + :int, -29, + :int, 4, + :voidp, "Hello", + :const_string, "World") assert_equal("int: -29, string: Hell, const string: World\n", output_buffer[0, written]) @@ -127,10 +127,10 @@ module Fiddle written = snprintf.call(output, output.size, "string: %.*s, const string: %s, uint: %u\n", - TYPE_INT, 2, - TYPE_VOIDP, "Hello", - TYPE_CONST_STRING, string_like_class.new("World"), - TYPE_INT, 29) + :int, 2, + :voidp, "Hello", + :const_string, string_like_class.new("World"), + :int, 29) assert_equal("string: He, const string: World, uint: 29\n", output_buffer[0, written]) end |