forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongestCommonPrefixTest.java
More file actions
29 lines (24 loc) · 1.06 KB
/
LongestCommonPrefixTest.java
File metadata and controls
29 lines (24 loc) · 1.06 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
package com.examplehub.leetcode.easy;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class LongestCommonPrefixTest {
@Test
void testSolution1() {
assertEquals("fl", LongestCommonPrefix.solution1(new String[] {"flower", "flow", "flight"}));
assertEquals(
"flower",
LongestCommonPrefix.solution1(new String[] {"flower", "flower", "flower", "flower"}));
assertEquals("", LongestCommonPrefix.solution1(new String[] {"dog", "racecar", "car"}));
assertEquals("a", LongestCommonPrefix.solution1(new String[] {"a"}));
assertEquals("", LongestCommonPrefix.solution1(null));
}
@Test
void testSolution2() {
assertEquals("fl", LongestCommonPrefix.solution2(new String[] {"flower", "flow", "flight"}));
assertEquals(
"flower",
LongestCommonPrefix.solution2(new String[] {"flower", "flower", "flower", "flower"}));
assertEquals("", LongestCommonPrefix.solution2(new String[] {"dog", "racecar", "car"}));
assertEquals("a", LongestCommonPrefix.solution2(new String[] {"a"}));
}
}