]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/java/vector/src/test/java/org/apache/arrow/vector/util/TestValidator.java
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org
.apache
.arrow
.vector
.util
;
20 import static org
.apache
.arrow
.vector
.util
.Validator
.equalEnough
;
21 import static org
.junit
.Assert
.assertFalse
;
22 import static org
.junit
.Assert
.assertTrue
;
24 import org
.junit
.Test
;
26 public class TestValidator
{
29 public void testFloatComp() {
30 assertTrue(equalEnough(912.4140000000002F
, 912.414F
));
31 assertTrue(equalEnough(912.4140000000002D
, 912.414D
));
32 assertTrue(equalEnough(912.414F
, 912.4140000000002F
));
33 assertTrue(equalEnough(912.414D
, 912.4140000000002D
));
34 assertFalse(equalEnough(912.414D
, 912.4140001D
));
35 assertFalse(equalEnough(null, 912.414D
));
36 assertTrue(equalEnough((Float
) null, null));
37 assertTrue(equalEnough((Double
) null, null));
38 assertFalse(equalEnough(912.414D
, null));
39 assertFalse(equalEnough(Double
.MAX_VALUE
, Double
.MIN_VALUE
));
40 assertFalse(equalEnough(Double
.MIN_VALUE
, Double
.MAX_VALUE
));
41 assertTrue(equalEnough(Double
.MAX_VALUE
, Double
.MAX_VALUE
));
42 assertTrue(equalEnough(Double
.MIN_VALUE
, Double
.MIN_VALUE
));
43 assertTrue(equalEnough(Double
.NEGATIVE_INFINITY
, Double
.NEGATIVE_INFINITY
));
44 assertFalse(equalEnough(Double
.NEGATIVE_INFINITY
, Double
.POSITIVE_INFINITY
));
45 assertTrue(equalEnough(Double
.NaN
, Double
.NaN
));
46 assertFalse(equalEnough(1.0, Double
.NaN
));
47 assertFalse(equalEnough(Float
.MAX_VALUE
, Float
.MIN_VALUE
));
48 assertFalse(equalEnough(Float
.MIN_VALUE
, Float
.MAX_VALUE
));
49 assertTrue(equalEnough(Float
.MAX_VALUE
, Float
.MAX_VALUE
));
50 assertTrue(equalEnough(Float
.MIN_VALUE
, Float
.MIN_VALUE
));
51 assertTrue(equalEnough(Float
.NEGATIVE_INFINITY
, Float
.NEGATIVE_INFINITY
));
52 assertFalse(equalEnough(Float
.NEGATIVE_INFINITY
, Float
.POSITIVE_INFINITY
));
53 assertTrue(equalEnough(Float
.NaN
, Float
.NaN
));
54 assertFalse(equalEnough(1.0F
, Float
.NaN
));