forked from nus-tic2002-2021/duke
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickTest.java
More file actions
81 lines (72 loc) · 2.91 KB
/
Copy pathQuickTest.java
File metadata and controls
81 lines (72 loc) · 2.91 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
import ui.WhatsAppStyleChatUI;
import java.lang.reflect.Method;
/**
* Quick test for specific issues found by automated tester
*/
public class QuickTest {
public static void main(String[] args) {
try {
WhatsAppStyleChatUI chatUI = new WhatsAppStyleChatUI();
Method preprocessMethod = WhatsAppStyleChatUI.class.getDeclaredMethod("preprocessInput", String.class);
preprocessMethod.setAccessible(true);
System.out.println("🔧 Testing Specific Fixes");
System.out.println("========================");
String[] problemCases = {
// Cases that were failing
"due project due friday",
"due task due tomorrow",
"due insurance claim due friday",
"due paper due monday",
"",
" ",
"appointment",
"meeting",
"deadline",
"appointment appointment appointment",
"call mom by morning",
"meeting tomorrow at 2pm",
"tell baby a joke",
"buy milk"
};
for (String testCase : problemCases) {
try {
String result = (String) preprocessMethod.invoke(chatUI, testCase);
System.out.printf("Input: \"%s\"\n", testCase);
System.out.printf("Output: \"%s\"\n", result);
System.out.printf("Valid: %s\n", isValidOutput(result));
System.out.println();
} catch (Exception e) {
System.out.printf("Input: \"%s\"\n", testCase);
System.out.printf("ERROR: %s\n", e.getMessage());
System.out.println();
}
}
} catch (Exception e) {
System.err.println("Test failed: " + e.getMessage());
e.printStackTrace();
}
}
private static boolean isValidOutput(String output) {
if (output == null || output.trim().isEmpty()) {
return false;
}
String[] parts = output.trim().split(" ", 2);
String cmdType = parts[0].toLowerCase();
switch (cmdType) {
case "event":
return parts.length > 1 && parts[1].contains("/at") &&
!parts[1].startsWith("/at") && !parts[1].endsWith("/at");
case "deadline":
return parts.length > 1 && parts[1].contains("/by") &&
!parts[1].startsWith("/by") && !parts[1].endsWith("/by");
case "todo":
return parts.length > 1 && !parts[1].trim().isEmpty();
case "help":
case "list":
case "search":
return true;
default:
return false;
}
}
}