• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.uwb.correction;
18 
19 import static java.lang.Math.abs;
20 
21 import com.android.server.uwb.correction.math.AoaVector;
22 import com.android.server.uwb.correction.math.SphericalVector;
23 import com.android.server.uwb.correction.math.Vector3;
24 
25 import org.junit.Assert;
26 
27 public final class TestHelpers {
TestHelpers()28     private TestHelpers() {}
29 
30     // Asserts that a value is within 0.001, to account for floating point rounding errors.
assertClose(double v, double c)31     public static void assertClose(double v, double c) {
32         Assert.assertTrue(abs(v - c) < 0.001);
33     }
34 
35     public static void assertClose(SphericalVector v, SphericalVector c) {
36         assertClose(v.azimuth, c.azimuth);
37         assertClose(v.elevation, c.elevation);
38         assertClose(v.distance, c.distance);
39     }
40 
41     public static void assertClose(AoaVector v, AoaVector c) {
42         assertClose(v.azimuth, c.azimuth);
43         assertClose(v.elevation, c.elevation);
44         assertClose(v.distance, c.distance);
45     }
46 
47     public static void assertClose(Vector3 v, Vector3 c) {
48         assertClose(v.x, c.x);
49         assertClose(v.y, c.y);
50         assertClose(v.z, c.z);
51     }
52 }
53