MCPcopy Create free account
hub / github.com/apache/arrow / HalfFloatTest

Class HalfFloatTest

ruby/red-arrow/test/test-half-float.rb:18–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16# under the License.
17
18class HalfFloatTest < Test::Unit::TestCase
19 sub_test_case(".new") do
20 test("Array") do
21 positive_infinity = Arrow::HalfFloat.new(0b1, 0b11111, 0b0000000000)
22 assert_equal([0b1, 0b11111, 0b0000000000],
23 [
24 positive_infinity.sign,
25 positive_infinity.exponent,
26 positive_infinity.fraction,
27 ])
28 end
29
30 test("Integer - 0") do
31 zero = Arrow::HalfFloat.new(0)
32 assert_equal([0b0, 0b00000, 0b0000000000],
33 [
34 zero.sign,
35 zero.exponent,
36 zero.fraction,
37 ])
38 end
39
40 test("Integer - +infinity") do
41 positive_infinity = Arrow::HalfFloat.new(0x7c00)
42 assert_equal([0b0, 0b11111, 0b0000000000],
43 [
44 positive_infinity.sign,
45 positive_infinity.exponent,
46 positive_infinity.fraction,
47 ])
48 end
49
50 test("Integer - -infinity") do
51 negative_infinity = Arrow::HalfFloat.new(0xfc00)
52 assert_equal([0b1, 0b11111, 0b0000000000],
53 [
54 negative_infinity.sign,
55 negative_infinity.exponent,
56 negative_infinity.fraction,
57 ])
58 end
59
60 test("Integer - 1/3") do
61 one_thirds = Arrow::HalfFloat.new(0x3555)
62 assert_equal([0b0, 0b01101, 0b0101010101],
63 [
64 one_thirds.sign,
65 one_thirds.exponent,
66 one_thirds.fraction,
67 ])
68 end
69
70 test("Float - 0") do
71 zero = Arrow::HalfFloat.new(0.0)
72 assert_equal([0b0, 0b00000, 0b0000000000],
73 [
74 zero.sign,
75 zero.exponent,

Callers

nothing calls this directly

Calls 3

testFunction · 0.85
signMethod · 0.80
newMethod · 0.45

Tested by

no test coverage detected