]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/ruby/red-arrow/test/test-decimal128.rb
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / ruby / red-arrow / test / test-decimal128.rb
CommitLineData
1d09f67e
TL
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18class Decimal128Test < Test::Unit::TestCase
19 sub_test_case("instance methods") do
20 def setup
21 @decimal128 = Arrow::Decimal128.new("10.1")
22 end
23
24 sub_test_case("#==") do
25 test("Arrow::Decimal128") do
26 assert do
27 @decimal128 == @decimal128
28 end
29 end
30
31 test("not Arrow::Decimal128") do
32 assert do
33 not (@decimal128 == 10.1)
34 end
35 end
36 end
37
38 sub_test_case("#!=") do
39 test("Arrow::Decimal128") do
40 assert do
41 not (@decimal128 != @decimal128)
42 end
43 end
44
45 test("not Arrow::Decimal128") do
46 assert do
47 @decimal128 != 10.1
48 end
49 end
50 end
51
52 sub_test_case("#to_s") do
53 test("default") do
54 assert_equal("101",
55 @decimal128.to_s)
56 end
57
58 test("scale") do
59 assert_equal("10.1",
60 @decimal128.to_s(1))
61 end
62 end
63
64 test("#abs") do
65 decimal128 = Arrow::Decimal128.new("-10.1")
66 assert_equal([
67 Arrow::Decimal128.new("-10.1"),
68 Arrow::Decimal128.new("10.1"),
69 ],
70 [
71 decimal128,
72 decimal128.abs,
73 ])
74 end
75
76 test("#abs!") do
77 decimal128 = Arrow::Decimal128.new("-10.1")
78 decimal128.abs!
79 assert_equal(Arrow::Decimal128.new("10.1"),
80 decimal128)
81 end
82
83 test("#negate") do
84 decimal128 = Arrow::Decimal128.new("-10.1")
85 assert_equal([
86 Arrow::Decimal128.new("-10.1"),
87 Arrow::Decimal128.new("10.1"),
88 ],
89 [
90 decimal128,
91 decimal128.negate,
92 ])
93 end
94
95 test("#negate!") do
96 decimal128 = Arrow::Decimal128.new("-10.1")
97 decimal128.negate!
98 assert_equal(Arrow::Decimal128.new("10.1"),
99 decimal128)
100 end
101 end
102end