diff --git a/src/commands/test.ts b/src/commands/test.ts index 548fa490..565c1c1a 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -59,7 +59,7 @@ export async function testSolution(uri?: vscode.Uri): Promise { ignoreFocusOut: true, }); if (testString) { - result = await leetCodeExecutor.testSolution(filePath, testString.replace(/"/g, "")); + result = await leetCodeExecutor.testSolution(filePath, testString); } break; case ":file": @@ -67,7 +67,7 @@ export async function testSolution(uri?: vscode.Uri): Promise { if (testFile && testFile.length) { const input: string = await fse.readFile(testFile[0].fsPath, "utf-8"); if (input.trim()) { - result = await leetCodeExecutor.testSolution(filePath, input.replace(/"/g, "").replace(/\r?\n/g, "\\n")); + result = await leetCodeExecutor.testSolution(filePath, input.replace(/\r?\n/g, "\\n")); } else { vscode.window.showErrorMessage("The selected test file must not be empty."); } diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts index 1ee5ab4a..d4cdfea0 100644 --- a/src/leetCodeExecutor.ts +++ b/src/leetCodeExecutor.ts @@ -96,7 +96,7 @@ class LeetCodeExecutor { public async testSolution(filePath: string, testString?: string): Promise { if (testString) { - return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`, "-t", `"${testString}"`]); + return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`, "-t", `'${testString}'`]); } return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`]); }