]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | class Decimal256Test < Test::Unit::TestCase | |
19 | sub_test_case("instance methods") do | |
20 | def setup | |
21 | @decimal256 = Arrow::Decimal256.new("10.1") | |
22 | end | |
23 | ||
24 | sub_test_case("#==") do | |
25 | test("Arrow::Decimal256") do | |
26 | assert do | |
27 | @decimal256 == @decimal256 | |
28 | end | |
29 | end | |
30 | ||
31 | test("not Arrow::Decimal256") do | |
32 | assert do | |
33 | not (@decimal256 == 10.1) | |
34 | end | |
35 | end | |
36 | end | |
37 | ||
38 | sub_test_case("#!=") do | |
39 | test("Arrow::Decimal256") do | |
40 | assert do | |
41 | not (@decimal256 != @decimal256) | |
42 | end | |
43 | end | |
44 | ||
45 | test("not Arrow::Decimal256") do | |
46 | assert do | |
47 | @decimal256 != 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 | @decimal256.to_s) | |
56 | end | |
57 | ||
58 | test("scale") do | |
59 | assert_equal("10.1", | |
60 | @decimal256.to_s(1)) | |
61 | end | |
62 | end | |
63 | ||
64 | test("#abs") do | |
65 | decimal256 = Arrow::Decimal256.new("-10.1") | |
66 | assert_equal([ | |
67 | Arrow::Decimal256.new("-10.1"), | |
68 | Arrow::Decimal256.new("10.1"), | |
69 | ], | |
70 | [ | |
71 | decimal256, | |
72 | decimal256.abs, | |
73 | ]) | |
74 | end | |
75 | ||
76 | test("#abs!") do | |
77 | decimal256 = Arrow::Decimal256.new("-10.1") | |
78 | decimal256.abs! | |
79 | assert_equal(Arrow::Decimal256.new("10.1"), | |
80 | decimal256) | |
81 | end | |
82 | ||
83 | test("#negate") do | |
84 | decimal256 = Arrow::Decimal256.new("-10.1") | |
85 | assert_equal([ | |
86 | Arrow::Decimal256.new("-10.1"), | |
87 | Arrow::Decimal256.new("10.1"), | |
88 | ], | |
89 | [ | |
90 | decimal256, | |
91 | decimal256.negate, | |
92 | ]) | |
93 | end | |
94 | ||
95 | test("#negate!") do | |
96 | decimal256 = Arrow::Decimal256.new("-10.1") | |
97 | decimal256.negate! | |
98 | assert_equal(Arrow::Decimal256.new("10.1"), | |
99 | decimal256) | |
100 | end | |
101 | end | |
102 | end |