Skip to content

Commit aed785c

Browse files
Test for finding prefix-suffix table
1 parent 0cf9326 commit aed785c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.jwetherell.algorithms.strings.test;
2+
3+
import com.jwetherell.algorithms.strings.StringInformations;
4+
import org.junit.Test;
5+
6+
import java.util.ArrayList;
7+
import java.util.Arrays;
8+
import java.util.List;
9+
10+
import static org.junit.Assert.*;
11+
12+
public class StringInformationTest {
13+
14+
@Test
15+
public void getPrefixSuffixes() throws Exception {
16+
List<Object[]> data = Arrays.asList(new Object[][]{
17+
{"", new ArrayList<Integer>()},
18+
{"a", Arrays.asList(0)},
19+
{"aaa", Arrays.asList(0, 1, 2)},
20+
{"abbabb", Arrays.asList(0, 0, 0, 1, 2, 3)},
21+
{"bbabbbbaab", Arrays.asList(0, 1, 0, 1, 2, 2, 2, 3, 0, 1)},
22+
{
23+
"( ͡° ͜ʖ ͡° )( ͡° a( ͡° ͜ʖ ͡°",
24+
Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
25+
}
26+
});
27+
for(Object[] testCase: data) {
28+
String input = (String) testCase[0];
29+
List<Integer> expected = (List<Integer>) testCase[1];
30+
assertEquals(expected, StringInformations.getPrefSufTable(input));
31+
}
32+
}
33+
34+
}

0 commit comments

Comments
 (0)