Skip to content

Commit cbd9e80

Browse files
committed
Support for multiple test cases
1 parent 03f1e75 commit cbd9e80

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/com/shuzijun/leetcode/plugin/manager/CodeManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.alibaba.fastjson.JSONArray;
44
import com.alibaba.fastjson.JSONObject;
5+
import com.google.common.base.Joiner;
56
import com.intellij.openapi.fileEditor.FileEditorManager;
67
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
78
import com.intellij.openapi.project.Project;
@@ -472,12 +473,15 @@ public void run() {
472473
} else {
473474
if (jsonObject.getBoolean("run_success")) {
474475
String input = returnObj.getString("test_case");
475-
String output = jsonObject.getJSONArray("code_answer").getString(0);
476+
String output = "";
477+
if (jsonObject.getJSONArray("code_answer") != null) {
478+
output = Joiner.on("\n").join(jsonObject.getJSONArray("code_answer"));
479+
}
476480
String expected = "";
477481
if (returnObj.getJSONArray("expected_code_answer") != null && !returnObj.getJSONArray("expected_code_answer").isEmpty()) {
478-
expected = returnObj.getJSONArray("expected_code_answer").getString(0);
482+
expected = Joiner.on("\n").join(returnObj.getJSONArray("expected_code_answer"));
479483
} else if (jsonObject.getJSONArray("expected_code_answer") != null && !jsonObject.getJSONArray("expected_code_answer").isEmpty()) {
480-
expected = jsonObject.getJSONArray("expected_code_answer").getString(0);
484+
expected = Joiner.on("\n").join(jsonObject.getJSONArray("expected_code_answer"));
481485
}
482486
String outputs = StringUtils.join(jsonObject.getJSONArray("code_output"), "\n\t\t");
483487
MessageUtils.getInstance(project).showInfoMsg("info", PropertiesUtils.getInfo("test.success", input, output, expected, outputs));

0 commit comments

Comments
 (0)