-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakingChangeTest.java
More file actions
75 lines (51 loc) · 1.55 KB
/
MakingChangeTest.java
File metadata and controls
75 lines (51 loc) · 1.55 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import static org.junit.Assert.*;
import org.junit.Test;
import java.util.Arrays;
import java.io.IOException;
public class MakingChangeTest {
@org.junit.Test
public void greedyTest_one(){
MakingChange go = new MakingChange();
int[] arr = {25, 10, 1};
if (Arrays.equals(go.greedy(36), arr)) {
System.out.println("Same");
}
else {
System.out.println("Not same");
}
}
@org.junit.Test
public void greedyTest_two() {
MakingChange go = new MakingChange();
int amount = 20;
if (amount < 0) {
throw new IllegalArgumentException("negative input is not allowed");
} else if (amount > 0) {
go.greedy(amount);
}
}
@org.junit.Test
public void GreedyTest_three() {
//MakingChange go = new MakingChange();
int[] arr = {10, 0, 5, 1};
try {
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 0) {
throw new IOException("one of the array elements is empty");
}
}
} catch (IOException e) {
System.out.println("at least one of the array elements is empty");
}
}
@org.junit.Test
public void greedyTest_four() {
MakingChange go = new MakingChange();
int amount = -9;
if (amount < 0) {
throw new IllegalArgumentException("negative input is not allowed");
} else if (amount > 0) {
go.greedy(amount);
}
}
}