1/*
2 * Copyright (C) 2007 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
17package android.util;
18
19import junit.framework.TestCase;
20import android.test.suitebuilder.annotation.SmallTest;
21
22public class FloatMathTest extends TestCase {
23
24    @SmallTest
25    public void testSqrt() {
26        assertEquals(7, FloatMath.sqrt(49), 0);
27        assertEquals(10, FloatMath.sqrt(100), 0);
28        assertEquals(0, FloatMath.sqrt(0), 0);
29        assertEquals(1, FloatMath.sqrt(1), 0);
30    }
31
32    @SmallTest
33    public void testFloor() {
34        assertEquals(78, FloatMath.floor(78.89f), 0);
35        assertEquals(-79, FloatMath.floor(-78.89f), 0);
36    }
37
38    @SmallTest
39    public void testCeil() {
40        assertEquals(79, FloatMath.ceil(78.89f), 0);
41        assertEquals(-78, FloatMath.ceil(-78.89f), 0);
42    }
43
44    @SmallTest
45    public void testSin() {
46        assertEquals(0.0, FloatMath.sin(0), 0);
47        assertEquals(0.8414709848078965f, FloatMath.sin(1), 0);
48    }
49
50    @SmallTest
51    public void testCos() {
52        assertEquals(1.0f, FloatMath.cos(0), 0);
53        assertEquals(0.5403023058681398f, FloatMath.cos(1), 0);
54    }
55}
56