gir_ffi 0.15.1 → 0.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +42 -0
  3. data/README.md +10 -10
  4. data/TODO.md +14 -35
  5. data/docs/Documentation.md +6 -0
  6. data/docs/Subclassing.md +38 -0
  7. data/lib/ffi-glib.rb +8 -3
  8. data/lib/ffi-glib/byte_array.rb +2 -1
  9. data/lib/ffi-glib/container_class_methods.rb +1 -3
  10. data/lib/ffi-glib/destroy_notify.rb +2 -2
  11. data/lib/ffi-glib/hash_table.rb +1 -2
  12. data/lib/ffi-glib/list.rb +11 -5
  13. data/lib/ffi-glib/list_methods.rb +12 -0
  14. data/lib/ffi-glib/s_list.rb +10 -4
  15. data/lib/ffi-gobject.rb +2 -5
  16. data/lib/ffi-gobject/object.rb +102 -92
  17. data/lib/ffi-gobject/object_class.rb +1 -1
  18. data/lib/ffi-gobject/ruby_closure.rb +1 -1
  19. data/lib/ffi-gobject/value.rb +108 -117
  20. data/lib/ffi-gobject_introspection/i_base_info.rb +35 -27
  21. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  22. data/lib/gir_ffi-base/gobject/lib.rb +4 -0
  23. data/lib/gir_ffi/array_element_convertor.rb +2 -3
  24. data/lib/gir_ffi/boxed_base.rb +13 -11
  25. data/lib/gir_ffi/builder.rb +3 -4
  26. data/lib/gir_ffi/builder_helper.rb +10 -2
  27. data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
  28. data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
  29. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
  31. data/lib/gir_ffi/builders/callback_builder.rb +25 -11
  32. data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
  33. data/lib/gir_ffi/builders/enum_builder.rb +9 -5
  34. data/lib/gir_ffi/builders/field_builder.rb +2 -1
  35. data/lib/gir_ffi/builders/function_builder.rb +1 -1
  36. data/lib/gir_ffi/builders/interface_builder.rb +3 -1
  37. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  38. data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
  39. data/lib/gir_ffi/builders/method_template.rb +4 -4
  40. data/lib/gir_ffi/builders/module_builder.rb +4 -2
  41. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
  42. data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
  43. data/lib/gir_ffi/builders/object_builder.rb +18 -6
  44. data/lib/gir_ffi/builders/property_builder.rb +1 -2
  45. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
  46. data/lib/gir_ffi/builders/struct_builder.rb +34 -7
  47. data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
  48. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  49. data/lib/gir_ffi/callback_base.rb +7 -8
  50. data/lib/gir_ffi/class_base.rb +1 -0
  51. data/lib/gir_ffi/core.rb +17 -2
  52. data/lib/gir_ffi/glib_error.rb +1 -2
  53. data/lib/gir_ffi/in_pointer.rb +7 -0
  54. data/lib/gir_ffi/object_base.rb +27 -0
  55. data/lib/gir_ffi/return_value_info.rb +1 -2
  56. data/lib/gir_ffi/struct_base.rb +1 -9
  57. data/lib/gir_ffi/struct_like_base.rb +9 -5
  58. data/lib/gir_ffi/type_map.rb +1 -0
  59. data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
  60. data/lib/gir_ffi/union_base.rb +1 -9
  61. data/lib/gir_ffi/user_defined_object_info.rb +3 -2
  62. data/lib/gir_ffi/version.rb +1 -1
  63. data/lib/gir_ffi/vfunc_implementation.rb +1 -0
  64. metadata +106 -143
  65. data/Gemfile +0 -14
  66. data/Rakefile +0 -9
  67. data/tasks/test.rake +0 -204
  68. data/test/base_test_helper.rb +0 -70
  69. data/test/ffi-glib/array_test.rb +0 -203
  70. data/test/ffi-glib/byte_array_test.rb +0 -28
  71. data/test/ffi-glib/bytes_test.rb +0 -61
  72. data/test/ffi-glib/closure_test.rb +0 -38
  73. data/test/ffi-glib/destroy_notify_test.rb +0 -18
  74. data/test/ffi-glib/hash_table_test.rb +0 -68
  75. data/test/ffi-glib/list_test.rb +0 -86
  76. data/test/ffi-glib/main_loop_test.rb +0 -53
  77. data/test/ffi-glib/ptr_array_test.rb +0 -112
  78. data/test/ffi-glib/ruby_closure_test.rb +0 -62
  79. data/test/ffi-glib/s_list_test.rb +0 -76
  80. data/test/ffi-glib/strv_test.rb +0 -60
  81. data/test/ffi-glib/variant_test.rb +0 -12
  82. data/test/ffi-gobject/gobject_test.rb +0 -76
  83. data/test/ffi-gobject/object_class_test.rb +0 -31
  84. data/test/ffi-gobject/object_test.rb +0 -122
  85. data/test/ffi-gobject/param_spec_test.rb +0 -32
  86. data/test/ffi-gobject/value_test.rb +0 -390
  87. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
  88. data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
  89. data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
  90. data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
  91. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
  92. data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
  93. data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
  94. data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
  95. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
  96. data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
  97. data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
  98. data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
  99. data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
  100. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
  101. data/test/ffi-gobject_introspection/lib_test.rb +0 -13
  102. data/test/ffi-gobject_introspection/strv_test.rb +0 -46
  103. data/test/ffi-gobject_test.rb +0 -151
  104. data/test/gir_ffi/allocation_helper_test.rb +0 -36
  105. data/test/gir_ffi/arg_helper_test.rb +0 -139
  106. data/test/gir_ffi/boolean_test.rb +0 -43
  107. data/test/gir_ffi/boxed_base_test.rb +0 -65
  108. data/test/gir_ffi/builder_test.rb +0 -322
  109. data/test/gir_ffi/builders/argument_builder_test.rb +0 -651
  110. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
  111. data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -126
  112. data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
  113. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -81
  114. data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
  115. data/test/gir_ffi/builders/constructor_builder_test.rb +0 -37
  116. data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
  117. data/test/gir_ffi/builders/field_builder_test.rb +0 -134
  118. data/test/gir_ffi/builders/function_builder_test.rb +0 -550
  119. data/test/gir_ffi/builders/initializer_builder_test.rb +0 -54
  120. data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
  121. data/test/gir_ffi/builders/module_builder_test.rb +0 -43
  122. data/test/gir_ffi/builders/object_builder_test.rb +0 -98
  123. data/test/gir_ffi/builders/property_builder_test.rb +0 -158
  124. data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
  125. data/test/gir_ffi/builders/return_value_builder_test.rb +0 -433
  126. data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -197
  127. data/test/gir_ffi/builders/struct_builder_test.rb +0 -93
  128. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
  129. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
  130. data/test/gir_ffi/builders/union_builder_test.rb +0 -28
  131. data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -524
  132. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -101
  133. data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -241
  134. data/test/gir_ffi/callback_base_test.rb +0 -22
  135. data/test/gir_ffi/class_base_test.rb +0 -166
  136. data/test/gir_ffi/core_test.rb +0 -98
  137. data/test/gir_ffi/enum_base_test.rb +0 -43
  138. data/test/gir_ffi/error_type_info_test.rb +0 -50
  139. data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -20
  140. data/test/gir_ffi/g_type_test.rb +0 -31
  141. data/test/gir_ffi/in_pointer_test.rb +0 -203
  142. data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
  143. data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -21
  144. data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
  145. data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
  146. data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
  147. data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -711
  148. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
  149. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
  150. data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
  151. data/test/gir_ffi/interface_base_test.rb +0 -20
  152. data/test/gir_ffi/method_stubber_test.rb +0 -65
  153. data/test/gir_ffi/object_base_test.rb +0 -64
  154. data/test/gir_ffi/object_store_test.rb +0 -41
  155. data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
  156. data/test/gir_ffi/sized_array_test.rb +0 -206
  157. data/test/gir_ffi/struct_base_test.rb +0 -23
  158. data/test/gir_ffi/struct_like_base_test.rb +0 -167
  159. data/test/gir_ffi/type_map_test.rb +0 -17
  160. data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
  161. data/test/gir_ffi/union_base_test.rb +0 -23
  162. data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
  163. data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
  164. data/test/gir_ffi/variable_name_generator_test.rb +0 -18
  165. data/test/gir_ffi/version_test.rb +0 -9
  166. data/test/gir_ffi/zero_terminated_test.rb +0 -108
  167. data/test/gir_ffi_test_helper.rb +0 -84
  168. data/test/integration/callback_exceptions_test.rb +0 -59
  169. data/test/integration/derived_classes_test.rb +0 -53
  170. data/test/integration/generated_everything_test.rb +0 -452
  171. data/test/integration/generated_gimarshallingtests_test.rb +0 -3096
  172. data/test/integration/generated_gio_test.rb +0 -116
  173. data/test/integration/generated_glib_test.rb +0 -10
  174. data/test/integration/generated_gobject_test.rb +0 -124
  175. data/test/integration/generated_gst_test.rb +0 -38
  176. data/test/integration/generated_gtk_source_test.rb +0 -32
  177. data/test/integration/generated_gtop_test.rb +0 -22
  178. data/test/integration/generated_pango_ft2_test.rb +0 -17
  179. data/test/integration/generated_pango_test.rb +0 -24
  180. data/test/integration/generated_regress_test.rb +0 -4038
  181. data/test/integration/generated_secret_test.rb +0 -14
  182. data/test/integration/generated_utility_test.rb +0 -174
  183. data/test/integration/generated_warnlib_test.rb +0 -43
  184. data/test/integration/method_lookup_test.rb +0 -34
  185. data/test/introspection_test_helper.rb +0 -93
  186. data/test/lib/Makefile.am +0 -110
  187. data/test/lib/autogen.sh +0 -4
  188. data/test/lib/configure.ac +0 -34
  189. data/test/lib/m4/jhflags.m4 +0 -21
  190. data/test/minitest/stats_plugin.rb +0 -30
@@ -1,3096 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- require "gir_ffi"
6
-
7
- GirFFI.setup :GIMarshallingTests
8
-
9
- # Tests generated methods and functions in the GIMarshallingTests namespace.
10
- describe GIMarshallingTests do
11
- let(:derived_klass) do
12
- Object.const_set("DerivedClass#{Sequence.next}",
13
- Class.new(GIMarshallingTests::Object))
14
- end
15
-
16
- def make_derived_instance
17
- GirFFI.define_type derived_klass do |info|
18
- yield info if block_given?
19
- end
20
- derived_klass.new
21
- end
22
-
23
- describe "GIMarshallingTests::BoxedStruct" do
24
- let(:instance) { GIMarshallingTests::BoxedStruct.new }
25
-
26
- it "has a writable field long_" do
27
- instance.long_ = 42
28
- assert_equal 42, instance.long_
29
- instance.long_ = 43
30
- assert_equal 43, instance.long_
31
- end
32
-
33
- it "has a writable field string_" do
34
- instance.string_ = "foobar"
35
- _(instance.string_).must_equal "foobar"
36
- end
37
-
38
- it "has a writable field g_strv" do
39
- _(instance.g_strv).must_be :==, []
40
- instance.g_strv = %w(foo bar)
41
- _(instance.g_strv).must_be :==, %w(foo bar)
42
- end
43
-
44
- it "creates an instance using #new" do
45
- bx = GIMarshallingTests::BoxedStruct.new
46
- assert_instance_of GIMarshallingTests::BoxedStruct, bx
47
- _(bx.struct).must_be :owned?
48
- end
49
-
50
- it "has a working method #inv" do
51
- instance.long_ = 42
52
- instance.inv
53
- pass
54
- end
55
-
56
- it "has a working function #inout" do
57
- bx = GIMarshallingTests::BoxedStruct.new
58
- bx.long_ = 42
59
- _(bx.struct).must_be :owned?
60
-
61
- res = GIMarshallingTests::BoxedStruct.inout bx
62
- _(bx.struct).must_be :owned?
63
- _(res.struct).must_be :owned?
64
-
65
- assert_equal 0, res.long_
66
- end
67
-
68
- it "has a working function #out" do
69
- res = GIMarshallingTests::BoxedStruct.out
70
- _(res.struct).must_be :owned?
71
- assert_equal 42, res.long_
72
- end
73
-
74
- it "has a working function #returnv" do
75
- res = GIMarshallingTests::BoxedStruct.returnv
76
- _(res.struct).must_be :owned?
77
- assert_equal 42, res.long_
78
- _(res.g_strv).must_be :==, %w(0 1 2)
79
- end
80
- end
81
-
82
- it "has the constant CONSTANT_GERROR_CODE" do
83
- assert_equal 5, GIMarshallingTests::CONSTANT_GERROR_CODE
84
- end
85
-
86
- it "has the constant CONSTANT_GERROR_DEBUG_MESSAGE" do
87
- _(GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE).must_equal(
88
- "we got an error, life is shit")
89
- end
90
-
91
- it "has the constant CONSTANT_GERROR_DOMAIN" do
92
- assert_equal "gi-marshalling-tests-gerror-domain",
93
- GIMarshallingTests::CONSTANT_GERROR_DOMAIN
94
- end
95
-
96
- it "has the constant CONSTANT_GERROR_MESSAGE" do
97
- assert_equal "gi-marshalling-tests-gerror-message",
98
- GIMarshallingTests::CONSTANT_GERROR_MESSAGE
99
- end
100
-
101
- it "has the constant CONSTANT_NUMBER" do
102
- assert_equal 42, GIMarshallingTests::CONSTANT_NUMBER
103
- end
104
-
105
- it "has the constant CONSTANT_UTF8" do
106
- assert_equal "const ♥ utf8", GIMarshallingTests::CONSTANT_UTF8
107
- end
108
-
109
- describe "GIMarshallingTests::Enum" do
110
- it "has the member :value1" do
111
- assert_equal 0, GIMarshallingTests::Enum[:value1]
112
- end
113
-
114
- it "has the member :value2" do
115
- assert_equal 1, GIMarshallingTests::Enum[:value2]
116
- end
117
-
118
- it "has the member :value3" do
119
- assert_equal 42, GIMarshallingTests::Enum[:value3]
120
- end
121
- end
122
-
123
- describe "GIMarshallingTests::Flags" do
124
- it "has the member :value1" do
125
- assert_equal 1, GIMarshallingTests::Flags[:value1]
126
- end
127
-
128
- it "has the member :value2" do
129
- assert_equal 2, GIMarshallingTests::Flags[:value2]
130
- end
131
-
132
- it "has the member :value3" do
133
- assert_equal 4, GIMarshallingTests::Flags[:value3]
134
- end
135
-
136
- it "has the member :mask" do
137
- assert_equal 3, GIMarshallingTests::Flags[:mask]
138
- end
139
-
140
- it "has the member :mask2" do
141
- assert_equal 3, GIMarshallingTests::Flags[:mask2]
142
- end
143
-
144
- it "has a working function #in" do
145
- GIMarshallingTests::Flags.in value2: true
146
- end
147
-
148
- it "has a working function #in_zero" do
149
- GIMarshallingTests::Flags.in_zero 0
150
- end
151
-
152
- it "has a working function #inout" do
153
- result = GIMarshallingTests::Flags.inout value2: true
154
- _(result).must_equal(value1: true)
155
- end
156
-
157
- it "has a working function #out" do
158
- result = GIMarshallingTests::Flags.out
159
- _(result).must_equal(value2: true)
160
- end
161
-
162
- it "has a working function #returnv" do
163
- result = GIMarshallingTests::Flags.returnv
164
- _(result).must_equal(value2: true)
165
- end
166
- end
167
-
168
- describe "GIMarshallingTests::GEnum" do
169
- it "has the member :value1" do
170
- assert_equal 0, GIMarshallingTests::GEnum[:value1]
171
- end
172
-
173
- it "has the member :value2" do
174
- assert_equal 1, GIMarshallingTests::GEnum[:value2]
175
- end
176
-
177
- it "has the member :value3" do
178
- assert_equal 42, GIMarshallingTests::GEnum[:value3]
179
- end
180
-
181
- it "has a working function #in" do
182
- GIMarshallingTests::GEnum.in :value3
183
- end
184
-
185
- it "has a working function #inout" do
186
- result = GIMarshallingTests::GEnum.inout :value3
187
- _(result).must_equal :value1
188
- end
189
-
190
- it "has a working function #out" do
191
- result = GIMarshallingTests::GEnum.out
192
- _(result).must_equal :value3
193
- end
194
-
195
- it "has a working function #returnv" do
196
- result = GIMarshallingTests::GEnum.returnv
197
- _(result).must_equal :value3
198
- end
199
- end
200
-
201
- describe "GIMarshallingTests::Interface" do
202
- it "has a working method #test_int8_in" do
203
- derived_klass.class_eval { include GIMarshallingTests::Interface }
204
- derived_instance = make_derived_instance do |info|
205
- info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ }
206
- end
207
- derived_instance.test_int8_in 8
208
- _(derived_instance.int).must_equal 8
209
- end
210
- end
211
-
212
- describe "GIMarshallingTests::Interface2" do
213
- it "must be tested for clashes with Interface" do
214
- skip "Needs more work to determine desired behavior"
215
- end
216
- end
217
-
218
- describe "GIMarshallingTests::Interface3" do
219
- it "has a working method #test_variant_array_in" do
220
- derived_klass.class_eval { include GIMarshallingTests::Interface3 }
221
- derived_instance = make_derived_instance do |info|
222
- info.install_vfunc_implementation :test_variant_array_in, proc { |obj, in_|
223
- obj.int = in_.to_a.first.get_byte
224
- }
225
- end
226
- derived_instance.test_variant_array_in [GLib::Variant.new_byte(42)]
227
- _(derived_instance.int).must_equal 42
228
- end
229
- end
230
-
231
- describe "GIMarshallingTests::InterfaceImpl" do
232
- it "has a working method #get_as_interface" do
233
- obj = GIMarshallingTests::InterfaceImpl.new []
234
- result = obj.get_as_interface
235
- _(result).must_be_kind_of GIMarshallingTests::Interface
236
- end
237
- end
238
-
239
- describe "GIMarshallingTests::NestedStruct" do
240
- let(:instance) { GIMarshallingTests::NestedStruct.new }
241
- it "has a writable field simple_struct" do
242
- assert_instance_of GIMarshallingTests::SimpleStruct,
243
- instance.simple_struct
244
- new_struct = GIMarshallingTests::SimpleStruct.new
245
- new_struct.int8 = 42
246
- instance.simple_struct = new_struct
247
- _(instance.simple_struct.int8).must_equal 42
248
- end
249
- end
250
-
251
- describe "GIMarshallingTests::NoTypeFlags" do
252
- it "has the member :value1" do
253
- assert_equal 1, GIMarshallingTests::NoTypeFlags[:value1]
254
- end
255
- it "has the member :value2" do
256
- assert_equal 2, GIMarshallingTests::NoTypeFlags[:value2]
257
- end
258
- it "has the member :value3" do
259
- assert_equal 4, GIMarshallingTests::NoTypeFlags[:value3]
260
- end
261
- it "has the member :mask" do
262
- assert_equal 3, GIMarshallingTests::NoTypeFlags[:mask]
263
- end
264
- it "has the member :mask2" do
265
- assert_equal 3, GIMarshallingTests::NoTypeFlags[:mask2]
266
- end
267
- end
268
-
269
- describe "GIMarshallingTests::NotSimpleStruct" do
270
- let(:instance) { GIMarshallingTests::NotSimpleStruct.new }
271
-
272
- it "has a writable field pointer" do
273
- _(instance.pointer).must_be_nil
274
- nested = GIMarshallingTests::NestedStruct.new
275
- nested.simple_struct.int8 = 23
276
- instance.pointer = nested
277
- _(instance.pointer.simple_struct.int8).must_equal 23
278
- end
279
- end
280
-
281
- it "has the constant OVERRIDES_CONSTANT" do
282
- assert_equal 42, GIMarshallingTests::OVERRIDES_CONSTANT
283
- end
284
-
285
- describe "GIMarshallingTests::Object" do
286
- it "creates an instance using #new" do
287
- ob = GIMarshallingTests::Object.new 42
288
- assert_instance_of GIMarshallingTests::Object, ob
289
- assert_equal 42, ob.int
290
- end
291
-
292
- it "fails to create an instance using #new_fail" do
293
- _(proc { GIMarshallingTests::Object.new_fail 42 }).must_raise GirFFI::GLibError
294
- end
295
-
296
- it "has a working function #full_inout" do
297
- ob = GIMarshallingTests::Object.new 42
298
- _(object_ref_count(ob)).must_equal 1
299
-
300
- res = GIMarshallingTests::Object.full_inout ob
301
-
302
- _(object_ref_count(ob)).must_equal 1
303
- _(object_ref_count(res)).must_equal 1
304
-
305
- _(res).must_be_instance_of GIMarshallingTests::Object
306
- _(res.int).must_equal 0
307
- end
308
-
309
- it "has a working function #full_out" do
310
- res = GIMarshallingTests::Object.full_out
311
- _(res).must_be_instance_of GIMarshallingTests::Object
312
- _(object_ref_count(res)).must_equal 1
313
- end
314
-
315
- it "has a working function #full_return" do
316
- res = GIMarshallingTests::Object.full_return
317
- _(res).must_be_instance_of GIMarshallingTests::Object
318
- _(object_ref_count(res)).must_equal 1
319
- end
320
-
321
- it "has a working function #none_inout" do
322
- ob = GIMarshallingTests::Object.new 42
323
- _(object_ref_count(ob)).must_equal 1
324
-
325
- res = GIMarshallingTests::Object.none_inout ob
326
-
327
- _(object_ref_count(ob)).must_equal 1
328
- _(object_ref_count(res)).must_equal 2
329
-
330
- _(res).must_be_instance_of GIMarshallingTests::Object
331
- _(ob.int).must_equal 42
332
- _(res.int).must_equal 0
333
- end
334
-
335
- it "has a working function #none_out" do
336
- res = GIMarshallingTests::Object.none_out
337
- _(res).must_be_instance_of GIMarshallingTests::Object
338
- _(object_ref_count(res)).must_equal 2
339
- end
340
-
341
- it "has a working function #none_return" do
342
- res = GIMarshallingTests::Object.none_return
343
- _(res).must_be_instance_of GIMarshallingTests::Object
344
- _(object_ref_count(res)).must_equal 2
345
- end
346
-
347
- it "has a working function #static_method" do
348
- GIMarshallingTests::Object.static_method
349
- pass
350
- end
351
-
352
- let(:instance) { GIMarshallingTests::Object.new 42 }
353
-
354
- it "has a working method #call_vfunc_with_callback" do
355
- cb = nil
356
- user_data = nil
357
- result = nil
358
-
359
- derived_instance = make_derived_instance do |info|
360
- info.install_vfunc_implementation :vfunc_with_callback, proc { |_obj, callback, callback_data|
361
- cb = callback
362
- user_data = callback_data.address
363
- result = callback.call(42, callback_data)
364
- }
365
- end
366
- derived_instance.call_vfunc_with_callback
367
-
368
- _(user_data).must_equal 0xdeadbeef
369
- # TODO: Change implementation of CallbackBase so that this becomes an
370
- # instance of GIMarshallingTests::CallbackIntInt
371
- _(cb).must_be_instance_of FFI::Function
372
- _(result).must_equal 42
373
- end
374
-
375
- it "has a working method #full_in" do
376
- skip "This function is defined in the header but not implemented"
377
- end
378
-
379
- it "has a working method #get_ref_info_for_vfunc_in_object_transfer_full" do
380
- obj = nil
381
- derived_instance = make_derived_instance do |info|
382
- info.install_vfunc_implementation :vfunc_in_object_transfer_full, proc { |_this, object|
383
- obj = object
384
- }
385
- end
386
- result = derived_instance
387
- .get_ref_info_for_vfunc_in_object_transfer_full GIMarshallingTests::Object.gtype
388
- _(result).must_equal [1, false]
389
- _(obj).must_be_instance_of GIMarshallingTests::Object
390
- end
391
-
392
- it "has a working method #get_ref_info_for_vfunc_in_object_transfer_none" do
393
- obj = nil
394
- derived_instance = make_derived_instance do |info|
395
- info.install_vfunc_implementation :vfunc_in_object_transfer_none, proc { |_this, object|
396
- obj = object
397
- }
398
- end
399
- result = derived_instance
400
- .get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.gtype
401
- _(object_ref_count(obj)).must_be :>, 0
402
- _(result).must_equal [2, false]
403
- _(obj).must_be_instance_of GIMarshallingTests::Object
404
- end
405
-
406
- it "has a working method #get_ref_info_for_vfunc_out_object_transfer_full" do
407
- obj = nil
408
- derived_instance = make_derived_instance do |info|
409
- info.install_vfunc_implementation :vfunc_out_object_transfer_full, proc { |_obj|
410
- obj = GIMarshallingTests::Object.new(42)
411
- }
412
- end
413
- result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_full
414
- _(object_ref_count(obj)).must_be :>, 0
415
- # TODO: Check desired result
416
- _(result).must_equal [2, false]
417
- end
418
-
419
- it "has a working method #get_ref_info_for_vfunc_out_object_transfer_none" do
420
- derived_instance = make_derived_instance do |info|
421
- info.install_vfunc_implementation :vfunc_out_object_transfer_none, proc { |_obj|
422
- GIMarshallingTests::Object.new 42
423
- }
424
- end
425
- result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_none
426
- _(result).must_equal [1, false]
427
- end
428
-
429
- it "has a working method #get_ref_info_for_vfunc_return_object_transfer_full" do
430
- derived_instance = make_derived_instance do |info|
431
- info.install_vfunc_implementation :vfunc_return_object_transfer_full, proc { |_obj|
432
- GIMarshallingTests::Object.new 42
433
- }
434
- end
435
- result = derived_instance.get_ref_info_for_vfunc_return_object_transfer_full
436
- _(result).must_equal [2, false]
437
- end
438
-
439
- it "has a working method #get_ref_info_for_vfunc_return_object_transfer_none" do
440
- derived_instance = make_derived_instance do |info|
441
- info.install_vfunc_implementation :vfunc_return_object_transfer_none, proc { |_obj|
442
- GIMarshallingTests::Object.new 42
443
- }
444
- end
445
- result = derived_instance.get_ref_info_for_vfunc_return_object_transfer_none
446
- _(result).must_equal [1, false]
447
- end
448
-
449
- it "has a working method #int8_in" do
450
- derived_instance = make_derived_instance do |info|
451
- info.install_vfunc_implementation :method_int8_in, proc { |obj, in_| obj.int = in_ }
452
- end
453
- derived_instance.int8_in 23
454
- _(derived_instance.int).must_equal 23
455
- end
456
-
457
- it "has a working method #int8_out" do
458
- derived_instance = make_derived_instance do |info|
459
- info.install_vfunc_implementation :method_int8_out, proc { |_obj| 42 }
460
- end
461
-
462
- _(derived_instance.int8_out).must_equal 42
463
- end
464
-
465
- it "has a working method #method" do
466
- instance.method
467
- pass
468
- end
469
-
470
- it "has a working method #method_array_in" do
471
- instance.method_array_in [-1, 0, 1, 2]
472
- pass
473
- end
474
-
475
- it "has a working method #method_array_inout" do
476
- res = instance.method_array_inout [-1, 0, 1, 2]
477
- _(res).must_be :==, [-2, -1, 0, 1, 2]
478
- end
479
-
480
- it "has a working method #method_array_out" do
481
- res = instance.method_array_out
482
- _(res).must_be :==, [-1, 0, 1, 2]
483
- end
484
-
485
- it "has a working method #method_array_return" do
486
- res = instance.method_array_return
487
- _(res).must_be :==, [-1, 0, 1, 2]
488
- end
489
-
490
- it "has a working method #method_int8_arg_and_out_callee" do
491
- derived_instance = make_derived_instance do |info|
492
- info.install_vfunc_implementation :method_int8_arg_and_out_callee, proc { |_obj, arg|
493
- 2 * arg
494
- }
495
- end
496
- result = derived_instance.method_int8_arg_and_out_callee 32
497
- _(result).must_equal 64
498
- end
499
-
500
- it "has a working method #method_int8_arg_and_out_caller" do
501
- derived_instance = make_derived_instance do |info|
502
- info.install_vfunc_implementation :method_int8_arg_and_out_caller, proc { |_obj, arg|
503
- 2 * arg
504
- }
505
- end
506
- result = derived_instance.method_int8_arg_and_out_caller 32
507
- _(result).must_equal 64
508
- end
509
-
510
- it "has a working method #method_int8_in" do
511
- derived_instance = make_derived_instance do |info|
512
- info.install_vfunc_implementation :method_int8_in, proc { |obj, in_| obj.int = in_ }
513
- end
514
- derived_instance.method_int8_in 108
515
- _(derived_instance.int).must_equal 108
516
- end
517
-
518
- it "has a working method #method_int8_out" do
519
- derived_instance = make_derived_instance do |info|
520
- info.install_vfunc_implementation :method_int8_out, proc { |_obj| 42 }
521
- end
522
- _(derived_instance.method_int8_out).must_equal 42
523
- end
524
-
525
- it "has a working method #method_str_arg_out_ret" do
526
- derived_instance = make_derived_instance do |info|
527
- info.install_vfunc_implementation :method_str_arg_out_ret, proc { |_obj, arg| [arg, 42] }
528
- end
529
- _(derived_instance.method_str_arg_out_ret("foo")).must_equal ["foo", 42]
530
- end
531
-
532
- it "has a working method #method_variant_array_in" do
533
- skip "This function is defined in the header but not implemented"
534
- end
535
-
536
- it "has a working method #method_with_default_implementation" do
537
- instance.method_with_default_implementation 104
538
- assert_equal 104, instance.int
539
- end
540
-
541
- it "has a working method #none_in" do
542
- instance.none_in
543
- pass
544
- end
545
-
546
- it "has a working method #overridden_method" do
547
- instance.set_property("int", 0)
548
- instance.overridden_method
549
- pass
550
- end
551
-
552
- it "has a working method #vfunc_array_out_parameter" do
553
- derived_instance = make_derived_instance do |info|
554
- info.install_vfunc_implementation :vfunc_array_out_parameter, proc { |_obj|
555
- [1.1, 2.2, 3.3]
556
- }
557
- end
558
- result = derived_instance.vfunc_array_out_parameter
559
- arr = result.to_a
560
- _(arr.length).must_equal 3
561
- _(arr[0]).must_be_close_to 1.1
562
- _(arr[1]).must_be_close_to 2.2
563
- _(arr[2]).must_be_close_to 3.3
564
- end
565
-
566
- it "has a working method #vfunc_caller_allocated_out_parameter" do
567
- derived_instance = make_derived_instance do |info|
568
- info.install_vfunc_implementation :vfunc_caller_allocated_out_parameter, proc { |_obj|
569
- "Hello!"
570
- }
571
- end
572
- result = derived_instance.vfunc_caller_allocated_out_parameter
573
- _(result).must_equal "Hello!"
574
- end
575
-
576
- it "has a working method #vfunc_meth_with_error" do
577
- derived_instance = make_derived_instance do |info|
578
- info.install_vfunc_implementation :vfunc_meth_with_err, proc { |_object, x|
579
- raise "This is not the answer!" unless x == 42
580
-
581
- true
582
- }
583
- end
584
- result = derived_instance.vfunc_meth_with_error 42
585
- _(result).must_equal true
586
-
587
- err = _(proc { derived_instance.vfunc_meth_with_error(21) })
588
- .must_raise GirFFI::GLibError
589
- _(err.message).must_equal "This is not the answer!"
590
- _(err.domain).must_equal "gir_ffi"
591
- _(err.code).must_equal 0
592
- end
593
-
594
- it "has a working method #vfunc_multiple_out_parameters" do
595
- derived_instance = make_derived_instance do |info|
596
- info.install_vfunc_implementation(
597
- :vfunc_multiple_out_parameters,
598
- proc { |*_args| [42.1, -142.3] })
599
- end
600
- result = derived_instance.vfunc_multiple_out_parameters
601
- _(result[0]).must_be_close_to 42.1
602
- _(result[1]).must_be_close_to(-142.3)
603
- end
604
-
605
- it "has a working method #vfunc_one_out_parameter" do
606
- derived_instance = make_derived_instance do |info|
607
- info.install_vfunc_implementation(
608
- :vfunc_one_out_parameter,
609
- proc { |*_args| 23.4 })
610
- end
611
- _(derived_instance.vfunc_one_out_parameter)
612
- .must_be_within_epsilon 23.4
613
- end
614
-
615
- it "has a working method #vfunc_out_enum" do
616
- derived_instance = make_derived_instance do |info|
617
- info.install_vfunc_implementation :vfunc_out_enum, proc { |_obj| :value2 }
618
- end
619
- _(derived_instance.vfunc_out_enum).must_equal :value2
620
- end
621
-
622
- it "has a working method #vfunc_return_enum" do
623
- derived_instance = make_derived_instance do |info|
624
- info.install_vfunc_implementation :vfunc_return_enum, proc { |_obj| :value2 }
625
- end
626
- _(derived_instance.vfunc_return_enum).must_equal :value2
627
- end
628
-
629
- it "has a working method #vfunc_return_value_and_multiple_out_parameters" do
630
- derived_instance = make_derived_instance do |info|
631
- info.install_vfunc_implementation(
632
- :vfunc_return_value_and_multiple_out_parameters,
633
- proc { |*_args| [42, -142, 3] })
634
- end
635
- _(derived_instance.vfunc_return_value_and_multiple_out_parameters)
636
- .must_equal [42, -142, 3]
637
- end
638
-
639
- it "has a working method #vfunc_return_value_and_one_out_parameter" do
640
- derived_instance = make_derived_instance do |info|
641
- info.install_vfunc_implementation(
642
- :vfunc_return_value_and_one_out_parameter,
643
- proc { |*_args| [42, -142] })
644
- end
645
- _(derived_instance.vfunc_return_value_and_one_out_parameter)
646
- .must_equal [42, -142]
647
- end
648
-
649
- it "has a working method #vfunc_return_value_only" do
650
- derived_instance = make_derived_instance do |info|
651
- info.install_vfunc_implementation :vfunc_return_value_only, proc { |_obj| 0x1234_5678 }
652
- end
653
- result = derived_instance.vfunc_return_value_only
654
- _(result).must_equal 0x1234_5678
655
- end
656
-
657
- it "has a working method #vfunc_with_callback" do
658
- result = 1
659
-
660
- derived_instance = make_derived_instance do |info|
661
- info.install_vfunc_implementation :vfunc_with_callback, proc { |_obj, callback, callback_data|
662
- callback.call(42, callback_data)
663
- }
664
- end
665
-
666
- derived_instance.vfunc_with_callback { |val, user_data| result = val + user_data }
667
-
668
- # The current implementation of the vfunc_with_callback method currently
669
- # doesn't actually call the virtual function vfunc_with_callback.
670
- _(result).must_equal 1
671
- _(result).wont_equal 42 + 23
672
- end
673
-
674
- describe "its 'int' property" do
675
- it "can be retrieved with #get_property" do
676
- assert_equal 42, instance.get_property("int")
677
- end
678
- it "can be retrieved with #int" do
679
- assert_equal 42, instance.int
680
- end
681
- it "can be set with #set_property" do
682
- instance.set_property("int", 13)
683
- assert_equal 13, instance.get_property("int")
684
- end
685
- it "can be set with #int=" do
686
- instance.int = 1
687
- assert_equal 1, instance.int
688
- end
689
- end
690
- end
691
-
692
- describe "GIMarshallingTests::OverridesObject" do
693
- it "creates an instance using #new" do
694
- ob = GIMarshallingTests::OverridesObject.new
695
- assert_instance_of GIMarshallingTests::OverridesObject, ob
696
- end
697
-
698
- it "has a working function #returnv" do
699
- ob = GIMarshallingTests::OverridesObject.returnv
700
- assert_instance_of GIMarshallingTests::OverridesObject, ob
701
- end
702
-
703
- let(:instance) { GIMarshallingTests::OverridesObject.new }
704
-
705
- it "has a working method #method" do
706
- result = instance.method
707
- _(result).must_equal 42
708
- end
709
-
710
- it "does not have accessors for its parent instance" do
711
- _(instance).wont_respond_to :parent_instance
712
- _(instance).wont_respond_to :parent_instance=
713
- end
714
- end
715
-
716
- describe "GIMarshallingTests::OverridesStruct" do
717
- let(:instance) { GIMarshallingTests::OverridesStruct.new }
718
-
719
- it "has a writable field long_" do
720
- instance.long_ = 43
721
- _(instance.long_).must_equal 43
722
- end
723
-
724
- it "creates an instance using #new" do
725
- ob = GIMarshallingTests::OverridesStruct.new
726
- assert_instance_of GIMarshallingTests::OverridesStruct, ob
727
- end
728
-
729
- it "has a working method #method" do
730
- _(instance.method).must_equal 42
731
- end
732
-
733
- it "has a working function #returnv" do
734
- ob = GIMarshallingTests::OverridesStruct.returnv
735
- assert_instance_of GIMarshallingTests::OverridesStruct, ob
736
- end
737
- end
738
-
739
- describe "GIMarshallingTests::PointerStruct" do
740
- it "creates an instance using #new" do
741
- ps = GIMarshallingTests::PointerStruct.new
742
- assert_instance_of GIMarshallingTests::PointerStruct, ps
743
- end
744
-
745
- let(:instance) { GIMarshallingTests::PointerStruct.new }
746
-
747
- it "has a writable field long_" do
748
- assert_equal 0, instance.long_
749
- instance.long_ = 1056
750
- assert_equal 1056, instance.long_
751
- end
752
-
753
- it "has a working method #inv" do
754
- instance.long_ = 42
755
- instance.inv
756
- pass
757
- end
758
-
759
- it "has a working function #returnv" do
760
- ob = GIMarshallingTests::PointerStruct.returnv
761
- assert_instance_of GIMarshallingTests::PointerStruct, ob
762
- end
763
- end
764
-
765
- describe "GIMarshallingTests::PropertiesObject" do
766
- it "creates an instance using #new" do
767
- ob = GIMarshallingTests::PropertiesObject.new
768
- assert_instance_of GIMarshallingTests::PropertiesObject, ob
769
- end
770
-
771
- let(:instance) { GIMarshallingTests::PropertiesObject.new }
772
-
773
- describe "its 'some-boolean' property" do
774
- it "can be retrieved with #get_property" do
775
- _(instance.get_property("some-boolean")).must_equal false
776
- end
777
-
778
- it "can be retrieved with #some_boolean" do
779
- _(instance.some_boolean).must_equal false
780
- end
781
-
782
- it "can be set with #set_property" do
783
- instance.set_property("some-boolean", true)
784
- _(instance.get_property("some-boolean")).must_equal true
785
- end
786
-
787
- it "can be set with #some_boolean=" do
788
- instance.some_boolean = true
789
- _(instance.get_property("some-boolean")).must_equal true
790
- end
791
- end
792
-
793
- describe "its 'some-boxed-glist' property" do
794
- it "can be retrieved with #get_property" do
795
- _(instance.get_property("some-boxed-glist")).must_be_nil
796
- end
797
-
798
- it "can be retrieved with #some_boxed_glist" do
799
- _(instance.some_boxed_glist).must_be_nil
800
- end
801
-
802
- it "can be set with #set_property" do
803
- instance.set_property("some-boxed-glist", [1, 2, 3])
804
- _(instance.some_boxed_glist.to_a).must_equal [1, 2, 3]
805
- end
806
-
807
- it "can be set with #some_boxed_glist=" do
808
- instance.some_boxed_glist = [1, 2, 3]
809
- _(instance.some_boxed_glist.to_a).must_equal [1, 2, 3]
810
- _(instance.get_property("some-boxed-glist").to_a).must_equal [1, 2, 3]
811
- end
812
- end
813
-
814
- describe "its 'some-boxed-struct' property" do
815
- it "can be retrieved with #get_property" do
816
- _(instance.get_property("some-boxed-struct")).must_be_nil
817
- end
818
-
819
- it "can be retrieved with #some_boxed_struct" do
820
- _(instance.some_boxed_struct).must_be_nil
821
- end
822
-
823
- it "can be set with #set_property" do
824
- boxed = GIMarshallingTests::BoxedStruct.new
825
- boxed.long_ = 42
826
- instance.set_property("some-boxed-struct", boxed)
827
- _(instance.get_property("some-boxed-struct").long_).must_equal 42
828
- end
829
-
830
- it "can be set with #some_boxed_struct=" do
831
- boxed = GIMarshallingTests::BoxedStruct.new
832
- boxed.long_ = 43
833
- instance.some_boxed_struct = boxed
834
- _(instance.some_boxed_struct.long_).must_equal 43
835
- end
836
- end
837
-
838
- describe "its 'some-byte-array' property" do
839
- before { skip_below("1.57.2") }
840
-
841
- it "can be retrieved with #get_property" do
842
- _(instance.get_property("some-byte-array")).must_be_nil
843
- end
844
-
845
- it "can be retrieved with #some_byte_array" do
846
- _(instance.some_byte_array).must_be_nil
847
- end
848
-
849
- it "can be set with #set_property" do
850
- instance.set_property "some-byte-array", "some bytes"
851
- _(instance.get_property("some-byte-array").to_string).must_equal "some bytes"
852
- end
853
-
854
- it "can be set with #some_byte_array=" do
855
- instance.some_byte_array = "some bytes"
856
- _(instance.some_byte_array.to_string).must_equal "some bytes"
857
- end
858
- end
859
-
860
- describe "its 'some-char' property" do
861
- it "can be retrieved with #get_property" do
862
- _(instance.get_property("some-char")).must_equal 0
863
- end
864
-
865
- it "can be retrieved with #some_char" do
866
- _(instance.some_char).must_equal 0
867
- end
868
-
869
- it "can be set with #set_property" do
870
- instance.set_property "some-char", 42
871
- _(instance.get_property("some-char")).must_equal 42
872
- end
873
-
874
- it "can be set with #some_char=" do
875
- instance.some_char = 43
876
- _(instance.some_char).must_equal 43
877
- end
878
- end
879
-
880
- describe "its 'some-double' property" do
881
- it "can be retrieved with #get_property" do
882
- _(instance.get_property("some-double")).must_equal 0.0
883
- end
884
-
885
- it "can be retrieved with #some_double" do
886
- _(instance.some_double).must_equal 0.0
887
- end
888
-
889
- it "can be set with #set_property" do
890
- instance.set_property("some-double", 3.14)
891
- _(instance.get_property("some-double")).must_equal 3.14
892
- end
893
-
894
- it "can be set with #some_double=" do
895
- instance.some_double = 3.14
896
- _(instance.some_double).must_equal 3.14
897
- end
898
- end
899
-
900
- describe "its 'some-enum' property" do
901
- before { skip_below("1.52.1") }
902
-
903
- it "can be retrieved with #get_property" do
904
- _(instance.get_property("some-enum")).must_equal :value1
905
- end
906
-
907
- it "can be retrieved with #some_enum" do
908
- _(instance.some_enum).must_equal :value1
909
- end
910
-
911
- it "can be set with #set_property" do
912
- instance.set_property("some-enum", :value3)
913
- _(instance.get_property("some-enum")).must_equal :value3
914
- end
915
-
916
- it "can be set with #some_enum=" do
917
- instance.some_enum = :value3
918
- _(instance.some_enum).must_equal :value3
919
- _(instance.get_property("some-enum")).must_equal :value3
920
- end
921
- end
922
-
923
- describe "its 'some-flags' property" do
924
- before { skip_below("1.52.1") }
925
-
926
- it "can be retrieved with #get_property" do
927
- _(instance.get_property("some-flags")).must_equal value1: true
928
- end
929
-
930
- it "can be retrieved with #some_flags" do
931
- _(instance.some_flags).must_equal value1: true
932
- end
933
-
934
- it "can be set with #set_property" do
935
- instance.set_property("some-flags", value3: true)
936
- _(instance.get_property("some-flags")).must_equal value3: true
937
- end
938
-
939
- it "can be set with #some_flags=" do
940
- instance.some_flags = :value3
941
- _(instance.some_flags).must_equal(value3: true)
942
- _(instance.get_property("some-flags")).must_equal(value3: true)
943
- end
944
- end
945
-
946
- describe "its 'some-float' property" do
947
- it "can be retrieved with #get_property" do
948
- _(instance.get_property("some-float")).must_equal 0.0
949
- end
950
-
951
- it "can be retrieved with #some_float" do
952
- _(instance.some_float).must_equal 0.0
953
- end
954
-
955
- it "can be set with #set_property" do
956
- instance.set_property("some-float", 3.14)
957
- _(instance.get_property("some-float")).must_be_close_to 3.14
958
- end
959
-
960
- it "can be set with #some_float=" do
961
- instance.some_float = 3.14
962
- _(instance.some_float).must_be_close_to 3.14
963
- end
964
- end
965
-
966
- describe "its 'some-gvalue' property" do
967
- before { skip_below "1.52.1" }
968
-
969
- it "can be retrieved with #get_property" do
970
- _(instance.get_property("some-gvalue")).must_be_nil
971
- end
972
-
973
- it "can be retrieved with #some_gvalue" do
974
- _(instance.some_gvalue).must_be_nil
975
- end
976
-
977
- it "can be set with #set_property" do
978
- value = GObject::Value.from 42
979
- instance.set_property("some-gvalue", value)
980
- _(instance.get_property("some-gvalue").get_value).must_equal 42
981
- end
982
-
983
- it "can be set with #some_gvalue=" do
984
- value = GObject::Value.from 42
985
- instance.some_gvalue = value
986
- _(instance.some_gvalue.get_value).must_equal 42
987
- _(instance.get_property("some-gvalue").get_value).must_equal 42
988
- end
989
- end
990
-
991
- describe "its 'some-int' property" do
992
- it "can be retrieved with #get_property" do
993
- _(instance.get_property("some-int")).must_equal 0
994
- end
995
-
996
- it "can be retrieved with #some_int" do
997
- _(instance.some_int).must_equal 0
998
- end
999
-
1000
- it "can be set with #set_property" do
1001
- instance.set_property "some-int", 4242
1002
- _(instance.get_property("some-int")).must_equal 4242
1003
- end
1004
-
1005
- it "can be set with #some_int=" do
1006
- instance.some_int = 4243
1007
- _(instance.some_int).must_equal 4243
1008
- end
1009
- end
1010
-
1011
- describe "its 'some-int64' property" do
1012
- it "can be retrieved with #get_property" do
1013
- _(instance.get_property("some-int64")).must_equal 0
1014
- end
1015
-
1016
- it "can be retrieved with #some_int64" do
1017
- _(instance.some_int64).must_equal 0
1018
- end
1019
-
1020
- it "can be set with #set_property" do
1021
- instance.set_property "some-int64", 42_000_000_000_000
1022
- _(instance.get_property("some-int64")).must_equal 42_000_000_000_000
1023
- end
1024
-
1025
- it "can be set with #some_int64=" do
1026
- instance.some_int64 = 43_000_000_000_000
1027
- _(instance.some_int64).must_equal 43_000_000_000_000
1028
- end
1029
- end
1030
-
1031
- describe "its 'some-long' property" do
1032
- it "can be retrieved with #get_property" do
1033
- _(instance.get_property("some-long")).must_equal 0
1034
- end
1035
-
1036
- it "can be retrieved with #some_long" do
1037
- _(instance.some_long).must_equal 0
1038
- end
1039
-
1040
- it "can be set with #set_property" do
1041
- instance.set_property "some-long", 4242
1042
- _(instance.get_property("some-long")).must_equal 4242
1043
- end
1044
-
1045
- it "can be set with #some_long=" do
1046
- instance.some_long = 4243
1047
- _(instance.some_long).must_equal 4243
1048
- end
1049
- end
1050
-
1051
- describe "its 'some-object' property" do
1052
- it "can be retrieved with #get_property" do
1053
- _(instance.get_property("some-object")).must_be_nil
1054
- end
1055
-
1056
- it "can be retrieved with #some_object" do
1057
- _(instance.some_object).must_be_nil
1058
- end
1059
-
1060
- it "can be set with #set_property" do
1061
- ob = GIMarshallingTests::Object.new 42
1062
- instance.set_property "some-object", ob
1063
- _(instance.get_property("some-object")).must_equal ob
1064
- end
1065
-
1066
- it "can be set with #some_object=" do
1067
- ob = GIMarshallingTests::Object.new 42
1068
- instance.some_object = ob
1069
- _(instance.some_object).must_equal ob
1070
- end
1071
- end
1072
-
1073
- describe "its 'some-readonly' property" do
1074
- before { skip_below("1.57.2") }
1075
-
1076
- it "can be retrieved with #get_property" do
1077
- _(instance.get_property("some-readonly")).must_equal 42
1078
- end
1079
-
1080
- it "can be retrieved with #some_readonly" do
1081
- _(instance.some_readonly).must_equal 42
1082
- end
1083
- end
1084
-
1085
- describe "its 'some-strv' property" do
1086
- it "can be retrieved with #get_property" do
1087
- _(instance.get_property("some-strv")).must_be :==, []
1088
- end
1089
-
1090
- it "can be retrieved with #some_strv" do
1091
- _(instance.some_strv).must_be :==, []
1092
- end
1093
-
1094
- it "can be set with #set_property" do
1095
- instance.set_property("some-strv", %w(foo bar))
1096
- _(instance.get_property("some-strv")).must_be :==, %w(foo bar)
1097
- end
1098
-
1099
- it "can be set with #some_strv=" do
1100
- instance.some_strv = %w(foo bar)
1101
- _(instance.some_strv).must_be :==, %w(foo bar)
1102
- end
1103
- end
1104
-
1105
- describe "its 'some-uchar' property" do
1106
- it "can be retrieved with #get_property" do
1107
- _(instance.get_property("some-uchar")).must_equal 0
1108
- end
1109
-
1110
- it "can be retrieved with #some_uchar" do
1111
- _(instance.some_uchar).must_equal 0
1112
- end
1113
-
1114
- it "can be set with #set_property" do
1115
- instance.set_property "some-uchar", 42
1116
- _(instance.get_property("some-uchar")).must_equal 42
1117
- end
1118
-
1119
- it "can be set with #some_uchar=" do
1120
- instance.some_uchar = 43
1121
- _(instance.some_uchar).must_equal 43
1122
- end
1123
- end
1124
-
1125
- describe "its 'some-uint' property" do
1126
- it "can be retrieved with #get_property" do
1127
- _(instance.get_property("some-uint")).must_equal 0
1128
- end
1129
-
1130
- it "can be retrieved with #some_uint" do
1131
- _(instance.some_uint).must_equal 0
1132
- end
1133
-
1134
- it "can be set with #set_property" do
1135
- instance.set_property "some-uint", 4242
1136
- _(instance.get_property("some-uint")).must_equal 4242
1137
- end
1138
-
1139
- it "can be set with #some_uint=" do
1140
- instance.some_uint = 4243
1141
- _(instance.some_uint).must_equal 4243
1142
- end
1143
- end
1144
-
1145
- describe "its 'some-uint64' property" do
1146
- it "can be retrieved with #get_property" do
1147
- _(instance.get_property("some-uint64")).must_equal 0
1148
- end
1149
-
1150
- it "can be retrieved with #some_uint64" do
1151
- _(instance.some_uint64).must_equal 0
1152
- end
1153
-
1154
- it "can be set with #set_property" do
1155
- instance.set_property "some-uint64", 42_000_000_000_000
1156
- _(instance.get_property("some-uint64")).must_equal 42_000_000_000_000
1157
- end
1158
-
1159
- it "can be set with #some_uint64=" do
1160
- instance.some_uint64 = 43_000_000_000_000
1161
- _(instance.some_uint64).must_equal 43_000_000_000_000
1162
- end
1163
- end
1164
-
1165
- describe "its 'some-ulong' property" do
1166
- it "can be retrieved with #get_property" do
1167
- _(instance.get_property("some-ulong")).must_equal 0
1168
- end
1169
-
1170
- it "can be retrieved with #some_ulong" do
1171
- _(instance.some_ulong).must_equal 0
1172
- end
1173
-
1174
- it "can be set with #set_property" do
1175
- instance.set_property "some-ulong", 4242
1176
- _(instance.get_property("some-ulong")).must_equal 4242
1177
- end
1178
-
1179
- it "can be set with #some_ulong=" do
1180
- instance.some_ulong = 4243
1181
- _(instance.some_ulong).must_equal 4243
1182
- end
1183
- end
1184
-
1185
- describe "its 'some-variant' property" do
1186
- it "can be retrieved with #get_property" do
1187
- _(instance.get_property("some-variant")).must_be_nil
1188
- end
1189
-
1190
- it "can be retrieved with #some_variant" do
1191
- _(instance.some_variant).must_be_nil
1192
- end
1193
-
1194
- it "can be set with #set_property" do
1195
- value = GLib::Variant.new_string("Foo")
1196
- instance.set_property "some-variant", value
1197
- _(instance.get_property("some-variant")).must_equal value
1198
- end
1199
-
1200
- it "can be set with #some_variant=" do
1201
- value = GLib::Variant.new_string("Foo")
1202
- instance.some_variant = value
1203
- _(instance.some_variant).must_equal value
1204
- end
1205
- end
1206
- end
1207
-
1208
- describe "GIMarshallingTests::SecondEnum" do
1209
- it "has the member :secondvalue1" do
1210
- assert_equal 0, GIMarshallingTests::SecondEnum[:secondvalue1]
1211
- end
1212
- it "has the member :secondvalue2" do
1213
- assert_equal 1, GIMarshallingTests::SecondEnum[:secondvalue2]
1214
- end
1215
- end
1216
-
1217
- describe "GIMarshallingTests::SimpleStruct" do
1218
- it "creates an instance using #new" do
1219
- ss = GIMarshallingTests::SimpleStruct.new
1220
- assert_instance_of GIMarshallingTests::SimpleStruct, ss
1221
- end
1222
-
1223
- let(:instance) { GIMarshallingTests::SimpleStruct.new }
1224
-
1225
- it "has a writable field long_" do
1226
- _(instance.long_).must_equal 0
1227
- instance.long_ = 1056
1228
- _(instance.long_).must_equal 1056
1229
- end
1230
-
1231
- it "has a writable field int8" do
1232
- _(instance.int8).must_equal 0
1233
- instance.int8 = -43
1234
- _(instance.int8).must_equal(-43)
1235
- end
1236
-
1237
- it "has a working method #inv" do
1238
- instance.long_ = 6
1239
- instance.int8 = 7
1240
- instance.inv
1241
- pass
1242
- end
1243
-
1244
- it "has a working method #method" do
1245
- instance.long_ = 6
1246
- instance.int8 = 7
1247
- instance.method
1248
- pass
1249
- end
1250
-
1251
- it "has a working function #returnv" do
1252
- ss = GIMarshallingTests::SimpleStruct.returnv
1253
- assert_instance_of GIMarshallingTests::SimpleStruct, ss
1254
- end
1255
- end
1256
-
1257
- describe "GIMarshallingTests::SubObject" do
1258
- it "creates an instance using #new" do
1259
- so = GIMarshallingTests::SubObject.new
1260
- _(so).must_be_instance_of GIMarshallingTests::SubObject
1261
- _(GObject.type_name_from_instance(so))
1262
- .must_equal "GIMarshallingTestsSubObject"
1263
- end
1264
-
1265
- let(:instance) { GIMarshallingTests::SubObject.new }
1266
-
1267
- it "has a working method #overwritten_method" do
1268
- instance.overwritten_method
1269
- pass
1270
- end
1271
-
1272
- it "has a working method #sub_method" do
1273
- instance.sub_method
1274
- pass
1275
- end
1276
-
1277
- it "does not have accessors for its parent instance" do
1278
- _(instance).wont_respond_to :parent_instance
1279
- _(instance).wont_respond_to :parent_instance=
1280
- end
1281
- end
1282
-
1283
- describe "GIMarshallingTests::SubSubObject" do
1284
- it "creates an instance using #new" do
1285
- so = GIMarshallingTests::SubSubObject.new
1286
- assert_instance_of GIMarshallingTests::SubSubObject, so
1287
- _(GObject.type_name_from_instance(so))
1288
- .must_equal "GIMarshallingTestsSubSubObject"
1289
- end
1290
-
1291
- let(:instance) { GIMarshallingTests::SubSubObject.new }
1292
-
1293
- it "does not have accessors for its parent instance" do
1294
- _(instance).wont_respond_to :parent_instance
1295
- _(instance).wont_respond_to :parent_instance=
1296
- end
1297
- end
1298
-
1299
- describe "GIMarshallingTests::Union" do
1300
- it "creates an instance with #new" do
1301
- u = GIMarshallingTests::Union.new
1302
- assert_instance_of GIMarshallingTests::Union, u
1303
- end
1304
-
1305
- let(:instance) { GIMarshallingTests::Union.new }
1306
-
1307
- it "has a writable field long_" do
1308
- assert_equal 0, instance.long_
1309
- instance.long_ = 1056
1310
- assert_equal 1056, instance.long_
1311
- end
1312
-
1313
- it "has a working method #inv" do
1314
- instance.long_ = 42
1315
- instance.inv
1316
- pass
1317
- end
1318
-
1319
- it "has a working method #method" do
1320
- instance.long_ = 42
1321
- instance.method
1322
- pass
1323
- end
1324
-
1325
- it "has a working function #inout" do
1326
- skip "This function is defined in the header but not implemented"
1327
- end
1328
-
1329
- it "has a working function #out" do
1330
- skip "This function is defined in the header but not implemented"
1331
- end
1332
-
1333
- it "has a working function #returnv" do
1334
- u = GIMarshallingTests::Union.returnv
1335
- assert_instance_of GIMarshallingTests::Union, u
1336
- end
1337
- end
1338
-
1339
- it "has a working function #array_bool_in" do
1340
- skip_below "1.51.1"
1341
- GIMarshallingTests.array_bool_in [true, false, true, true]
1342
- end
1343
-
1344
- it "has a working function #array_bool_out" do
1345
- skip_below "1.51.1"
1346
- result = GIMarshallingTests.array_bool_out
1347
- _(result.to_a).must_equal [true, false, true, true]
1348
- end
1349
-
1350
- it "has a working function #array_enum_in" do
1351
- GIMarshallingTests.array_enum_in [:value1, :value2, :value3]
1352
- end
1353
-
1354
- it "has a working function #array_fixed_inout" do
1355
- res = GIMarshallingTests.array_fixed_inout [-1, 0, 1, 2]
1356
- _(res).must_be :==, [2, 1, 0, -1]
1357
- end
1358
-
1359
- it "has a working function #array_fixed_int_in" do
1360
- GIMarshallingTests.array_fixed_int_in [-1, 0, 1, 2]
1361
- pass
1362
- end
1363
-
1364
- it "has a working function #array_fixed_int_return" do
1365
- res = GIMarshallingTests.array_fixed_int_return
1366
- _(res).must_be :==, [-1, 0, 1, 2]
1367
- end
1368
-
1369
- it "has a working function #array_fixed_out" do
1370
- res = GIMarshallingTests.array_fixed_out
1371
- _(res).must_be :==, [-1, 0, 1, 2]
1372
- end
1373
-
1374
- it "has a working function #array_fixed_out_struct" do
1375
- res = GIMarshallingTests.array_fixed_out_struct
1376
- assert_equal [[7, 6], [6, 7]], res.map { |s| [s.long_, s.int8] }
1377
- end
1378
-
1379
- it "has a working function #array_fixed_short_in" do
1380
- GIMarshallingTests.array_fixed_short_in [-1, 0, 1, 2]
1381
- pass
1382
- end
1383
-
1384
- it "has a working function #array_fixed_short_return" do
1385
- res = GIMarshallingTests.array_fixed_short_return
1386
- _(res).must_be :==, [-1, 0, 1, 2]
1387
- end
1388
-
1389
- it "has a working function #array_gvariant_container_in" do
1390
- v1 = GLib::Variant.new_int32(27)
1391
- v2 = GLib::Variant.new_string("Hello")
1392
- result = GIMarshallingTests.array_gvariant_container_in [v1, v2]
1393
- arr = result.to_a
1394
- _(arr.size).must_equal 2
1395
- _(arr[0].get_int32).must_equal 27
1396
- _(arr[1].get_string).must_equal "Hello"
1397
- end
1398
-
1399
- it "has a working function #array_gvariant_full_in" do
1400
- v1 = GLib::Variant.new_int32(27)
1401
- v2 = GLib::Variant.new_string("Hello")
1402
- result = GIMarshallingTests.array_gvariant_full_in [v1, v2]
1403
- arr = result.to_a
1404
- _(arr.size).must_equal 2
1405
- _(arr[0].get_int32).must_equal 27
1406
- _(arr[1].get_string).must_equal "Hello"
1407
- end
1408
-
1409
- it "has a working function #array_gvariant_none_in" do
1410
- v1 = GLib::Variant.new_int32(27)
1411
- v2 = GLib::Variant.new_string("Hello")
1412
- result = GIMarshallingTests.array_gvariant_none_in [v1, v2]
1413
- arr = result.to_a
1414
- _(arr.size).must_equal 2
1415
- _(arr[0].get_int32).must_equal 27
1416
- _(arr[1].get_string).must_equal "Hello"
1417
- end
1418
-
1419
- it "has a working function #array_in" do
1420
- GIMarshallingTests.array_in [-1, 0, 1, 2]
1421
- pass
1422
- end
1423
-
1424
- it "has a working function #array_in_guint64_len" do
1425
- GIMarshallingTests.array_in_guint64_len [-1, 0, 1, 2]
1426
- pass
1427
- end
1428
-
1429
- it "has a working function #array_in_guint8_len" do
1430
- GIMarshallingTests.array_in_guint8_len [-1, 0, 1, 2]
1431
- pass
1432
- end
1433
-
1434
- it "has a working function #array_in_len_before" do
1435
- GIMarshallingTests.array_in_len_before [-1, 0, 1, 2]
1436
- pass
1437
- end
1438
-
1439
- it "has a working function #array_in_len_zero_terminated" do
1440
- GIMarshallingTests.array_in_len_zero_terminated [-1, 0, 1, 2]
1441
- pass
1442
- end
1443
-
1444
- it "has a working function #array_in_nonzero_nonlen" do
1445
- GIMarshallingTests.array_in_nonzero_nonlen 1, "abcd".bytes.to_a
1446
- pass
1447
- end
1448
-
1449
- it "has a working function #array_in_utf8_two_in" do
1450
- GIMarshallingTests.array_in_utf8_two_in [-1, 0, 1, 2], "1", "2"
1451
- pass
1452
- end
1453
-
1454
- it "has a working function #array_in_utf8_two_in_out_of_order" do
1455
- GIMarshallingTests.array_in_utf8_two_in_out_of_order "1", [-1, 0, 1, 2], "2"
1456
- pass
1457
- end
1458
-
1459
- it "has a working function #array_inout" do
1460
- res = GIMarshallingTests.array_inout [-1, 0, 1, 2]
1461
- _(res).must_be :==, [-2, -1, 0, 1, 2]
1462
- end
1463
-
1464
- it "has a working function #array_inout_etc" do
1465
- arr, sum = GIMarshallingTests.array_inout_etc 42, [-1, 0, 1, 2], 24
1466
- _(arr).must_be :==, [42, -1, 0, 1, 24]
1467
- _(sum).must_equal 42 + 24
1468
- end
1469
-
1470
- it "has a working function #array_int64_in" do
1471
- skip_below "1.51.1"
1472
- GIMarshallingTests.array_int64_in [-1, 0, 1, 2]
1473
- end
1474
-
1475
- it "has a working function #array_out" do
1476
- res = GIMarshallingTests.array_out
1477
- _(res).must_be :==, [-1, 0, 1, 2]
1478
- end
1479
-
1480
- it "has a working function #array_out_etc" do
1481
- arr, sum = GIMarshallingTests.array_out_etc 42, 24
1482
- _(arr).must_be :==, [42, 0, 1, 24]
1483
- _(sum).must_equal 42 + 24
1484
- end
1485
-
1486
- it "has a working function #array_return" do
1487
- res = GIMarshallingTests.array_return
1488
- _(res).must_be :==, [-1, 0, 1, 2]
1489
- end
1490
-
1491
- it "has a working function #array_return_etc" do
1492
- arr, sum = GIMarshallingTests.array_return_etc 42, 24
1493
- _(arr).must_be :==, [42, 0, 1, 24]
1494
- _(sum).must_equal 42 + 24
1495
- end
1496
-
1497
- it "has a working function #array_simple_struct_in" do
1498
- arr = [1, 2, 3].map do |val|
1499
- GIMarshallingTests::SimpleStruct.new.tap { |struct| struct.long_ = val }
1500
- end
1501
- GIMarshallingTests.array_simple_struct_in arr
1502
- end
1503
-
1504
- it "has a working function #array_string_in" do
1505
- GIMarshallingTests.array_string_in %w(foo bar)
1506
- pass
1507
- end
1508
-
1509
- it "has a working function #array_struct_in" do
1510
- arr = [1, 2, 3].map do |val|
1511
- GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
1512
- end
1513
- GIMarshallingTests.array_struct_in arr
1514
- end
1515
-
1516
- it "has a working function #array_struct_take_in" do
1517
- arr = [1, 2, 3].map do |val|
1518
- GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
1519
- end
1520
- # NOTE: This copies values so arr's elements stay valid
1521
- GIMarshallingTests.array_struct_take_in arr
1522
-
1523
- _(arr.map(&:long_)).must_equal [1, 2, 3]
1524
- end
1525
-
1526
- it "has a working function #array_struct_value_in" do
1527
- arr = [1, 2, 3].map do |val|
1528
- GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
1529
- end
1530
- GIMarshallingTests.array_struct_value_in arr
1531
- end
1532
-
1533
- it "has a working function #array_uint64_in" do
1534
- skip_below "1.51.1"
1535
- GIMarshallingTests.array_uint64_in [-1, 0, 1, 2]
1536
- end
1537
-
1538
- it "has a working function #array_uint8_in" do
1539
- arr = "abcd".bytes.to_a
1540
- GIMarshallingTests.array_uint8_in arr
1541
- pass
1542
- end
1543
-
1544
- it "has a working function #array_unichar_in" do
1545
- skip_below "1.51.1"
1546
- arr = [0x63, 0x6f, 0x6e, 0x73, 0x74,
1547
- 0x20, 0x2665, 0x20, 0x75, 0x74,
1548
- 0x66, 0x38]
1549
- GIMarshallingTests.array_unichar_in arr
1550
- end
1551
-
1552
- it "has a working function #array_unichar_out" do
1553
- skip_below "1.51.1"
1554
- result = GIMarshallingTests.array_unichar_out
1555
- _(result.to_a).must_equal [0x63, 0x6f, 0x6e, 0x73, 0x74,
1556
- 0x20, 0x2665, 0x20, 0x75, 0x74,
1557
- 0x66, 0x38]
1558
- end
1559
-
1560
- it "has a working function #array_zero_terminated_in" do
1561
- GIMarshallingTests.array_zero_terminated_in %w(0 1 2)
1562
- pass
1563
- end
1564
-
1565
- it "has a working function #array_zero_terminated_inout" do
1566
- res = GIMarshallingTests.array_zero_terminated_inout %w(0 1 2)
1567
- _(res).must_be :==, ["-1", "0", "1", "2"]
1568
- end
1569
-
1570
- it "has a working function #array_zero_terminated_out" do
1571
- res = GIMarshallingTests.array_zero_terminated_out
1572
- _(res).must_be :==, %w(0 1 2)
1573
- end
1574
-
1575
- it "has a working function #array_zero_terminated_return" do
1576
- res = GIMarshallingTests.array_zero_terminated_return
1577
- _(res).must_be :==, %w(0 1 2)
1578
- end
1579
-
1580
- it "has a working function #array_zero_terminated_return_null" do
1581
- res = GIMarshallingTests.array_zero_terminated_return_null
1582
- _(res).must_be :==, []
1583
- end
1584
-
1585
- it "has a working function #array_zero_terminated_return_struct" do
1586
- res = GIMarshallingTests.array_zero_terminated_return_struct
1587
- _(res.to_a.map(&:long_)).must_equal [42, 43, 44]
1588
- end
1589
-
1590
- it "has a working function #array_zero_terminated_return_unichar" do
1591
- skip_below "1.51.1"
1592
- res = GIMarshallingTests.array_zero_terminated_return_unichar
1593
- _(res.to_a).must_equal [0x63, 0x6f, 0x6e, 0x73, 0x74,
1594
- 0x20, 0x2665, 0x20, 0x75, 0x74,
1595
- 0x66, 0x38]
1596
- end
1597
-
1598
- it "has a working function #boolean_in_false" do
1599
- GIMarshallingTests.boolean_in_false false
1600
- pass
1601
- end
1602
-
1603
- it "has a working function #boolean_in_true" do
1604
- GIMarshallingTests.boolean_in_true true
1605
- pass
1606
- end
1607
-
1608
- it "has a working function #boolean_inout_false_true" do
1609
- res = GIMarshallingTests.boolean_inout_false_true false
1610
- _(res).must_equal true
1611
- end
1612
-
1613
- it "has a working function #boolean_inout_true_false" do
1614
- res = GIMarshallingTests.boolean_inout_true_false true
1615
- _(res).must_equal false
1616
- end
1617
-
1618
- it "has a working function #boolean_out_false" do
1619
- res = GIMarshallingTests.boolean_out_false
1620
- _(res).must_equal false
1621
- end
1622
-
1623
- it "has a working function #boolean_out_true" do
1624
- res = GIMarshallingTests.boolean_out_true
1625
- _(res).must_equal true
1626
- end
1627
-
1628
- it "has a working function #boolean_return_false" do
1629
- res = GIMarshallingTests.boolean_return_false
1630
- _(res).must_equal false
1631
- end
1632
-
1633
- it "has a working function #boolean_return_true" do
1634
- res = GIMarshallingTests.boolean_return_true
1635
- _(res).must_equal true
1636
- end
1637
-
1638
- it "has a working function #boxed_struct_inout" do
1639
- bx = GIMarshallingTests::BoxedStruct.new
1640
- bx.long_ = 42
1641
- res = GIMarshallingTests.boxed_struct_inout bx
1642
- _(res.long_).must_equal 0
1643
- end
1644
-
1645
- it "has a working function #boxed_struct_out" do
1646
- res = GIMarshallingTests.boxed_struct_out
1647
- _(res.long_).must_equal 42
1648
- end
1649
-
1650
- it "has a working function #boxed_struct_returnv" do
1651
- res = GIMarshallingTests.boxed_struct_returnv
1652
- _(res.long_).must_equal 42
1653
- _(res.g_strv).must_be :==, %w(0 1 2)
1654
- end
1655
-
1656
- it "has a working function #bytearray_full_return" do
1657
- ret = GIMarshallingTests.bytearray_full_return
1658
- assert_instance_of GLib::ByteArray, ret
1659
- assert_includes(
1660
- ["0123".bytes.to_a, "\x001\xFF3".bytes.to_a],
1661
- ret.to_string.bytes.to_a)
1662
- end
1663
-
1664
- it "has a working function #bytearray_none_in" do
1665
- val = GIMarshallingTests.bytearray_full_return.to_string
1666
- ba = GLib::ByteArray.new
1667
- ba = ba.append val
1668
- GIMarshallingTests.bytearray_none_in ba
1669
- pass
1670
- end
1671
-
1672
- it "has a working function #callback_multiple_out_parameters" do
1673
- result = GIMarshallingTests.callback_multiple_out_parameters do |*_args|
1674
- [12.0, 13.0]
1675
- end
1676
- _(result).must_equal [12.0, 13.0]
1677
- end
1678
-
1679
- it "has a working function #callback_one_out_parameter" do
1680
- result = GIMarshallingTests.callback_one_out_parameter { 42.0 }
1681
- _(result).must_equal 42.0
1682
- end
1683
-
1684
- it "has a working function #callback_owned_boxed" do
1685
- a = nil
1686
-
1687
- callback = proc { |box, _callback_data| a = box.long_ * 2 }
1688
-
1689
- result = GIMarshallingTests.callback_owned_boxed(&callback)
1690
- _(result).must_equal 1
1691
- _(a).must_equal 2
1692
-
1693
- result = GIMarshallingTests.callback_owned_boxed(&callback)
1694
- _(result).must_equal 2
1695
- _(a).must_equal 4
1696
- end
1697
-
1698
- it "has a working function #callback_return_value_and_multiple_out_parameters" do
1699
- result = GIMarshallingTests.callback_return_value_and_multiple_out_parameters do |*_args|
1700
- [42, -142, 3]
1701
- end
1702
- _(result).must_equal [42, -142, 3]
1703
- end
1704
-
1705
- it "has a working function #callback_return_value_and_one_out_parameter" do
1706
- result = GIMarshallingTests.callback_return_value_and_one_out_parameter do |*_args|
1707
- [42, -142]
1708
- end
1709
- _(result).must_equal [42, -142]
1710
- end
1711
-
1712
- it "has a working function #callback_return_value_only" do
1713
- result = GIMarshallingTests.callback_return_value_only { 42 }
1714
- _(result).must_equal 42
1715
- end
1716
-
1717
- it "has a working function #double_in" do
1718
- GIMarshallingTests.double_in Float::MAX
1719
- pass
1720
- end
1721
-
1722
- it "has a working function #double_inout" do
1723
- ret = GIMarshallingTests.double_inout Float::MAX
1724
- assert_in_epsilon 2.225e-308, ret
1725
- end
1726
-
1727
- it "has a working function #double_out" do
1728
- ret = GIMarshallingTests.double_out
1729
- _(ret).must_equal Float::MAX
1730
- end
1731
-
1732
- it "has a working function #double_return" do
1733
- ret = GIMarshallingTests.double_return
1734
- _(ret).must_equal Float::MAX
1735
- end
1736
-
1737
- it "has a working function #enum_in" do
1738
- GIMarshallingTests.enum_in :value3
1739
- pass
1740
- end
1741
-
1742
- it "has a working function #enum_inout" do
1743
- e = GIMarshallingTests.enum_inout :value3
1744
- _(e).must_equal :value1
1745
- end
1746
-
1747
- it "has a working function #enum_out" do
1748
- e = GIMarshallingTests.enum_out
1749
- _(e).must_equal :value3
1750
- end
1751
-
1752
- it "has a working function #enum_returnv" do
1753
- e = GIMarshallingTests.enum_returnv
1754
- _(e).must_equal :value3
1755
- end
1756
-
1757
- it "has a working function #filename_list_return" do
1758
- fl = GIMarshallingTests.filename_list_return
1759
- _(fl).must_be_nil
1760
- end
1761
-
1762
- it "has a working function #flags_in" do
1763
- GIMarshallingTests.flags_in value2: true
1764
- pass
1765
- end
1766
-
1767
- it "has a working function #flags_in_zero" do
1768
- GIMarshallingTests.flags_in_zero 0
1769
- pass
1770
- end
1771
-
1772
- it "has a working function #flags_inout" do
1773
- res = GIMarshallingTests.flags_inout value2: true
1774
- _(res).must_equal(value1: true)
1775
- end
1776
-
1777
- it "has a working function #flags_out" do
1778
- res = GIMarshallingTests.flags_out
1779
- _(res).must_equal(value2: true)
1780
- end
1781
-
1782
- it "has a working function #flags_returnv" do
1783
- res = GIMarshallingTests.flags_returnv
1784
- _(res).must_equal(value2: true)
1785
- end
1786
-
1787
- it "has a working function #float_in" do
1788
- # float_return returns MAX_FLT
1789
- flt = GIMarshallingTests.float_return
1790
- GIMarshallingTests.float_in flt
1791
- pass
1792
- end
1793
-
1794
- it "has a working function #float_inout" do
1795
- # float_return returns MAX_FLT
1796
- flt = GIMarshallingTests.float_return
1797
- res = GIMarshallingTests.float_inout flt
1798
- assert_in_epsilon 1.175e-38, res
1799
- end
1800
-
1801
- it "has a working function #float_out" do
1802
- flt = GIMarshallingTests.float_out
1803
- assert_in_epsilon 3.402e+38, flt
1804
- end
1805
-
1806
- it "has a working function #float_return" do
1807
- flt = GIMarshallingTests.float_return
1808
- assert_in_epsilon 3.402e+38, flt
1809
- end
1810
-
1811
- it "has a working function #garray_bool_none_in" do
1812
- skip_below "1.51.1"
1813
- GIMarshallingTests.garray_bool_none_in [true, false, true, true]
1814
- end
1815
-
1816
- it "has a working function #garray_boxed_struct_full_return" do
1817
- skip_below "1.61.1"
1818
- result = GIMarshallingTests.garray_boxed_struct_full_return
1819
- _(result.map(&:long_)).must_equal [42, 43, 44]
1820
- end
1821
-
1822
- it "has a working function #garray_int_none_in" do
1823
- arr = [-1, 0, 1, 2]
1824
- GIMarshallingTests.garray_int_none_in arr
1825
- pass
1826
- end
1827
-
1828
- it "has a working function #garray_int_none_return" do
1829
- arr = GIMarshallingTests.garray_int_none_return
1830
- _(arr).must_be :==, [-1, 0, 1, 2]
1831
- end
1832
-
1833
- it "has a working function #garray_uint64_none_in" do
1834
- GIMarshallingTests.garray_uint64_none_in [0, 0xffff_ffff_ffff_ffff]
1835
- pass
1836
- end
1837
-
1838
- it "has a working function #garray_uint64_none_return" do
1839
- res = GIMarshallingTests.garray_uint64_none_return
1840
- _(res).must_be :==, [0, 0xffff_ffff_ffff_ffff]
1841
- end
1842
-
1843
- it "has a working function #garray_unichar_none_in" do
1844
- skip_below "1.51.1"
1845
- arr = [0x63, 0x6f, 0x6e, 0x73, 0x74,
1846
- 0x20, 0x2665, 0x20, 0x75, 0x74,
1847
- 0x66, 0x38]
1848
- GIMarshallingTests.garray_unichar_none_in arr
1849
- end
1850
-
1851
- it "has a working function #garray_utf8_container_inout" do
1852
- res = GIMarshallingTests.garray_utf8_container_inout %w(0 1 2)
1853
- _(res).must_be :==, ["-2", "-1", "0", "1"]
1854
- end
1855
-
1856
- it "has a working function #garray_utf8_container_out" do
1857
- res = GIMarshallingTests.garray_utf8_container_out
1858
- _(res).must_be :==, %w(0 1 2)
1859
- end
1860
-
1861
- it "has a working function #garray_utf8_container_return" do
1862
- res = GIMarshallingTests.garray_utf8_container_return
1863
- _(res).must_be :==, %w(0 1 2)
1864
- end
1865
-
1866
- it "has a working function #garray_utf8_full_inout" do
1867
- arr = %w(0 1 2)
1868
- res = GIMarshallingTests.garray_utf8_full_inout arr
1869
- _(res).must_be :==, ["-2", "-1", "0", "1"]
1870
- end
1871
-
1872
- it "has a working function #garray_utf8_full_out" do
1873
- res = GIMarshallingTests.garray_utf8_full_out
1874
- _(res).must_be :==, %w(0 1 2)
1875
- end
1876
-
1877
- it "has a working function #garray_utf8_full_out_caller_allocated" do
1878
- res = GIMarshallingTests.garray_utf8_full_out_caller_allocated
1879
- _(res).must_be :==, %w(0 1 2)
1880
- end
1881
-
1882
- it "has a working function #garray_utf8_full_return" do
1883
- res = GIMarshallingTests.garray_utf8_full_return
1884
- _(res).must_be :==, %w(0 1 2)
1885
- end
1886
-
1887
- it "has a working function #garray_utf8_none_in" do
1888
- arr = %w(0 1 2)
1889
- GIMarshallingTests.garray_utf8_none_in arr
1890
- pass
1891
- end
1892
-
1893
- it "has a working function #garray_utf8_none_inout" do
1894
- arr = %w(0 1 2)
1895
- res = GIMarshallingTests.garray_utf8_none_inout arr
1896
- _(res).must_be :==, ["-2", "-1", "0", "1"]
1897
- end
1898
-
1899
- it "has a working function #garray_utf8_none_out" do
1900
- res = GIMarshallingTests.garray_utf8_none_out
1901
- _(res).must_be :==, %w(0 1 2)
1902
- end
1903
-
1904
- it "has a working function #garray_utf8_none_return" do
1905
- res = GIMarshallingTests.garray_utf8_none_return
1906
- _(res).must_be :==, %w(0 1 2)
1907
- end
1908
-
1909
- it "has a working function #gbytes_full_return" do
1910
- res = GIMarshallingTests.gbytes_full_return
1911
- _(res.to_a).must_equal [0, 49, 0xFF, 51]
1912
- end
1913
-
1914
- it "has a working function #gbytes_none_in" do
1915
- GIMarshallingTests.gbytes_none_in [0, 49, 0xFF, 51]
1916
- pass
1917
- end
1918
-
1919
- it "has a working function #gclosure_in" do
1920
- cl = GObject::RubyClosure.new { 42 }
1921
- GIMarshallingTests.gclosure_in cl
1922
- pass
1923
- end
1924
-
1925
- it "has a working function #gclosure_return" do
1926
- cl = GIMarshallingTests.gclosure_return
1927
- gv = GObject::Value.wrap_ruby_value 0
1928
- result = cl.invoke gv, []
1929
- _(gv.get_value).must_equal 42
1930
- _(result).must_equal 42
1931
- end
1932
-
1933
- it "has a working function #genum_in" do
1934
- GIMarshallingTests.genum_in :value3
1935
- pass
1936
- end
1937
-
1938
- it "has a working function #genum_inout" do
1939
- res = GIMarshallingTests.genum_inout :value3
1940
- _(res).must_equal :value1
1941
- end
1942
-
1943
- it "has a working function #genum_out" do
1944
- res = GIMarshallingTests.genum_out
1945
- _(res).must_equal :value3
1946
- end
1947
-
1948
- it "has a working function #genum_returnv" do
1949
- res = GIMarshallingTests.genum_returnv
1950
- _(res).must_equal :value3
1951
- end
1952
-
1953
- it "has a working function #gerror" do
1954
- begin
1955
- GIMarshallingTests.gerror
1956
- flunk "Error should have been raised"
1957
- rescue GirFFI::GLibError => e
1958
- _(e.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1959
- _(e.domain).must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN
1960
- _(e.code).must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
1961
- end
1962
- end
1963
-
1964
- it "has a working function #gerror_array_in" do
1965
- begin
1966
- GIMarshallingTests.gerror_array_in [1, 2, 3]
1967
- flunk "Error should have been raised"
1968
- rescue GirFFI::GLibError => e
1969
- _(e.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1970
- _(e.domain).must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN
1971
- _(e.code).must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
1972
- end
1973
- end
1974
-
1975
- it "has a working function #gerror_out" do
1976
- error, debug = GIMarshallingTests.gerror_out
1977
- _(debug).must_equal GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE
1978
- _(error.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1979
- end
1980
-
1981
- it "has a working function #gerror_out_transfer_none" do
1982
- error, debug = GIMarshallingTests.gerror_out_transfer_none
1983
- _(debug).must_equal GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE
1984
- _(error.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1985
- end
1986
-
1987
- it "has a working function #gerror_return" do
1988
- error = GIMarshallingTests.gerror_return
1989
- _(error.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1990
- end
1991
-
1992
- it "has a working function #ghashtable_double_in" do
1993
- skip_below "1.51.2"
1994
- GIMarshallingTests.ghashtable_double_in(
1995
- "-1" => -0.1, "0" => 0.0, "1" => 0.1, "2" => 0.2)
1996
- end
1997
-
1998
- it "has a working function #ghashtable_float_in" do
1999
- skip_below "1.51.2"
2000
- GIMarshallingTests.ghashtable_float_in(
2001
- "-1" => -0.1, "0" => 0.0, "1" => 0.1, "2" => 0.2)
2002
- end
2003
-
2004
- it "has a working function #ghashtable_int64_in" do
2005
- skip_below "1.51.2"
2006
- GIMarshallingTests.ghashtable_int64_in(
2007
- "-1" => -1, "0" => 0, "1" => 1, "2" => 0x100000000)
2008
- end
2009
-
2010
- it "has a working function #ghashtable_int_none_in" do
2011
- GIMarshallingTests.ghashtable_int_none_in(
2012
- -1 => 1, 0 => 0, 1 => -1, 2 => -2)
2013
- end
2014
-
2015
- it "has a working function #ghashtable_int_none_return" do
2016
- gh = GIMarshallingTests.ghashtable_int_none_return
2017
- assert_equal({ -1 => 1, 0 => 0, 1 => -1, 2 => -2 }, gh.to_hash)
2018
- end
2019
-
2020
- it "has a working function #ghashtable_uint64_in" do
2021
- skip_below "1.51.2"
2022
- GIMarshallingTests.ghashtable_uint64_in(
2023
- "-1" => 0x100000000, "0" => 0, "1" => 1, "2" => 2)
2024
- end
2025
-
2026
- it "has a working function #ghashtable_utf8_container_in" do
2027
- skip "This function is defined in the header but not implemented"
2028
- end
2029
-
2030
- it "has a working function #ghashtable_utf8_container_inout" do
2031
- hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }
2032
- res = GIMarshallingTests.ghashtable_utf8_container_inout hsh
2033
- assert_equal({ "-1" => "1", "0" => "0", "1" => "1" }, res.to_hash)
2034
- end
2035
-
2036
- it "has a working function #ghashtable_utf8_container_out" do
2037
- res = GIMarshallingTests.ghashtable_utf8_container_out
2038
- assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" },
2039
- res.to_hash)
2040
- end
2041
-
2042
- it "has a working function #ghashtable_utf8_container_return" do
2043
- res = GIMarshallingTests.ghashtable_utf8_container_return
2044
- assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" },
2045
- res.to_hash)
2046
- end
2047
-
2048
- it "has a working function #ghashtable_utf8_full_in" do
2049
- skip "This function is defined in the header but not implemented"
2050
- end
2051
-
2052
- it "has a working function #ghashtable_utf8_full_inout" do
2053
- hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }
2054
- res = GIMarshallingTests.ghashtable_utf8_full_inout hsh
2055
- assert_equal({ "-1" => "1", "0" => "0", "1" => "1" }, res.to_hash)
2056
- end
2057
-
2058
- it "has a working function #ghashtable_utf8_full_out" do
2059
- res = GIMarshallingTests.ghashtable_utf8_full_out
2060
- assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" },
2061
- res.to_hash)
2062
- end
2063
-
2064
- it "has a working function #ghashtable_utf8_full_return" do
2065
- res = GIMarshallingTests.ghashtable_utf8_full_return
2066
- assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" },
2067
- res.to_hash)
2068
- end
2069
-
2070
- it "has a working function #ghashtable_utf8_none_in" do
2071
- hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }
2072
- GIMarshallingTests.ghashtable_utf8_none_in hsh
2073
- pass
2074
- end
2075
-
2076
- it "has a working function #ghashtable_utf8_none_inout" do
2077
- hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }
2078
- res = GIMarshallingTests.ghashtable_utf8_none_inout hsh
2079
- assert_equal({ "-1" => "1", "0" => "0", "1" => "1" }, res.to_hash)
2080
- end
2081
-
2082
- it "has a working function #ghashtable_utf8_none_out" do
2083
- res = GIMarshallingTests.ghashtable_utf8_none_out
2084
- assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" },
2085
- res.to_hash)
2086
- end
2087
-
2088
- it "has a working function #ghashtable_utf8_none_return" do
2089
- res = GIMarshallingTests.ghashtable_utf8_none_return
2090
- assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" },
2091
- res.to_hash)
2092
- end
2093
-
2094
- it "has a working function #glist_int_none_in" do
2095
- GIMarshallingTests.glist_int_none_in [-1, 0, 1, 2]
2096
- pass
2097
- end
2098
-
2099
- it "has a working function #glist_int_none_return" do
2100
- res = GIMarshallingTests.glist_int_none_return
2101
- _(res).must_be :==, [-1, 0, 1, 2]
2102
- end
2103
-
2104
- it "has a working function #glist_uint32_none_in" do
2105
- GIMarshallingTests.glist_uint32_none_in [0, 0xffff_ffff]
2106
- pass
2107
- end
2108
-
2109
- it "has a working function #glist_uint32_none_return" do
2110
- res = GIMarshallingTests.glist_uint32_none_return
2111
- _(res).must_be :==, [0, 0xffff_ffff]
2112
- end
2113
-
2114
- it "has a working function #glist_utf8_container_inout" do
2115
- res = GIMarshallingTests.glist_utf8_container_inout %w(0 1 2)
2116
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2117
- end
2118
-
2119
- it "has a working function #glist_utf8_container_out" do
2120
- res = GIMarshallingTests.glist_utf8_container_out
2121
- _(res).must_be :==, %w(0 1 2)
2122
- end
2123
-
2124
- it "has a working function #glist_utf8_container_return" do
2125
- res = GIMarshallingTests.glist_utf8_container_return
2126
- _(res).must_be :==, %w(0 1 2)
2127
- end
2128
-
2129
- it "has a working function #glist_utf8_full_inout" do
2130
- res = GIMarshallingTests.glist_utf8_full_inout %w(0 1 2)
2131
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2132
- end
2133
-
2134
- it "has a working function #glist_utf8_full_out" do
2135
- res = GIMarshallingTests.glist_utf8_full_out
2136
- _(res).must_be :==, %w(0 1 2)
2137
- end
2138
-
2139
- it "has a working function #glist_utf8_full_return" do
2140
- res = GIMarshallingTests.glist_utf8_full_return
2141
- _(res).must_be :==, %w(0 1 2)
2142
- end
2143
-
2144
- it "has a working function #glist_utf8_none_in" do
2145
- GIMarshallingTests.glist_utf8_none_in %w(0 1 2)
2146
- end
2147
-
2148
- it "has a working function #glist_utf8_none_inout" do
2149
- res = GIMarshallingTests.glist_utf8_none_inout %w(0 1 2)
2150
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2151
- end
2152
-
2153
- it "has a working function #glist_utf8_none_out" do
2154
- res = GIMarshallingTests.glist_utf8_none_out
2155
- _(res).must_be :==, %w(0 1 2)
2156
- end
2157
-
2158
- it "has a working function #glist_utf8_none_return" do
2159
- res = GIMarshallingTests.glist_utf8_none_return
2160
- _(res).must_be :==, %w(0 1 2)
2161
- end
2162
-
2163
- it "has a working function #gptrarray_boxed_struct_full_return" do
2164
- skip_below "1.61.1"
2165
- result = GIMarshallingTests.gptrarray_boxed_struct_full_return
2166
- _(result.map(&:long_)).must_equal [42, 43, 44]
2167
- end
2168
-
2169
- it "has a working function #gptrarray_utf8_container_inout" do
2170
- res = GIMarshallingTests.gptrarray_utf8_container_inout %w(0 1 2)
2171
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2172
- end
2173
-
2174
- it "has a working function #gptrarray_utf8_container_out" do
2175
- res = GIMarshallingTests.gptrarray_utf8_container_out
2176
- _(res).must_be :==, %w(0 1 2)
2177
- end
2178
-
2179
- it "has a working function #gptrarray_utf8_container_return" do
2180
- res = GIMarshallingTests.gptrarray_utf8_container_return
2181
- _(res).must_be :==, %w(0 1 2)
2182
- end
2183
-
2184
- it "has a working function #gptrarray_utf8_full_inout" do
2185
- res = GIMarshallingTests.gptrarray_utf8_full_inout %w(0 1 2)
2186
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2187
- end
2188
-
2189
- it "has a working function #gptrarray_utf8_full_out" do
2190
- res = GIMarshallingTests.gptrarray_utf8_full_out
2191
- _(res).must_be :==, %w(0 1 2)
2192
- end
2193
-
2194
- it "has a working function #gptrarray_utf8_full_return" do
2195
- res = GIMarshallingTests.gptrarray_utf8_full_return
2196
- _(res).must_be :==, %w(0 1 2)
2197
- end
2198
-
2199
- it "has a working function #gptrarray_utf8_none_in" do
2200
- GIMarshallingTests.gptrarray_utf8_none_in %w(0 1 2)
2201
- end
2202
-
2203
- it "has a working function #gptrarray_utf8_none_inout" do
2204
- res = GIMarshallingTests.gptrarray_utf8_none_inout %w(0 1 2)
2205
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2206
- end
2207
-
2208
- it "has a working function #gptrarray_utf8_none_out" do
2209
- res = GIMarshallingTests.gptrarray_utf8_none_out
2210
- _(res).must_be :==, %w(0 1 2)
2211
- end
2212
-
2213
- it "has a working function #gptrarray_utf8_none_return" do
2214
- res = GIMarshallingTests.gptrarray_utf8_none_return
2215
- _(res).must_be :==, %w(0 1 2)
2216
- end
2217
-
2218
- it "has a working function #gslist_int_none_in" do
2219
- GIMarshallingTests.gslist_int_none_in [-1, 0, 1, 2]
2220
- pass
2221
- end
2222
-
2223
- it "has a working function #gslist_int_none_return" do
2224
- res = GIMarshallingTests.gslist_int_none_return
2225
- _(res).must_be :==, [-1, 0, 1, 2]
2226
- end
2227
-
2228
- it "has a working function #gslist_utf8_container_inout" do
2229
- res = GIMarshallingTests.gslist_utf8_container_inout %w(0 1 2)
2230
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2231
- end
2232
-
2233
- it "has a working function #gslist_utf8_container_out" do
2234
- res = GIMarshallingTests.gslist_utf8_container_out
2235
- _(res).must_be :==, %w(0 1 2)
2236
- end
2237
-
2238
- it "has a working function #gslist_utf8_container_return" do
2239
- res = GIMarshallingTests.gslist_utf8_container_return
2240
- _(res).must_be :==, %w(0 1 2)
2241
- end
2242
-
2243
- it "has a working function #gslist_utf8_full_inout" do
2244
- res = GIMarshallingTests.gslist_utf8_full_inout %w(0 1 2)
2245
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2246
- end
2247
-
2248
- it "has a working function #gslist_utf8_full_out" do
2249
- res = GIMarshallingTests.gslist_utf8_full_out
2250
- _(res).must_be :==, %w(0 1 2)
2251
- end
2252
-
2253
- it "has a working function #gslist_utf8_full_return" do
2254
- res = GIMarshallingTests.gslist_utf8_full_return
2255
- _(res).must_be :==, %w(0 1 2)
2256
- end
2257
-
2258
- it "has a working function #gslist_utf8_none_in" do
2259
- GIMarshallingTests.gslist_utf8_none_in %w(0 1 2)
2260
- pass
2261
- end
2262
-
2263
- it "has a working function #gslist_utf8_none_inout" do
2264
- res = GIMarshallingTests.gslist_utf8_none_inout %w(0 1 2)
2265
- _(res).must_be :==, ["-2", "-1", "0", "1"]
2266
- end
2267
-
2268
- it "has a working function #gslist_utf8_none_out" do
2269
- res = GIMarshallingTests.gslist_utf8_none_out
2270
- _(res).must_be :==, %w(0 1 2)
2271
- end
2272
-
2273
- it "has a working function #gslist_utf8_none_return" do
2274
- res = GIMarshallingTests.gslist_utf8_none_return
2275
- _(res).must_be :==, %w(0 1 2)
2276
- end
2277
-
2278
- it "has a working function #gstrv_in" do
2279
- GIMarshallingTests.gstrv_in %w(0 1 2)
2280
- pass
2281
- end
2282
-
2283
- it "has a working function #gstrv_inout" do
2284
- res = GIMarshallingTests.gstrv_inout %w(0 1 2)
2285
- _(res).must_be :==, ["-1", "0", "1", "2"]
2286
- end
2287
-
2288
- it "has a working function #gstrv_out" do
2289
- res = GIMarshallingTests.gstrv_out
2290
- _(res).must_be :==, %w(0 1 2)
2291
- end
2292
-
2293
- it "has a working function #gstrv_return" do
2294
- res = GIMarshallingTests.gstrv_return
2295
- _(res).must_be :==, %w(0 1 2)
2296
- end
2297
-
2298
- it "has a working function #gtype_in" do
2299
- GIMarshallingTests.gtype_in GObject::TYPE_NONE
2300
- pass
2301
- end
2302
-
2303
- it "has a working function #gtype_inout" do
2304
- res = GIMarshallingTests.gtype_inout GObject::TYPE_NONE
2305
- _(res).must_equal GObject::TYPE_INT
2306
- end
2307
-
2308
- it "has a working function #gtype_out" do
2309
- res = GIMarshallingTests.gtype_out
2310
- _(res).must_equal GObject::TYPE_NONE
2311
- end
2312
-
2313
- it "has a working function #gtype_return" do
2314
- res = GIMarshallingTests.gtype_return
2315
- _(res).must_equal GObject::TYPE_NONE
2316
- end
2317
-
2318
- it "has a working function #gtype_string_in" do
2319
- GIMarshallingTests.gtype_string_in GObject::TYPE_STRING
2320
- pass
2321
- end
2322
-
2323
- it "has a working function #gtype_string_out" do
2324
- res = GIMarshallingTests.gtype_string_out
2325
- _(res).must_equal GObject::TYPE_STRING
2326
- end
2327
-
2328
- it "has a working function #gtype_string_return" do
2329
- res = GIMarshallingTests.gtype_string_return
2330
- _(res).must_equal GObject::TYPE_STRING
2331
- end
2332
-
2333
- it "has a working function #gvalue_flat_array" do
2334
- GIMarshallingTests.gvalue_flat_array [42, "42", true]
2335
- pass
2336
- end
2337
-
2338
- it "has a working function #gvalue_flat_array_round_trip" do
2339
- result = GIMarshallingTests.gvalue_flat_array_round_trip 42, "42", true
2340
- arr = result.to_a
2341
- _(arr[0].get_value).must_equal 42
2342
- _(arr[1].get_value).must_equal "42"
2343
- _(arr[2].get_value).must_equal true
2344
- end
2345
-
2346
- it "has a working function #gvalue_in" do
2347
- GIMarshallingTests.gvalue_in GObject::Value.wrap_ruby_value(42)
2348
- GIMarshallingTests.gvalue_in 42
2349
- pass
2350
- end
2351
-
2352
- it "has a working function #gvalue_in_enum" do
2353
- gv = GObject::Value.new
2354
- gv.init GIMarshallingTests::GEnum.gtype
2355
- gv.set_enum GIMarshallingTests::GEnum[:value3]
2356
- GIMarshallingTests.gvalue_in_enum gv
2357
- pass
2358
- end
2359
-
2360
- it "has a working function #gvalue_in_with_modification" do
2361
- gv = GObject::Value.wrap_ruby_value(42)
2362
- GIMarshallingTests.gvalue_in_with_modification gv
2363
- _(gv.get_value).must_equal 24
2364
- end
2365
-
2366
- it "has a working function #gvalue_in_with_type" do
2367
- gv = GObject::Value.new
2368
- gv.init GIMarshallingTests::SubSubObject.gtype
2369
- GIMarshallingTests.gvalue_in_with_type gv, GIMarshallingTests::Object.gtype
2370
- end
2371
-
2372
- it "has a working function #gvalue_inout" do
2373
- res = GIMarshallingTests.gvalue_inout GObject::Value.wrap_ruby_value(42)
2374
- _(res).must_equal "42"
2375
-
2376
- res = GIMarshallingTests.gvalue_inout 42
2377
- _(res).must_equal "42"
2378
- end
2379
-
2380
- it "has a working function #gvalue_int64_in" do
2381
- gv = GObject::Value.new
2382
- gv.init GObject::TYPE_INT64
2383
- gv.set_value 0x7fff_ffff_ffff_ffff
2384
- GIMarshallingTests.gvalue_int64_in gv
2385
- pass
2386
- end
2387
-
2388
- it "has a working function #gvalue_int64_out" do
2389
- gv = GIMarshallingTests.gvalue_int64_out
2390
- _(gv).must_equal 0x7fff_ffff_ffff_ffff
2391
- end
2392
-
2393
- it "has a working function #gvalue_out" do
2394
- res = GIMarshallingTests.gvalue_out
2395
- _(res).must_equal 42
2396
- end
2397
-
2398
- it "has a working function #gvalue_out_caller_allocates" do
2399
- res = GIMarshallingTests.gvalue_out_caller_allocates
2400
- _(res).must_equal 42
2401
- end
2402
-
2403
- it "has a working function #gvalue_return" do
2404
- res = GIMarshallingTests.gvalue_return
2405
- _(res).must_equal 42
2406
- end
2407
-
2408
- it "has a working function #init_function" do
2409
- res, arr = GIMarshallingTests.init_function %w(foo bar baz)
2410
- _(res).must_equal true
2411
- _(arr).must_be :==, %w(foo bar)
2412
- end
2413
-
2414
- it "has a working function #int16_in_max" do
2415
- GIMarshallingTests.int16_in_max 0x7fff
2416
- pass
2417
- end
2418
-
2419
- it "has a working function #int16_in_min" do
2420
- GIMarshallingTests.int16_in_min(-0x8000)
2421
- pass
2422
- end
2423
-
2424
- it "has a working function #int16_inout_max_min" do
2425
- res = GIMarshallingTests.int16_inout_max_min 0x7fff
2426
- assert_equal res, -0x8000
2427
- end
2428
-
2429
- it "has a working function #int16_inout_min_max" do
2430
- res = GIMarshallingTests.int16_inout_min_max(-0x8000)
2431
- assert_equal 0x7fff, res
2432
- end
2433
-
2434
- it "has a working function #int16_out_max" do
2435
- res = GIMarshallingTests.int16_out_max
2436
- assert_equal 0x7fff, res
2437
- end
2438
-
2439
- it "has a working function #int16_out_min" do
2440
- res = GIMarshallingTests.int16_out_min
2441
- assert_equal(-0x8000, res)
2442
- end
2443
-
2444
- it "has a working function #int16_return_max" do
2445
- res = GIMarshallingTests.int16_return_max
2446
- assert_equal 0x7fff, res
2447
- end
2448
-
2449
- it "has a working function #int16_return_min" do
2450
- res = GIMarshallingTests.int16_return_min
2451
- assert_equal(-0x8000, res)
2452
- end
2453
-
2454
- it "has a working function #int32_in_max" do
2455
- GIMarshallingTests.int32_in_max 0x7fffffff
2456
- pass
2457
- end
2458
-
2459
- it "has a working function #int32_in_min" do
2460
- GIMarshallingTests.int32_in_min(-0x80000000)
2461
- pass
2462
- end
2463
-
2464
- it "has a working function #int32_inout_max_min" do
2465
- res = GIMarshallingTests.int32_inout_max_min 0x7fffffff
2466
- assert_equal(-0x80000000, res)
2467
- end
2468
-
2469
- it "has a working function #int32_inout_min_max" do
2470
- res = GIMarshallingTests.int32_inout_min_max(-0x80000000)
2471
- assert_equal 0x7fffffff, res
2472
- end
2473
-
2474
- it "has a working function #int32_out_max" do
2475
- res = GIMarshallingTests.int32_out_max
2476
- assert_equal 0x7fffffff, res
2477
- end
2478
-
2479
- it "has a working function #int32_out_min" do
2480
- res = GIMarshallingTests.int32_out_min
2481
- assert_equal(-0x80000000, res)
2482
- end
2483
-
2484
- it "has a working function #int32_return_max" do
2485
- res = GIMarshallingTests.int32_return_max
2486
- assert_equal 0x7fffffff, res
2487
- end
2488
-
2489
- it "has a working function #int32_return_min" do
2490
- res = GIMarshallingTests.int32_return_min
2491
- assert_equal(-0x80000000, res)
2492
- end
2493
-
2494
- it "has a working function #int64_in_max" do
2495
- GIMarshallingTests.int64_in_max 0x7fffffffffffffff
2496
- pass
2497
- end
2498
-
2499
- it "has a working function #int64_in_min" do
2500
- GIMarshallingTests.int64_in_min(-0x8000000000000000)
2501
- pass
2502
- end
2503
-
2504
- it "has a working function #int64_inout_max_min" do
2505
- res = GIMarshallingTests.int64_inout_max_min 0x7fffffffffffffff
2506
- assert_equal(-0x8000000000000000, res)
2507
- end
2508
-
2509
- it "has a working function #int64_inout_min_max" do
2510
- res = GIMarshallingTests.int64_inout_min_max(-0x8000000000000000)
2511
- assert_equal 0x7fffffffffffffff, res
2512
- end
2513
-
2514
- it "has a working function #int64_out_max" do
2515
- res = GIMarshallingTests.int64_out_max
2516
- assert_equal 0x7fffffffffffffff, res
2517
- end
2518
-
2519
- it "has a working function #int64_out_min" do
2520
- res = GIMarshallingTests.int64_out_min
2521
- assert_equal(-0x8000000000000000, res)
2522
- end
2523
-
2524
- it "has a working function #int64_return_max" do
2525
- res = GIMarshallingTests.int64_return_max
2526
- assert_equal 0x7fffffffffffffff, res
2527
- end
2528
-
2529
- it "has a working function #int64_return_min" do
2530
- res = GIMarshallingTests.int64_return_min
2531
- assert_equal(-0x8000000000000000, res)
2532
- end
2533
-
2534
- it "has a working function #int8_in_max" do
2535
- GIMarshallingTests.int8_in_max 0x7f
2536
- pass
2537
- end
2538
-
2539
- it "has a working function #int8_in_min" do
2540
- GIMarshallingTests.int8_in_min(-0x80)
2541
- pass
2542
- end
2543
-
2544
- it "has a working function #int8_inout_max_min" do
2545
- res = GIMarshallingTests.int8_inout_max_min 0x7f
2546
- assert_equal(-0x80, res)
2547
- end
2548
-
2549
- it "has a working function #int8_inout_min_max" do
2550
- res = GIMarshallingTests.int8_inout_min_max(-0x80)
2551
- assert_equal 0x7f, res
2552
- end
2553
-
2554
- it "has a working function #int8_out_max" do
2555
- res = GIMarshallingTests.int8_out_max
2556
- assert_equal 0x7f, res
2557
- end
2558
-
2559
- it "has a working function #int8_out_min" do
2560
- res = GIMarshallingTests.int8_out_min
2561
- assert_equal(-0x80, res)
2562
- end
2563
-
2564
- it "has a working function #int8_return_max" do
2565
- res = GIMarshallingTests.int8_return_max
2566
- assert_equal 0x7f, res
2567
- end
2568
-
2569
- it "has a working function #int8_return_min" do
2570
- res = GIMarshallingTests.int8_return_min
2571
- assert_equal(-0x80, res)
2572
- end
2573
-
2574
- it "has a working function #int_in_max" do
2575
- GIMarshallingTests.int_in_max 0x7fffffff
2576
- pass
2577
- end
2578
-
2579
- it "has a working function #int_in_min" do
2580
- GIMarshallingTests.int_in_min(-0x80000000)
2581
- pass
2582
- end
2583
-
2584
- it "has a working function #int_inout_max_min" do
2585
- res = GIMarshallingTests.int_inout_max_min 0x7fffffff
2586
- assert_equal(-0x80000000, res)
2587
- end
2588
-
2589
- it "has a working function #int_inout_min_max" do
2590
- res = GIMarshallingTests.int_inout_min_max(-0x80000000)
2591
- assert_equal 0x7fffffff, res
2592
- end
2593
-
2594
- it "has a working function #int_one_in_utf8_two_in_one_allows_none" do
2595
- GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, "2", "3"
2596
- GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, nil, "3"
2597
- pass
2598
- end
2599
-
2600
- it "has a working function #int_out_max" do
2601
- res = GIMarshallingTests.int_out_max
2602
- assert_equal 0x7fffffff, res
2603
- end
2604
-
2605
- it "has a working function #int_out_min" do
2606
- res = GIMarshallingTests.int_out_min
2607
- assert_equal(-0x80000000, res)
2608
- end
2609
-
2610
- it "has a working function #int_out_out" do
2611
- res = GIMarshallingTests.int_out_out
2612
- assert_equal [6, 7], res
2613
- end
2614
-
2615
- it "has a working function #int_return_max" do
2616
- res = GIMarshallingTests.int_return_max
2617
- assert_equal 0x7fffffff, res
2618
- end
2619
-
2620
- it "has a working function #int_return_min" do
2621
- res = GIMarshallingTests.int_return_min
2622
- assert_equal(-0x80000000, res)
2623
- end
2624
-
2625
- it "has a working function #int_return_out" do
2626
- res = GIMarshallingTests.int_return_out
2627
- assert_equal [6, 7], res
2628
- end
2629
-
2630
- it "has a working function #int_three_in_three_out" do
2631
- res = GIMarshallingTests.int_three_in_three_out 4, 5, 6
2632
- assert_equal [4, 5, 6], res
2633
- end
2634
-
2635
- it "has a working function #int_two_in_utf8_two_in_with_allow_none" do
2636
- GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, "3", "4"
2637
- GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, nil, nil
2638
- pass
2639
- end
2640
-
2641
- it "has a working function #long_in_max" do
2642
- GIMarshallingTests.long_in_max max_long
2643
- pass
2644
- end
2645
-
2646
- it "has a working function #long_in_min" do
2647
- GIMarshallingTests.long_in_min min_long
2648
- pass
2649
- end
2650
-
2651
- it "has a working function #long_inout_max_min" do
2652
- res = GIMarshallingTests.long_inout_max_min max_long
2653
- assert_equal min_long, res
2654
- end
2655
-
2656
- it "has a working function #long_inout_min_max" do
2657
- res = GIMarshallingTests.long_inout_min_max min_long
2658
- assert_equal max_long, res
2659
- end
2660
-
2661
- it "has a working function #long_out_max" do
2662
- res = GIMarshallingTests.long_out_max
2663
- assert_equal max_long, res
2664
- end
2665
-
2666
- it "has a working function #long_out_min" do
2667
- res = GIMarshallingTests.long_out_min
2668
- assert_equal min_long, res
2669
- end
2670
-
2671
- it "has a working function #long_return_max" do
2672
- res = GIMarshallingTests.long_return_max
2673
- assert_equal max_long, res
2674
- end
2675
-
2676
- it "has a working function #long_return_min" do
2677
- res = GIMarshallingTests.long_return_min
2678
- assert_equal min_long, res
2679
- end
2680
-
2681
- it "has a working function #multi_array_key_value_in" do
2682
- keys = %w(one two three)
2683
- values = [1, 2, 3].map { |val| GObject::Value.wrap_ruby_value val }
2684
- GIMarshallingTests.multi_array_key_value_in keys, values
2685
- end
2686
-
2687
- it "has a working function #no_type_flags_in" do
2688
- GIMarshallingTests.no_type_flags_in value2: true
2689
- pass
2690
- end
2691
-
2692
- it "has a working function #no_type_flags_in_zero" do
2693
- GIMarshallingTests.no_type_flags_in_zero 0
2694
- pass
2695
- end
2696
-
2697
- it "has a working function #no_type_flags_inout" do
2698
- res = GIMarshallingTests.no_type_flags_inout value2: true
2699
- _(res).must_equal(value1: true)
2700
- end
2701
-
2702
- it "has a working function #no_type_flags_out" do
2703
- res = GIMarshallingTests.no_type_flags_out
2704
- _(res).must_equal(value2: true)
2705
- end
2706
-
2707
- it "has a working function #no_type_flags_returnv" do
2708
- res = GIMarshallingTests.no_type_flags_returnv
2709
- _(res).must_equal(value2: true)
2710
- end
2711
-
2712
- it "has a working function #overrides_struct_returnv" do
2713
- res = GIMarshallingTests.overrides_struct_returnv
2714
- _(res).must_be_instance_of GIMarshallingTests::OverridesStruct
2715
- end
2716
-
2717
- it "has a working function #param_spec_in_bool" do
2718
- ps = GObject.param_spec_boolean "mybool", "nick", "blurb", true, :readable
2719
- GIMarshallingTests.param_spec_in_bool ps
2720
- pass
2721
- end
2722
-
2723
- it "has a working function #param_spec_out" do
2724
- res = GIMarshallingTests.param_spec_out
2725
- _(res.value_type).must_equal GObject::TYPE_STRING
2726
- _(res.get_name).must_equal "test-param"
2727
- end
2728
-
2729
- it "has a working function #param_spec_return" do
2730
- res = GIMarshallingTests.param_spec_return
2731
- _(res.value_type).must_equal GObject::TYPE_STRING
2732
- _(res.get_name).must_equal "test-param"
2733
- end
2734
-
2735
- it "has a working function #pointer_in_return" do
2736
- ptr = FFI::MemoryPointer.new 1
2737
- res = GIMarshallingTests.pointer_in_return ptr
2738
- assert_equal ptr.address, res.address
2739
- end
2740
-
2741
- it "has a working function #pointer_struct_get_type" do
2742
- res = GIMarshallingTests.pointer_struct_get_type
2743
- gtype = GObject.type_from_name "GIMarshallingTestsPointerStruct"
2744
- assert_equal gtype, res
2745
- end
2746
-
2747
- it "has a working function #pointer_struct_returnv" do
2748
- res = GIMarshallingTests.pointer_struct_returnv
2749
- assert_instance_of GIMarshallingTests::PointerStruct, res
2750
- assert_equal 42, res.long_
2751
- end
2752
-
2753
- it "has a working function #return_gvalue_flat_array" do
2754
- result = GIMarshallingTests.return_gvalue_flat_array
2755
- arr = result.to_a
2756
- _(arr[0].get_value).must_equal 42
2757
- _(arr[1].get_value).must_equal "42"
2758
- _(arr[2].get_value).must_equal true
2759
- end
2760
-
2761
- it "has a working function #short_in_max" do
2762
- GIMarshallingTests.short_in_max 0x7fff
2763
- pass
2764
- end
2765
-
2766
- it "has a working function #short_in_min" do
2767
- GIMarshallingTests.short_in_min(-0x8000)
2768
- pass
2769
- end
2770
-
2771
- it "has a working function #short_inout_max_min" do
2772
- res = GIMarshallingTests.short_inout_max_min 0x7fff
2773
- assert_equal(-0x8000, res)
2774
- end
2775
-
2776
- it "has a working function #short_inout_min_max" do
2777
- res = GIMarshallingTests.short_inout_min_max(-0x8000)
2778
- assert_equal 0x7fff, res
2779
- end
2780
-
2781
- it "has a working function #short_out_max" do
2782
- res = GIMarshallingTests.short_out_max
2783
- assert_equal 0x7fff, res
2784
- end
2785
-
2786
- it "has a working function #short_out_min" do
2787
- res = GIMarshallingTests.short_out_min
2788
- assert_equal(-0x8000, res)
2789
- end
2790
-
2791
- it "has a working function #short_return_max" do
2792
- res = GIMarshallingTests.short_return_max
2793
- assert_equal 0x7fff, res
2794
- end
2795
-
2796
- it "has a working function #short_return_min" do
2797
- res = GIMarshallingTests.short_return_min
2798
- assert_equal(-0x8000, res)
2799
- end
2800
-
2801
- it "has a working function #simple_struct_returnv" do
2802
- res = GIMarshallingTests.simple_struct_returnv
2803
- assert_instance_of GIMarshallingTests::SimpleStruct, res
2804
- assert_equal 6, res.long_
2805
- assert_equal 7, res.int8
2806
- end
2807
-
2808
- it "has a working function #size_in" do
2809
- GIMarshallingTests.size_in max_size_t
2810
- end
2811
-
2812
- it "has a working function #size_inout" do
2813
- res = GIMarshallingTests.size_inout max_size_t
2814
- assert_equal 0, res
2815
- end
2816
-
2817
- it "has a working function #size_out" do
2818
- res = GIMarshallingTests.size_out
2819
- assert_equal max_size_t, res
2820
- end
2821
-
2822
- it "has a working function #size_return" do
2823
- res = GIMarshallingTests.size_return
2824
- assert_equal max_size_t, res
2825
- end
2826
-
2827
- it "has a working function #ssize_in_max" do
2828
- GIMarshallingTests.ssize_in_max max_ssize_t
2829
- pass
2830
- end
2831
-
2832
- it "has a working function #ssize_in_min" do
2833
- GIMarshallingTests.ssize_in_min min_ssize_t
2834
- pass
2835
- end
2836
-
2837
- it "has a working function #ssize_inout_max_min" do
2838
- res = GIMarshallingTests.ssize_inout_max_min max_ssize_t
2839
- assert_equal min_ssize_t, res
2840
- end
2841
-
2842
- it "has a working function #ssize_inout_min_max" do
2843
- res = GIMarshallingTests.ssize_inout_min_max min_ssize_t
2844
- assert_equal max_ssize_t, res
2845
- end
2846
-
2847
- it "has a working function #ssize_out_max" do
2848
- res = GIMarshallingTests.ssize_out_max
2849
- assert_equal max_ssize_t, res
2850
- end
2851
-
2852
- it "has a working function #ssize_out_min" do
2853
- res = GIMarshallingTests.ssize_out_min
2854
- assert_equal min_ssize_t, res
2855
- end
2856
-
2857
- it "has a working function #ssize_return_max" do
2858
- res = GIMarshallingTests.ssize_return_max
2859
- assert_equal max_ssize_t, res
2860
- end
2861
-
2862
- it "has a working function #ssize_return_min" do
2863
- res = GIMarshallingTests.ssize_return_min
2864
- assert_equal min_ssize_t, res
2865
- end
2866
-
2867
- it "has a working function #test_interface_test_int8_in" do
2868
- derived_klass.class_eval { include GIMarshallingTests::Interface }
2869
- instance = make_derived_instance do |info|
2870
- info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ }
2871
- end
2872
- _(instance.int).must_equal 0
2873
- GIMarshallingTests.test_interface_test_int8_in instance, 8
2874
- _(instance.int).must_equal 8
2875
- end
2876
-
2877
- it "has a working function #time_t_in" do
2878
- GIMarshallingTests.time_t_in 1_234_567_890
2879
- pass
2880
- end
2881
-
2882
- it "has a working function #time_t_inout" do
2883
- res = GIMarshallingTests.time_t_inout 1_234_567_890
2884
- assert_equal 0, res
2885
- end
2886
-
2887
- it "has a working function #time_t_out" do
2888
- res = GIMarshallingTests.time_t_out
2889
- assert_equal 1_234_567_890, res
2890
- end
2891
-
2892
- it "has a working function #time_t_return" do
2893
- res = GIMarshallingTests.time_t_return
2894
- assert_equal 1_234_567_890, res
2895
- end
2896
-
2897
- it "has a working function #uint16_in" do
2898
- GIMarshallingTests.uint16_in 0xffff
2899
- pass
2900
- end
2901
-
2902
- it "has a working function #uint16_inout" do
2903
- res = GIMarshallingTests.uint16_inout 0xffff
2904
- assert_equal 0, res
2905
- end
2906
-
2907
- it "has a working function #uint16_out" do
2908
- res = GIMarshallingTests.uint16_out
2909
- assert_equal 0xffff, res
2910
- end
2911
-
2912
- it "has a working function #uint16_return" do
2913
- res = GIMarshallingTests.uint16_return
2914
- assert_equal 0xffff, res
2915
- end
2916
-
2917
- it "has a working function #uint32_in" do
2918
- GIMarshallingTests.uint32_in 0xffffffff
2919
- end
2920
-
2921
- it "has a working function #uint32_inout" do
2922
- res = GIMarshallingTests.uint32_inout 0xffffffff
2923
- assert_equal 0, res
2924
- end
2925
-
2926
- it "has a working function #uint32_out" do
2927
- res = GIMarshallingTests.uint32_out
2928
- assert_equal 0xffffffff, res
2929
- end
2930
-
2931
- it "has a working function #uint32_return" do
2932
- res = GIMarshallingTests.uint32_return
2933
- assert_equal 0xffffffff, res
2934
- end
2935
-
2936
- it "has a working function #uint64_in" do
2937
- GIMarshallingTests.uint64_in 0xffff_ffff_ffff_ffff
2938
- pass
2939
- end
2940
-
2941
- it "has a working function #uint64_inout" do
2942
- res = GIMarshallingTests.uint64_inout 0xffff_ffff_ffff_ffff
2943
- assert_equal 0, res
2944
- end
2945
-
2946
- it "has a working function #uint64_out" do
2947
- res = GIMarshallingTests.uint64_out
2948
- assert_equal 0xffff_ffff_ffff_ffff, res
2949
- end
2950
-
2951
- it "has a working function #uint64_return" do
2952
- res = GIMarshallingTests.uint64_return
2953
- assert_equal 0xffff_ffff_ffff_ffff, res
2954
- end
2955
-
2956
- it "has a working function #uint8_in" do
2957
- GIMarshallingTests.uint8_in 0xff
2958
- end
2959
-
2960
- it "has a working function #uint8_inout" do
2961
- res = GIMarshallingTests.uint8_inout 0xff
2962
- assert_equal 0, res
2963
- end
2964
-
2965
- it "has a working function #uint8_out" do
2966
- res = GIMarshallingTests.uint8_out
2967
- assert_equal 0xff, res
2968
- end
2969
-
2970
- it "has a working function #uint8_return" do
2971
- res = GIMarshallingTests.uint8_return
2972
- assert_equal 0xff, res
2973
- end
2974
-
2975
- it "has a working function #uint_in" do
2976
- GIMarshallingTests.uint_in max_uint
2977
- pass
2978
- end
2979
-
2980
- it "has a working function #uint_inout" do
2981
- res = GIMarshallingTests.uint_inout max_uint
2982
- assert_equal 0, res
2983
- end
2984
-
2985
- it "has a working function #uint_out" do
2986
- res = GIMarshallingTests.uint_out
2987
- assert_equal max_uint, res
2988
- end
2989
-
2990
- it "has a working function #uint_return" do
2991
- res = GIMarshallingTests.uint_return
2992
- assert_equal max_uint, res
2993
- end
2994
-
2995
- it "has a working function #ulong_in" do
2996
- GIMarshallingTests.ulong_in max_ulong
2997
- end
2998
-
2999
- it "has a working function #ulong_inout" do
3000
- res = GIMarshallingTests.ulong_inout max_ulong
3001
- assert_equal 0, res
3002
- end
3003
-
3004
- it "has a working function #ulong_out" do
3005
- res = GIMarshallingTests.ulong_out
3006
- assert_equal max_ulong, res
3007
- end
3008
-
3009
- it "has a working function #ulong_return" do
3010
- res = GIMarshallingTests.ulong_return
3011
- assert_equal max_ulong, res
3012
- end
3013
-
3014
- it "has a working function #union_inout" do
3015
- skip "This function is defined in the header but not implemented"
3016
- end
3017
-
3018
- it "has a working function #union_out" do
3019
- skip "This function is defined in the header but not implemented"
3020
- end
3021
-
3022
- it "has a working function #union_returnv" do
3023
- res = GIMarshallingTests.union_returnv
3024
- assert_instance_of GIMarshallingTests::Union, res
3025
- assert_equal 42, res.long_
3026
- end
3027
-
3028
- it "has a working function #ushort_in" do
3029
- GIMarshallingTests.ushort_in max_ushort
3030
- pass
3031
- end
3032
-
3033
- it "has a working function #ushort_inout" do
3034
- res = GIMarshallingTests.ushort_inout max_ushort
3035
- assert_equal 0, res
3036
- end
3037
-
3038
- it "has a working function #ushort_out" do
3039
- res = GIMarshallingTests.ushort_out
3040
- assert_equal max_ushort, res
3041
- end
3042
-
3043
- it "has a working function #ushort_return" do
3044
- res = GIMarshallingTests.ushort_return
3045
- assert_equal max_ushort, res
3046
- end
3047
-
3048
- it "has a working function #utf8_as_uint8array_in" do
3049
- GIMarshallingTests.utf8_as_uint8array_in GIMarshallingTests::CONSTANT_UTF8.bytes.to_a
3050
- pass
3051
- end
3052
-
3053
- it "has a working function #utf8_dangling_out" do
3054
- res = GIMarshallingTests.utf8_dangling_out
3055
- assert_nil res
3056
- end
3057
-
3058
- it "has a working function #utf8_full_in" do
3059
- skip "This function is defined in the header but not implemented"
3060
- end
3061
-
3062
- it "has a working function #utf8_full_inout" do
3063
- res = GIMarshallingTests.utf8_full_inout "const ♥ utf8"
3064
- assert_equal "", res
3065
- end
3066
-
3067
- it "has a working function #utf8_full_out" do
3068
- res = GIMarshallingTests.utf8_full_out
3069
- assert_equal "const ♥ utf8", res
3070
- end
3071
-
3072
- it "has a working function #utf8_full_return" do
3073
- res = GIMarshallingTests.utf8_full_return
3074
- assert_equal "const ♥ utf8", res
3075
- end
3076
-
3077
- it "has a working function #utf8_none_in" do
3078
- GIMarshallingTests.utf8_none_in "const ♥ utf8"
3079
- pass
3080
- end
3081
-
3082
- it "has a working function #utf8_none_inout" do
3083
- res = GIMarshallingTests.utf8_none_inout "const ♥ utf8"
3084
- assert_equal "", res
3085
- end
3086
-
3087
- it "has a working function #utf8_none_out" do
3088
- res = GIMarshallingTests.utf8_none_out
3089
- assert_equal "const ♥ utf8", res
3090
- end
3091
-
3092
- it "has a working function #utf8_none_return" do
3093
- res = GIMarshallingTests.utf8_none_return
3094
- assert_equal "const ♥ utf8", res
3095
- end
3096
- end