forked from prmr/DesignBook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCos.java
More file actions
60 lines (51 loc) · 1.47 KB
/
TestCos.java
File metadata and controls
60 lines (51 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
* Companion code for the book "Introduction to Software Design with Java"
* by Martin P. Robillard.
*
* Copyright (C) 2019 by Martin P. Robillard
*
* This code is licensed under a Creative Commons
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
*
* See http://creativecommons.org/licenses/by-nc-nd/4.0/
*******************************************************************************/
package chapter5;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class TestCos
{
private static final double ZERO = 0.0;
private static final double QUARTER = Math.PI/2.0;
private static final double HALF = Math.PI;
private static final double THREE_QUARTERS = Math.PI * 1.5;
@Test
public void testCos_NaN()
{
assertEquals(Double.NaN, Math.cos(Double.NaN));
}
@Test
public void testCos_Infinity()
{
assertEquals(Double.NaN, Math.cos(Double.POSITIVE_INFINITY));
}
@Test
public void testCos_Zero()
{
assertEquals(1.0, Math.cos(ZERO), Math.ulp(1.0));
}
@Test
public void testCos_Quarter()
{
assertEquals(0.0, Math.cos(QUARTER), Math.ulp(0.0));
}
@Test
public void testCos_Half()
{
assertEquals(-1.0, Math.cos(HALF), Math.ulp(-1.0));
}
@Test
public void testCos_ThreeQuaters()
{
assertEquals(0.0, Math.cos(THREE_QUARTERS), Math.ulp(0.0));
}
}