-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTester.java
More file actions
35 lines (32 loc) · 1.11 KB
/
Tester.java
File metadata and controls
35 lines (32 loc) · 1.11 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
package Substrings;
/**
* Author: Hymeis
* Date Created: Feb. 5, 2025
* Program description: The driver for testing the algorithms and
* functions
*/
public class Tester {
public static void main(String[] args) {
Util utilTester = new Util();
String[][] testCases = {
{"Hymeis", "ei"},
{"Hello World", "World"},
{"abc", "d"},
{"abcd", "bc"},
{"aaaaa", "aaa"},
};
System.out.println("===== Substring Index Tests =====");
for (String[] pair : testCases) {
String longer = pair[0];
String shorter = pair[1];
int expectedIndex = longer.indexOf(shorter);
int actualIndex = utilTester.indexOf(longer, shorter);
boolean testPassed = (expectedIndex == actualIndex);
System.out.printf(
"Longer: \"%s\" | Shorter: \"%s\" \n\tExpected: %d | Actual: %d \n\tTest Passed: %b%n",
longer, shorter, expectedIndex, actualIndex, testPassed
);
}
System.out.println("=================================");
}
}