-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFractionTester.java
More file actions
47 lines (36 loc) · 1.26 KB
/
Copy pathFractionTester.java
File metadata and controls
47 lines (36 loc) · 1.26 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
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class FractionTester {
private Fraction newFraction, otherFraction, thirdFraction;
@Before
public void setUp(){
newFraction = new Fraction(2, 4);
otherFraction = new Fraction(5, 5);
thirdFraction = new Fraction(8, 2);
}
@Test
public void testMultiplyEm() {
assertEquals("Faulty math when multiplying", newFraction.multiplyEm(otherFraction), new Fraction (1, 2));
}
@Test
public void testAddEm() {
assertEquals("Faulty math when adding", newFraction.addEm(otherFraction), new Fraction (1, 2));
}
@Test
public void testTakeRecip(){
assertEquals("Error when taking reciprical", thirdFraction.takeRecip(), new Fraction (1, 4));
}
@Test
public void testSimplifyWhenNumeratorIsBigger(){
assertEquals("Error when simplifying when numerator is bigger", newFraction.simplify(), new Fraction (1, 2));
}
@Test
public void testSimplifyWhenDenominatorIsBigger(){
assertEquals("Error when simplifying when denominator is bigger", thirdFraction.simplify(), new Fraction (0, 0));
}
@Test
public void testSimplifyWhenDenomAndNumerAreSame(){
assertEquals("Error when simplifying when denominator == numerator", otherFraction.simplify(), new Fraction (0, 0));
}
}