Skip to content

Commit 835ad35

Browse files
authored
Support for multiple test cases
Support for multiple test cases fix #123
2 parents 25f995b + cbd9e80 commit 835ad35

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;
@@ -471,12 +472,15 @@ public void run() {
471472
} else {
472473
if (jsonObject.getBoolean("run_success")) {
473474
String input = returnObj.getString("test_case");
474-
String output = jsonObject.getJSONArray("code_answer").getString(0);
475+
String output = "";
476+
if (jsonObject.getJSONArray("code_answer") != null) {
477+
output = Joiner.on("\n").join(jsonObject.getJSONArray("code_answer"));
478+
}
475479
String expected = "";
476480
if (returnObj.getJSONArray("expected_code_answer") != null && !returnObj.getJSONArray("expected_code_answer").isEmpty()) {
477-
expected = returnObj.getJSONArray("expected_code_answer").getString(0);
481+
expected = Joiner.on("\n").join(returnObj.getJSONArray("expected_code_answer"));
478482
} else if (jsonObject.getJSONArray("expected_code_answer") != null && !jsonObject.getJSONArray("expected_code_answer").isEmpty()) {
479-
expected = jsonObject.getJSONArray("expected_code_answer").getString(0);
483+
expected = Joiner.on("\n").join(jsonObject.getJSONArray("expected_code_answer"));
480484
}
481485
String outputs = StringUtils.join(jsonObject.getJSONArray("code_output"), "\n\t\t");
482486
MessageUtils.getInstance(project).showInfoMsg("info", PropertiesUtils.getInfo("test.success", input, output, expected, outputs));

0 commit comments

Comments
 (0)