-
-
Notifications
You must be signed in to change notification settings - Fork 312
Expand file tree
/
Copy pathBuySellStocksTest.java
More file actions
46 lines (34 loc) · 986 Bytes
/
BuySellStocksTest.java
File metadata and controls
46 lines (34 loc) · 986 Bytes
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
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BuySellStocksTest {
@Test
void testEmptyArray() {
int[] prices = {};
int result = BuySellStocks.maxProfit(prices);
assertEquals(0, result);
}
@Test
void testUpdateBuyPrice() {
int[] prices = {8, 5, 10};
int result = BuySellStocks.maxProfit(prices);
assertEquals(5, result);
}
@Test
void testUpdateProfit() {
int[] prices = {1, 5, 10};
int result = BuySellStocks.maxProfit(prices);
assertEquals(9, result);
}
@Test
void testNoUpdateProfit() {
int[] prices = {1, 10, 5};
int result = BuySellStocks.maxProfit(prices);
assertEquals(9, result);
}
@Test
void testMixedUpdates() {
int[] prices = {10, 2, 7, 3, 8, 4};
int result = BuySellStocks.maxProfit(prices);
assertEquals(6, result);
}
}