From 1f205079e9a8c2a6a9c354a8f9670c166e0b4a63 Mon Sep 17 00:00:00 2001 From: "sheche@microsoft.com" Date: Sat, 9 Feb 2019 21:03:42 +0800 Subject: [PATCH] Fix the bug that quotes are not accepted in test cases --- src/commands/test.ts | 4 ++-- src/leetCodeExecutor.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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}"`]); }