Skip to content

Commit e8da833

Browse files
authored
Fix the bug that quotes are not accepted in test cases (LeetCode-OpenSource#111)
1 parent cae75fe commit e8da833

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/commands/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ export async function testSolution(uri?: vscode.Uri): Promise<void> {
5959
ignoreFocusOut: true,
6060
});
6161
if (testString) {
62-
result = await leetCodeExecutor.testSolution(filePath, testString.replace(/"/g, ""));
62+
result = await leetCodeExecutor.testSolution(filePath, testString);
6363
}
6464
break;
6565
case ":file":
6666
const testFile: vscode.Uri[] | undefined = await showFileSelectDialog();
6767
if (testFile && testFile.length) {
6868
const input: string = await fse.readFile(testFile[0].fsPath, "utf-8");
6969
if (input.trim()) {
70-
result = await leetCodeExecutor.testSolution(filePath, input.replace(/"/g, "").replace(/\r?\n/g, "\\n"));
70+
result = await leetCodeExecutor.testSolution(filePath, input.replace(/\r?\n/g, "\\n"));
7171
} else {
7272
vscode.window.showErrorMessage("The selected test file must not be empty.");
7373
}

src/leetCodeExecutor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class LeetCodeExecutor {
9696

9797
public async testSolution(filePath: string, testString?: string): Promise<string> {
9898
if (testString) {
99-
return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`, "-t", `"${testString}"`]);
99+
return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`, "-t", `'${testString}'`]);
100100
}
101101
return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`]);
102102
}

0 commit comments

Comments
 (0)