Skip to content

Fix the bug that quotes are not accepted in test cases #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ export async function testSolution(uri?: vscode.Uri): Promise<void> {
ignoreFocusOut: true,
});
if (testString) {
result = await leetCodeExecutor.testSolution(filePath, testString.replace(/"/g, ""));
result = await leetCodeExecutor.testSolution(filePath, testString);
}
break;
case ":file":
const testFile: vscode.Uri[] | undefined = await showFileSelectDialog();
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.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/leetCodeExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class LeetCodeExecutor {

public async testSolution(filePath: string, testString?: string): Promise<string> {
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}"`]);
}
Expand Down