rice 4.3.3 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -26
- data/README.md +7 -2
- data/Rakefile +7 -1
- data/include/rice/rice.hpp +7291 -4430
- data/include/rice/stl.hpp +769 -222
- data/lib/mkmf-rice.rb +37 -95
- data/rice/Address_Registration_Guard.hpp +72 -3
- data/rice/Arg.hpp +19 -5
- data/rice/Arg.ipp +24 -0
- data/rice/Callback.hpp +21 -0
- data/rice/Callback.ipp +13 -0
- data/rice/Constructor.hpp +4 -27
- data/rice/Constructor.ipp +79 -0
- data/rice/Data_Object.hpp +74 -3
- data/rice/Data_Object.ipp +324 -32
- data/rice/Data_Type.hpp +215 -3
- data/rice/Data_Type.ipp +125 -64
- data/rice/Director.hpp +0 -2
- data/rice/Enum.hpp +4 -6
- data/rice/Enum.ipp +101 -57
- data/rice/Exception.hpp +62 -2
- data/rice/Exception.ipp +7 -12
- data/rice/JumpException.hpp +44 -0
- data/rice/JumpException.ipp +48 -0
- data/rice/MemoryView.hpp +11 -0
- data/rice/MemoryView.ipp +43 -0
- data/rice/Return.hpp +6 -26
- data/rice/Return.ipp +10 -16
- data/rice/detail/DefaultHandler.hpp +12 -0
- data/rice/detail/DefaultHandler.ipp +8 -0
- data/rice/detail/HandlerRegistry.hpp +5 -35
- data/rice/detail/HandlerRegistry.ipp +7 -11
- data/rice/detail/InstanceRegistry.hpp +1 -4
- data/rice/detail/MethodInfo.hpp +15 -5
- data/rice/detail/MethodInfo.ipp +78 -6
- data/rice/detail/Native.hpp +32 -0
- data/rice/detail/Native.ipp +129 -0
- data/rice/detail/NativeAttributeGet.hpp +51 -0
- data/rice/detail/NativeAttributeGet.ipp +51 -0
- data/rice/detail/NativeAttributeSet.hpp +43 -0
- data/rice/detail/NativeAttributeSet.ipp +82 -0
- data/rice/detail/NativeCallbackFFI.hpp +55 -0
- data/rice/detail/NativeCallbackFFI.ipp +151 -0
- data/rice/detail/NativeCallbackSimple.hpp +30 -0
- data/rice/detail/NativeCallbackSimple.ipp +29 -0
- data/rice/detail/NativeFunction.hpp +20 -21
- data/rice/detail/NativeFunction.ipp +199 -64
- data/rice/detail/NativeIterator.hpp +8 -11
- data/rice/detail/NativeIterator.ipp +27 -31
- data/rice/detail/NativeRegistry.hpp +24 -15
- data/rice/detail/NativeRegistry.ipp +23 -48
- data/rice/detail/Proc.hpp +4 -0
- data/rice/detail/Proc.ipp +85 -0
- data/rice/detail/Registries.hpp +0 -7
- data/rice/detail/Registries.ipp +0 -18
- data/rice/detail/RubyFunction.hpp +0 -3
- data/rice/detail/RubyFunction.ipp +4 -8
- data/rice/detail/RubyType.hpp +19 -0
- data/rice/detail/RubyType.ipp +187 -0
- data/rice/detail/TupleIterator.hpp +14 -0
- data/rice/detail/Type.hpp +5 -6
- data/rice/detail/Type.ipp +150 -33
- data/rice/detail/TypeRegistry.hpp +15 -7
- data/rice/detail/TypeRegistry.ipp +105 -12
- data/rice/detail/Wrapper.hpp +6 -5
- data/rice/detail/Wrapper.ipp +45 -23
- data/rice/detail/cpp_protect.hpp +5 -6
- data/rice/detail/default_allocation_func.ipp +0 -2
- data/rice/detail/from_ruby.hpp +37 -3
- data/rice/detail/from_ruby.ipp +911 -454
- data/rice/detail/ruby.hpp +18 -0
- data/rice/detail/to_ruby.hpp +41 -3
- data/rice/detail/to_ruby.ipp +437 -113
- data/rice/global_function.hpp +0 -4
- data/rice/global_function.ipp +1 -2
- data/rice/rice.hpp +105 -22
- data/rice/ruby_mark.hpp +4 -3
- data/rice/stl.hpp +4 -0
- data/test/embed_ruby.cpp +4 -1
- data/test/extconf.rb +2 -0
- data/test/ruby/test_multiple_extensions_same_class.rb +14 -14
- data/test/test_Address_Registration_Guard.cpp +5 -0
- data/test/test_Array.cpp +12 -1
- data/test/test_Attribute.cpp +103 -21
- data/test/test_Builtin_Object.cpp +5 -0
- data/test/test_Callback.cpp +231 -0
- data/test/test_Class.cpp +5 -31
- data/test/test_Constructor.cpp +69 -6
- data/test/test_Data_Object.cpp +9 -4
- data/test/test_Data_Type.cpp +428 -64
- data/test/test_Director.cpp +10 -5
- data/test/test_Enum.cpp +152 -40
- data/test/test_Exception.cpp +235 -0
- data/test/test_File.cpp +70 -0
- data/test/test_From_Ruby.cpp +542 -0
- data/test/test_Hash.cpp +5 -0
- data/test/test_Identifier.cpp +5 -0
- data/test/test_Inheritance.cpp +6 -1
- data/test/test_Iterator.cpp +5 -0
- data/test/test_JumpException.cpp +22 -0
- data/test/test_Keep_Alive.cpp +6 -1
- data/test/test_Keep_Alive_No_Wrapper.cpp +5 -0
- data/test/test_Memory_Management.cpp +5 -0
- data/test/test_Module.cpp +118 -64
- data/test/test_Native_Registry.cpp +2 -33
- data/test/test_Object.cpp +5 -0
- data/test/test_Overloads.cpp +631 -0
- data/test/test_Ownership.cpp +67 -4
- data/test/test_Proc.cpp +45 -0
- data/test/test_Self.cpp +5 -0
- data/test/test_Stl_Exception.cpp +109 -0
- data/test/test_Stl_Map.cpp +22 -8
- data/test/test_Stl_Optional.cpp +5 -0
- data/test/test_Stl_Pair.cpp +7 -2
- data/test/test_Stl_Reference_Wrapper.cpp +5 -0
- data/test/test_Stl_SmartPointer.cpp +210 -5
- data/test/test_Stl_String.cpp +5 -0
- data/test/test_Stl_String_View.cpp +5 -0
- data/test/test_Stl_Type.cpp +147 -0
- data/test/test_Stl_Unordered_Map.cpp +18 -7
- data/test/test_Stl_Variant.cpp +5 -0
- data/test/test_Stl_Vector.cpp +130 -8
- data/test/test_String.cpp +5 -0
- data/test/test_Struct.cpp +5 -0
- data/test/test_Symbol.cpp +5 -0
- data/test/test_Template.cpp +192 -0
- data/test/test_To_Ruby.cpp +152 -0
- data/test/test_Tracking.cpp +1 -0
- data/test/test_Type.cpp +100 -0
- data/test/test_global_functions.cpp +53 -6
- data/test/unittest.cpp +8 -0
- metadata +37 -20
- data/lib/version.rb +0 -3
- data/rice/Address_Registration_Guard_defn.hpp +0 -79
- data/rice/Data_Object_defn.hpp +0 -84
- data/rice/Data_Type_defn.hpp +0 -190
- data/rice/Exception_defn.hpp +0 -68
- data/rice/HandlerRegistration.hpp +0 -15
- data/rice/Identifier.hpp +0 -50
- data/rice/Identifier.ipp +0 -29
- data/rice/detail/ExceptionHandler.hpp +0 -8
- data/rice/detail/ExceptionHandler.ipp +0 -28
- data/rice/detail/ExceptionHandler_defn.hpp +0 -77
- data/rice/detail/Jump_Tag.hpp +0 -21
- data/rice/detail/NativeAttribute.hpp +0 -64
- data/rice/detail/NativeAttribute.ipp +0 -112
- data/rice/detail/from_ruby_defn.hpp +0 -38
- data/rice/detail/to_ruby_defn.hpp +0 -48
- data/test/test_Jump_Tag.cpp +0 -17
- data/test/test_To_From_Ruby.cpp +0 -399
data/test/test_To_From_Ruby.cpp
DELETED
@@ -1,399 +0,0 @@
|
|
1
|
-
#include "unittest.hpp"
|
2
|
-
#include "embed_ruby.hpp"
|
3
|
-
#include <rice/rice.hpp>
|
4
|
-
|
5
|
-
#include <limits>
|
6
|
-
#include <cmath>
|
7
|
-
|
8
|
-
using namespace Rice;
|
9
|
-
|
10
|
-
TESTSUITE(To_From_Ruby);
|
11
|
-
|
12
|
-
SETUP(To_From_Ruby)
|
13
|
-
{
|
14
|
-
embed_ruby();
|
15
|
-
}
|
16
|
-
|
17
|
-
TESTCASE(object_to_ruby)
|
18
|
-
{
|
19
|
-
Object o(rb_str_new2("foo"));
|
20
|
-
ASSERT_EQUAL(o.value(), detail::to_ruby(o));
|
21
|
-
}
|
22
|
-
|
23
|
-
TESTCASE(object_from_ruby)
|
24
|
-
{
|
25
|
-
Object o(rb_str_new2("foo"));
|
26
|
-
ASSERT_EQUAL(o, detail::From_Ruby<Object>().convert(o));
|
27
|
-
}
|
28
|
-
|
29
|
-
TESTCASE(short_to_ruby)
|
30
|
-
{
|
31
|
-
ASSERT_EQUAL(INT2NUM(0), detail::to_ruby((short)0));
|
32
|
-
ASSERT_EQUAL(INT2NUM(-1), detail::to_ruby((short)-1));
|
33
|
-
ASSERT_EQUAL(INT2NUM(1), detail::to_ruby((short)1));
|
34
|
-
ASSERT_EQUAL(INT2NUM(std::numeric_limits<short>::min()),
|
35
|
-
detail::to_ruby(std::numeric_limits<short>::min()));
|
36
|
-
ASSERT_EQUAL(INT2NUM(std::numeric_limits<short>::max()),
|
37
|
-
detail::to_ruby(std::numeric_limits<short>::max()));
|
38
|
-
}
|
39
|
-
|
40
|
-
TESTCASE(short_from_ruby)
|
41
|
-
{
|
42
|
-
ASSERT_EQUAL(0, detail::From_Ruby<short>().convert(INT2NUM(0)));
|
43
|
-
ASSERT_EQUAL(-1, detail::From_Ruby<short>().convert(INT2NUM(-1)));
|
44
|
-
ASSERT_EQUAL(1, detail::From_Ruby<short>().convert(INT2NUM(1)));
|
45
|
-
ASSERT_EQUAL(std::numeric_limits<short>::min(),
|
46
|
-
detail::From_Ruby<short>().convert(INT2NUM(std::numeric_limits<short>::min())));
|
47
|
-
ASSERT_EQUAL(std::numeric_limits<short>::max(),
|
48
|
-
detail::From_Ruby<short>().convert(INT2NUM(std::numeric_limits<short>::max())));
|
49
|
-
|
50
|
-
ASSERT_EXCEPTION_CHECK(
|
51
|
-
Exception,
|
52
|
-
detail::From_Ruby<short>().convert(rb_str_new2("bad value")),
|
53
|
-
ASSERT_EQUAL("no implicit conversion of String into Integer", ex.what())
|
54
|
-
);
|
55
|
-
}
|
56
|
-
|
57
|
-
TESTCASE(int_to_ruby)
|
58
|
-
{
|
59
|
-
ASSERT(rb_equal(INT2NUM(0), detail::to_ruby((int)0)));
|
60
|
-
ASSERT(rb_equal(INT2NUM(-1), detail::to_ruby((int)-1)));
|
61
|
-
ASSERT(rb_equal(INT2NUM(1), detail::to_ruby((int)1)));
|
62
|
-
ASSERT(rb_equal(INT2NUM(std::numeric_limits<int>::min()), detail::to_ruby(std::numeric_limits<int>::min())));
|
63
|
-
ASSERT(rb_equal(INT2NUM(std::numeric_limits<int>::max()), detail::to_ruby(std::numeric_limits<int>::max())));
|
64
|
-
}
|
65
|
-
|
66
|
-
TESTCASE(int_from_ruby)
|
67
|
-
{
|
68
|
-
ASSERT_EQUAL(0, detail::From_Ruby<int>().convert(INT2NUM(0)));
|
69
|
-
ASSERT_EQUAL(-1, detail::From_Ruby<int>().convert(INT2NUM(-1)));
|
70
|
-
ASSERT_EQUAL(1, detail::From_Ruby<int>().convert(INT2NUM(1)));
|
71
|
-
ASSERT_EQUAL(std::numeric_limits<int>::min(),
|
72
|
-
detail::From_Ruby<int>().convert(INT2NUM(std::numeric_limits<int>::min())));
|
73
|
-
ASSERT_EQUAL(std::numeric_limits<int>::max(),
|
74
|
-
detail::From_Ruby<int>().convert(INT2NUM(std::numeric_limits<int>::max())));
|
75
|
-
|
76
|
-
ASSERT_EXCEPTION_CHECK(
|
77
|
-
Exception,
|
78
|
-
detail::From_Ruby<int>().convert(rb_str_new2("bad value")),
|
79
|
-
ASSERT_EQUAL("no implicit conversion of String into Integer", ex.what())
|
80
|
-
);
|
81
|
-
}
|
82
|
-
|
83
|
-
TESTCASE(long_to_ruby)
|
84
|
-
{
|
85
|
-
ASSERT(rb_equal(LONG2NUM(0), detail::to_ruby((long)0)));
|
86
|
-
ASSERT(rb_equal(LONG2NUM(-1), detail::to_ruby((long)-1)));
|
87
|
-
ASSERT(rb_equal(LONG2NUM(1), detail::to_ruby((long)1)));
|
88
|
-
ASSERT(rb_equal(LONG2NUM(FIXNUM_MAX), detail::to_ruby(FIXNUM_MAX)));
|
89
|
-
ASSERT(rb_equal(LONG2NUM(FIXNUM_MIN), detail::to_ruby(FIXNUM_MIN)));
|
90
|
-
ASSERT(rb_equal(LONG2NUM(std::numeric_limits<long>::min()), detail::to_ruby(std::numeric_limits<long>::min())));
|
91
|
-
ASSERT(rb_equal(LONG2NUM(std::numeric_limits<long>::max()), detail::to_ruby(std::numeric_limits<long>::max())));
|
92
|
-
}
|
93
|
-
|
94
|
-
TESTCASE(long_from_ruby)
|
95
|
-
{
|
96
|
-
ASSERT_EQUAL(0, detail::From_Ruby<long>().convert(LONG2NUM(0)));
|
97
|
-
ASSERT_EQUAL(-1, detail::From_Ruby<long>().convert(LONG2NUM(-1)));
|
98
|
-
ASSERT_EQUAL(1, detail::From_Ruby<long>().convert(LONG2NUM(1)));
|
99
|
-
ASSERT_EQUAL(FIXNUM_MIN, detail::From_Ruby<long>().convert(LONG2NUM(FIXNUM_MIN)));
|
100
|
-
ASSERT_EQUAL(FIXNUM_MAX, detail::From_Ruby<long>().convert(LONG2NUM(FIXNUM_MAX)));
|
101
|
-
ASSERT_EQUAL(std::numeric_limits<long>::min(), detail::From_Ruby<long>().convert(LONG2NUM(std::numeric_limits<long>::min())));
|
102
|
-
ASSERT_EQUAL(std::numeric_limits<long>::max(), detail::From_Ruby<long>().convert(LONG2NUM(std::numeric_limits<long>::max())));
|
103
|
-
|
104
|
-
ASSERT_EXCEPTION_CHECK(
|
105
|
-
Exception,
|
106
|
-
detail::From_Ruby<long>().convert(rb_str_new2("bad value")),
|
107
|
-
ASSERT_EQUAL("no implicit conversion of String into Integer", ex.what())
|
108
|
-
);
|
109
|
-
}
|
110
|
-
|
111
|
-
TESTCASE(long_long_to_ruby)
|
112
|
-
{
|
113
|
-
ASSERT(rb_equal(LL2NUM(0), detail::to_ruby((long long)0)));
|
114
|
-
ASSERT(rb_equal(LL2NUM(-1), detail::to_ruby((long long)-1)));
|
115
|
-
ASSERT(rb_equal(LL2NUM(1), detail::to_ruby((long long)1)));
|
116
|
-
ASSERT(rb_equal(LL2NUM(std::numeric_limits<long long>::min()), detail::to_ruby(std::numeric_limits<long long>::min())));
|
117
|
-
ASSERT(rb_equal(LL2NUM(std::numeric_limits<long long>::max()), detail::to_ruby(std::numeric_limits<long long>::max())));
|
118
|
-
}
|
119
|
-
|
120
|
-
TESTCASE(long_long_from_ruby)
|
121
|
-
{
|
122
|
-
ASSERT_EQUAL(0, detail::From_Ruby<long long>().convert(LL2NUM(0)));
|
123
|
-
ASSERT_EQUAL(-1, detail::From_Ruby<long long>().convert(LL2NUM(-1)));
|
124
|
-
ASSERT_EQUAL(1, detail::From_Ruby<long long>().convert(LL2NUM(1)));
|
125
|
-
ASSERT_EQUAL(std::numeric_limits<long long>::min(),
|
126
|
-
detail::From_Ruby<long long>().convert(LL2NUM(std::numeric_limits<long long>::min())));
|
127
|
-
ASSERT_EQUAL(std::numeric_limits<long long>::max(),
|
128
|
-
detail::From_Ruby<long long>().convert(LL2NUM(std::numeric_limits<long long>::max())));
|
129
|
-
|
130
|
-
ASSERT_EXCEPTION_CHECK(
|
131
|
-
Exception,
|
132
|
-
detail::From_Ruby<long long>().convert(rb_str_new2("bad value")),
|
133
|
-
ASSERT_EQUAL("no implicit conversion from string", ex.what())
|
134
|
-
);
|
135
|
-
}
|
136
|
-
|
137
|
-
TESTCASE(unsigned_short_to_ruby)
|
138
|
-
{
|
139
|
-
ASSERT(rb_equal(UINT2NUM(0), detail::to_ruby((unsigned short)0)));
|
140
|
-
ASSERT(rb_equal(UINT2NUM(1), detail::to_ruby((unsigned short)1)));
|
141
|
-
ASSERT(rb_equal(UINT2NUM(std::numeric_limits<unsigned short>::min()), detail::to_ruby(std::numeric_limits<unsigned short>::min())));
|
142
|
-
ASSERT(rb_equal(UINT2NUM(std::numeric_limits<unsigned short>::max()), detail::to_ruby(std::numeric_limits<unsigned short>::max())));
|
143
|
-
}
|
144
|
-
|
145
|
-
TESTCASE(unsigned_short_from_ruby)
|
146
|
-
{
|
147
|
-
ASSERT_EQUAL(0u, detail::From_Ruby<unsigned short>().convert(UINT2NUM(0)));
|
148
|
-
ASSERT_EQUAL(1u, detail::From_Ruby<unsigned short>().convert(UINT2NUM(1)));
|
149
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned short>::min(),
|
150
|
-
detail::From_Ruby<unsigned short>().convert(UINT2NUM(std::numeric_limits<unsigned short>::min())));
|
151
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned short>::max(),
|
152
|
-
detail::From_Ruby<unsigned short>().convert(UINT2NUM(std::numeric_limits<unsigned short>::max())));
|
153
|
-
|
154
|
-
ASSERT_EXCEPTION_CHECK(
|
155
|
-
Exception,
|
156
|
-
detail::From_Ruby<unsigned short>().convert(rb_str_new2("bad value")),
|
157
|
-
ASSERT_EQUAL("no implicit conversion of String into Integer", ex.what())
|
158
|
-
);
|
159
|
-
}
|
160
|
-
|
161
|
-
TESTCASE(unsigned_int_to_ruby)
|
162
|
-
{
|
163
|
-
ASSERT(rb_equal(UINT2NUM(0), detail::to_ruby((unsigned int)0)));
|
164
|
-
ASSERT(rb_equal(UINT2NUM(1), detail::to_ruby((unsigned int)1)));
|
165
|
-
ASSERT(rb_equal(UINT2NUM(std::numeric_limits<unsigned int>::min()), detail::to_ruby(std::numeric_limits<unsigned int>::min())));
|
166
|
-
ASSERT(rb_equal(UINT2NUM(std::numeric_limits<unsigned int>::max()), detail::to_ruby(std::numeric_limits<unsigned int>::max())));
|
167
|
-
}
|
168
|
-
|
169
|
-
TESTCASE(unsigned_int_from_ruby)
|
170
|
-
{
|
171
|
-
ASSERT_EQUAL(0u, detail::From_Ruby<unsigned int>().convert(UINT2NUM(0)));
|
172
|
-
ASSERT_EQUAL(1u, detail::From_Ruby<unsigned int>().convert(UINT2NUM(1)));
|
173
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned int>::min(),
|
174
|
-
detail::From_Ruby<unsigned int>().convert(UINT2NUM(std::numeric_limits<unsigned int>::min())));
|
175
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned int>::max(),
|
176
|
-
detail::From_Ruby<unsigned int>().convert(UINT2NUM(std::numeric_limits<unsigned int>::max())));
|
177
|
-
|
178
|
-
ASSERT_EXCEPTION_CHECK(
|
179
|
-
Exception,
|
180
|
-
detail::From_Ruby<unsigned int>().convert(rb_str_new2("bad value")),
|
181
|
-
ASSERT_EQUAL("no implicit conversion of String into Integer", ex.what())
|
182
|
-
);
|
183
|
-
}
|
184
|
-
|
185
|
-
TESTCASE(unsigned_long_to_ruby)
|
186
|
-
{
|
187
|
-
ASSERT(rb_equal(ULONG2NUM(0), detail::to_ruby((unsigned long)0)));
|
188
|
-
ASSERT(rb_equal(ULONG2NUM(1), detail::to_ruby((unsigned long)1)));
|
189
|
-
ASSERT(rb_equal(ULONG2NUM(FIXNUM_MAX), detail::to_ruby(FIXNUM_MAX)));
|
190
|
-
ASSERT(rb_equal(ULONG2NUM(std::numeric_limits<unsigned long>::min()), detail::to_ruby(std::numeric_limits<unsigned long>::min())));
|
191
|
-
ASSERT(rb_equal(ULONG2NUM(std::numeric_limits<unsigned long>::max()), detail::to_ruby(std::numeric_limits<unsigned long>::max())));
|
192
|
-
}
|
193
|
-
|
194
|
-
TESTCASE(unsigned_long_from_ruby)
|
195
|
-
{
|
196
|
-
ASSERT_EQUAL(0u, detail::From_Ruby<unsigned long>().convert(ULONG2NUM(0)));
|
197
|
-
ASSERT_EQUAL(1u, detail::From_Ruby<unsigned long>().convert(ULONG2NUM(1)));
|
198
|
-
ASSERT_EQUAL(static_cast<unsigned long>(FIXNUM_MIN),
|
199
|
-
detail::From_Ruby<unsigned long>().convert(ULONG2NUM(FIXNUM_MIN)));
|
200
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned long>::min(),
|
201
|
-
detail::From_Ruby<unsigned long>().convert(ULONG2NUM(std::numeric_limits<unsigned long>::min())));
|
202
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned long>::max(),
|
203
|
-
detail::From_Ruby<unsigned long>().convert(ULONG2NUM(std::numeric_limits<unsigned long>::max())));
|
204
|
-
|
205
|
-
ASSERT_EXCEPTION_CHECK(
|
206
|
-
Exception,
|
207
|
-
detail::From_Ruby<unsigned long>().convert(rb_str_new2("bad value")),
|
208
|
-
ASSERT_EQUAL("no implicit conversion of String into Integer", ex.what())
|
209
|
-
);
|
210
|
-
}
|
211
|
-
|
212
|
-
TESTCASE(unsigned_long_long_to_ruby)
|
213
|
-
{
|
214
|
-
ASSERT(rb_equal(ULL2NUM(0), detail::to_ruby((unsigned long long)0)));
|
215
|
-
ASSERT(rb_equal(ULL2NUM(1), detail::to_ruby((unsigned long long)1)));
|
216
|
-
ASSERT(rb_equal(ULL2NUM(std::numeric_limits<unsigned long long>::min()), detail::to_ruby(std::numeric_limits<unsigned long long>::min())));
|
217
|
-
ASSERT(rb_equal(ULL2NUM(std::numeric_limits<unsigned long long>::max()), detail::to_ruby(std::numeric_limits<unsigned long long>::max())));
|
218
|
-
}
|
219
|
-
|
220
|
-
TESTCASE(unsigned_long_long_from_ruby)
|
221
|
-
{
|
222
|
-
ASSERT_EQUAL(0u, detail::From_Ruby<unsigned long>().convert(ULL2NUM(0)));
|
223
|
-
ASSERT_EQUAL(1u, detail::From_Ruby<unsigned long>().convert(ULL2NUM(1)));
|
224
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned long long>::min(),
|
225
|
-
detail::From_Ruby<unsigned long long>().convert(ULL2NUM(std::numeric_limits<unsigned long long>::min())));
|
226
|
-
ASSERT_EQUAL(std::numeric_limits<unsigned long long>::max(),
|
227
|
-
detail::From_Ruby<unsigned long long>().convert(ULL2NUM(std::numeric_limits<unsigned long long>::max())));
|
228
|
-
|
229
|
-
ASSERT_EXCEPTION_CHECK(
|
230
|
-
Exception,
|
231
|
-
detail::From_Ruby<unsigned long long>().convert(rb_str_new2("bad value")),
|
232
|
-
ASSERT(std::string(ex.what()).find("no implicit conversion") == 0)
|
233
|
-
);
|
234
|
-
}
|
235
|
-
|
236
|
-
TESTCASE(bool_to_ruby)
|
237
|
-
{
|
238
|
-
ASSERT(rb_equal(Qfalse, detail::to_ruby(false)));
|
239
|
-
ASSERT(rb_equal(Qtrue, detail::to_ruby(true)));
|
240
|
-
}
|
241
|
-
|
242
|
-
TESTCASE(bool_from_ruby)
|
243
|
-
{
|
244
|
-
ASSERT_EQUAL(false, detail::From_Ruby<bool>().convert(Qfalse));
|
245
|
-
ASSERT_EQUAL(false, detail::From_Ruby<bool>().convert(Qnil));
|
246
|
-
ASSERT_EQUAL(true, detail::From_Ruby<bool>().convert(Qtrue));
|
247
|
-
ASSERT_EQUAL(true, detail::From_Ruby<bool>().convert(rb_str_new2("some string")));
|
248
|
-
ASSERT_EQUAL(true, detail::From_Ruby<bool>().convert(INT2NUM(3)));
|
249
|
-
ASSERT_EQUAL(true, detail::From_Ruby<bool>().convert(rb_float_new(3.33)));
|
250
|
-
}
|
251
|
-
|
252
|
-
TESTCASE(float_to_ruby)
|
253
|
-
{
|
254
|
-
ASSERT(rb_equal(rb_float_new(0.0f), detail::to_ruby(0.0f)));
|
255
|
-
ASSERT(rb_equal(rb_float_new(-1.0f), detail::to_ruby(-1.0f)));
|
256
|
-
ASSERT(rb_equal(rb_float_new(1.0f), detail::to_ruby(1.0f)));
|
257
|
-
ASSERT(rb_equal(rb_float_new(0.5f), detail::to_ruby(0.5f)));
|
258
|
-
ASSERT(rb_equal(rb_float_new(std::numeric_limits<float>::min()), detail::to_ruby(std::numeric_limits<float>::min())));
|
259
|
-
ASSERT(rb_equal(rb_float_new(std::numeric_limits<float>::max()), detail::to_ruby(std::numeric_limits<float>::max())));
|
260
|
-
ASSERT(Object(detail::to_ruby(std::numeric_limits<float>::quiet_NaN())).call("nan?"));
|
261
|
-
ASSERT(Object(detail::to_ruby(std::numeric_limits<float>::signaling_NaN())).call("nan?"));
|
262
|
-
ASSERT_EQUAL(rb_float_new(std::numeric_limits<float>::epsilon()),
|
263
|
-
detail::to_ruby(std::numeric_limits<float>::epsilon()));
|
264
|
-
}
|
265
|
-
|
266
|
-
TESTCASE(float_from_ruby)
|
267
|
-
{
|
268
|
-
ASSERT_EQUAL(0.0f, detail::From_Ruby<float>().convert(rb_float_new(0.0f)));
|
269
|
-
ASSERT_EQUAL(-1.0f, detail::From_Ruby<float>().convert(rb_float_new(-1.0f)));
|
270
|
-
ASSERT_EQUAL(1.0f, detail::From_Ruby<float>().convert(rb_float_new(1.0f)));
|
271
|
-
ASSERT_EQUAL(std::numeric_limits<float>::min(),
|
272
|
-
detail::From_Ruby<float>().convert(rb_float_new(std::numeric_limits<float>::min())));
|
273
|
-
ASSERT_EQUAL(std::numeric_limits<float>::max(),
|
274
|
-
detail::From_Ruby<float>().convert(rb_float_new(std::numeric_limits<float>::max())));
|
275
|
-
ASSERT(std::isnan(detail::From_Ruby<float>().convert(rb_float_new(std::numeric_limits<float>::quiet_NaN()))));
|
276
|
-
ASSERT(std::isnan(detail::From_Ruby<float>().convert(rb_float_new(std::numeric_limits<float>::signaling_NaN()))));
|
277
|
-
ASSERT_EQUAL(std::numeric_limits<float>::epsilon(),
|
278
|
-
detail::From_Ruby<float>().convert(rb_float_new(std::numeric_limits<float>::epsilon())));
|
279
|
-
|
280
|
-
ASSERT_EXCEPTION_CHECK(
|
281
|
-
Exception,
|
282
|
-
detail::From_Ruby<float>().convert(rb_str_new2("bad value")),
|
283
|
-
ASSERT_EQUAL("no implicit conversion to float from string", ex.what())
|
284
|
-
);
|
285
|
-
}
|
286
|
-
|
287
|
-
TESTCASE(double_to_ruby)
|
288
|
-
{
|
289
|
-
ASSERT(rb_equal(rb_float_new(0.0f), detail::to_ruby(0.0f)));
|
290
|
-
ASSERT(rb_equal(rb_float_new(-1.0f), detail::to_ruby(-1.0f)));
|
291
|
-
ASSERT(rb_equal(rb_float_new(1.0f), detail::to_ruby(1.0f)));
|
292
|
-
ASSERT(rb_equal(rb_float_new(0.5f), detail::to_ruby(0.5f)));
|
293
|
-
ASSERT(rb_equal(rb_float_new(std::numeric_limits<double>::min()), detail::to_ruby(std::numeric_limits<double>::min())));
|
294
|
-
ASSERT(rb_equal(rb_float_new(std::numeric_limits<double>::max()), detail::to_ruby(std::numeric_limits<double>::max())));
|
295
|
-
ASSERT(Object(detail::to_ruby(std::numeric_limits<double>::quiet_NaN())).call("nan?"));
|
296
|
-
ASSERT(Object(detail::to_ruby(std::numeric_limits<double>::signaling_NaN())).call("nan?"));
|
297
|
-
ASSERT(rb_equal(rb_float_new(std::numeric_limits<double>::epsilon()), detail::to_ruby(std::numeric_limits<double>::epsilon())));
|
298
|
-
}
|
299
|
-
|
300
|
-
TESTCASE(double_from_ruby)
|
301
|
-
{
|
302
|
-
ASSERT_EQUAL(0.0, detail::From_Ruby<double>().convert(rb_float_new(0.0)));
|
303
|
-
ASSERT_EQUAL(-1.0, detail::From_Ruby<double>().convert(rb_float_new(-1.0)));
|
304
|
-
ASSERT_EQUAL(1.0, detail::From_Ruby<double>().convert(rb_float_new(1.0)));
|
305
|
-
ASSERT_EQUAL(std::numeric_limits<double>::min(),
|
306
|
-
detail::From_Ruby<double>().convert(rb_float_new(std::numeric_limits<double>::min())));
|
307
|
-
ASSERT_EQUAL(std::numeric_limits<double>::max(),
|
308
|
-
detail::From_Ruby<double>().convert(rb_float_new(std::numeric_limits<double>::max())));
|
309
|
-
ASSERT(std::isnan(detail::From_Ruby<double>().convert(rb_float_new(std::numeric_limits<double>::quiet_NaN()))));
|
310
|
-
ASSERT(std::isnan(detail::From_Ruby<double>().convert(rb_float_new(std::numeric_limits<double>::signaling_NaN()))));
|
311
|
-
ASSERT_EQUAL(std::numeric_limits<double>::epsilon(),
|
312
|
-
detail::From_Ruby<double>().convert(rb_float_new(std::numeric_limits<double>::epsilon())));
|
313
|
-
|
314
|
-
ASSERT_EXCEPTION_CHECK(
|
315
|
-
Exception,
|
316
|
-
detail::From_Ruby<double>().convert(rb_str_new2("bad value")),
|
317
|
-
ASSERT_EQUAL("no implicit conversion to float from string", ex.what())
|
318
|
-
);
|
319
|
-
}
|
320
|
-
|
321
|
-
TESTCASE(char_const_ptr_to_ruby)
|
322
|
-
{
|
323
|
-
ASSERT(rb_equal(String("").value(), detail::to_ruby((char const *)"")));
|
324
|
-
ASSERT(rb_equal(String("foo").value(), detail::to_ruby((char const *)"foo")));
|
325
|
-
ASSERT(rb_equal(String("foo").value(), detail::to_ruby("foo")));
|
326
|
-
}
|
327
|
-
|
328
|
-
TESTCASE(char_const_array_to_ruby_symbol)
|
329
|
-
{
|
330
|
-
ASSERT(rb_equal(Symbol("foo").value(), detail::to_ruby(":foo")));
|
331
|
-
}
|
332
|
-
|
333
|
-
TESTCASE(char_const_ptr_from_ruby)
|
334
|
-
{
|
335
|
-
char const* foo = "foo";
|
336
|
-
ASSERT_EQUAL(foo, detail::From_Ruby<char const *>().convert(rb_str_new2("foo")));
|
337
|
-
ASSERT_EQUAL("", detail::From_Ruby<char const*>().convert(rb_str_new2("")));
|
338
|
-
|
339
|
-
ASSERT_EXCEPTION_CHECK(
|
340
|
-
Exception,
|
341
|
-
detail::From_Ruby<char const *>().convert(rb_float_new(32.3)),
|
342
|
-
ASSERT_EQUAL("wrong argument type Float (expected String)", ex.what())
|
343
|
-
);
|
344
|
-
}
|
345
|
-
|
346
|
-
TESTCASE(char_from_ruby_single_character_string)
|
347
|
-
{
|
348
|
-
ASSERT_EQUAL('x', detail::From_Ruby<char>().convert(rb_str_new2("x")));
|
349
|
-
}
|
350
|
-
|
351
|
-
TESTCASE(char_from_ruby_longer_string)
|
352
|
-
{
|
353
|
-
ASSERT_EXCEPTION_CHECK(
|
354
|
-
std::invalid_argument,
|
355
|
-
detail::From_Ruby<char>().convert(rb_str_new2("xy")),
|
356
|
-
ASSERT_EQUAL("from_ruby<char>: string must have length 1", ex.what())
|
357
|
-
);
|
358
|
-
|
359
|
-
ASSERT_EXCEPTION_CHECK(
|
360
|
-
Exception,
|
361
|
-
detail::From_Ruby<char>().convert(rb_float_new(47.2)),
|
362
|
-
ASSERT_EQUAL("wrong argument type Float (expected char type)", ex.what())
|
363
|
-
);
|
364
|
-
}
|
365
|
-
|
366
|
-
TESTCASE(char_from_ruby_fixnum)
|
367
|
-
{
|
368
|
-
ASSERT_EQUAL('1', detail::From_Ruby<char>().convert(INT2NUM(49)));
|
369
|
-
}
|
370
|
-
|
371
|
-
TESTCASE(unsigned_char_from_ruby)
|
372
|
-
{
|
373
|
-
unsigned char expected = -1;
|
374
|
-
ASSERT_EQUAL(expected, detail::From_Ruby<unsigned char>().convert(INT2NUM(-1)));
|
375
|
-
|
376
|
-
ASSERT_EXCEPTION_CHECK(
|
377
|
-
Exception,
|
378
|
-
detail::From_Ruby<unsigned char>().convert(rb_float_new(1.3)),
|
379
|
-
ASSERT_EQUAL("wrong argument type Float (expected char type)", ex.what())
|
380
|
-
);
|
381
|
-
}
|
382
|
-
|
383
|
-
TESTCASE(signed_char_from_ruby)
|
384
|
-
{
|
385
|
-
unsigned char expected = 10;
|
386
|
-
ASSERT_EQUAL(expected, detail::From_Ruby<signed char>().convert(INT2NUM(10)));
|
387
|
-
}
|
388
|
-
|
389
|
-
TESTCASE(char_star_from_ruby)
|
390
|
-
{
|
391
|
-
const char* expected = "my string";
|
392
|
-
ASSERT_EQUAL(expected, detail::From_Ruby<const char*>().convert(rb_str_new2("my string")));
|
393
|
-
|
394
|
-
ASSERT_EXCEPTION_CHECK(
|
395
|
-
Exception,
|
396
|
-
detail::From_Ruby<const char*>().convert(rb_float_new(11.11)),
|
397
|
-
ASSERT_EQUAL("wrong argument type Float (expected String)", ex.what())
|
398
|
-
);
|
399
|
-
}
|