Repository navigation
Expand file tree
/
Copy pathCoinChange322Test.java
More file actions
107 lines (77 loc) · 2.85 KB
/
Copy pathCoinChange322Test.java
File metadata and controls
107 lines (77 loc) · 2.85 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.leetcode.medium;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
public class CoinChange322Test {
private CoinChange322 solution;
@BeforeEach
void setUp() {
solution = new CoinChange322();
}
@Test
void testCoinChangeMemoization_Example1() {
int[] coins = {1, 2, 5};
int amount = 11;
int expected = 3;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeMemoization(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeMemoization_Example2() {
int[] coins = {2};
int amount = 3;
int expected = -1;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeMemoization(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeMemoization_Example3() {
int[] coins = {1};
int amount = 0;
int expected = 0;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeMemoization(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeMemoization_Example4() {
int[] coins = {1, 2, 5};
int amount = 100;
int expected = 20;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeMemoization(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeTabulation_Example1() {
int[] coins = {1, 2, 5};
int amount = 11;
int expected = 3;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeTabulation(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeTabulation_Example2() {
int[] coins = {2};
int amount = 3;
int expected = -1;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeTabulation(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeTabulation_Example3() {
int[] coins = {1};
int amount = 0;
int expected = 0;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeTabulation(coins, amount));
assertEquals(expected, result);
}
@Test
void testCoinChangeTabulation_Example4() {
int[] coins = {1, 2, 5};
int amount = 100;
int expected = 20;
int result = assertTimeoutPreemptively(Duration.ofMillis(100), () -> solution.coinChangeTabulation(coins, amount));
assertEquals(expected, result);
}
}