1 /*
2  * Copyright 2005 Google Inc.
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 package com.google.common.geometry;
17 
18 import junit.framework.TestCase;
19 
20 public strictfp class S1AngleTest extends TestCase {
21 
22 
testBasic()23   public void testBasic() {
24     // Check that the conversion between Pi radians and 180 degrees is exact.
25     assertEquals(S1Angle.radians(Math.PI).radians(), Math.PI);
26     assertEquals(S1Angle.radians(Math.PI).degrees(), 180.0);
27     assertEquals(S1Angle.degrees(180).radians(), Math.PI);
28     assertEquals(S1Angle.degrees(180).degrees(), 180.0);
29 
30     assertEquals(S1Angle.radians(Math.PI / 2).degrees(), 90.0);
31 
32     // Check negative angles.
33     assertEquals(S1Angle.radians(-Math.PI / 2).degrees(), -90.0);
34     assertEquals(S1Angle.degrees(-45).radians(), -Math.PI / 4);
35 
36     // Check that E5/E6/E7 representations work as expected.
37     assertEquals(S1Angle.e5(2000000), S1Angle.degrees(20));
38     assertEquals(S1Angle.e6(-60000000), S1Angle.degrees(-60));
39     assertEquals(S1Angle.e7(750000000), S1Angle.degrees(75));
40     assertEquals(S1Angle.degrees(12.34567).e5(), 1234567);
41     assertEquals(S1Angle.degrees(12.345678).e6(), 12345678);
42     assertEquals(S1Angle.degrees(-12.3456789).e7(), -123456789);
43   }
44 }
45