Skip to content

Commit

Permalink
Update regex for cpp arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJunny committed Dec 7, 2024
1 parent a4d753d commit 28ce87e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function fillFunctionCall(
paramTypes: string[],
) {
const regex =
/^\[\s*(?:(?:"[^"]*"|\d+\.\d*|\d+|'[^']*'|true|false|null)(\s*,\s*(?:"[^"]*"|\d+\.\d*|\d+|'[^']*'|true|false|null))*)?\s*\]$/;
/^\[\s*(?:(?:"[^"]*"|-?\d+\.\d*|-?\d+|'[^']*'|true|false|null)(\s*,\s*(?:"[^"]*"|-?\d+\.\d*|-?\d+|'[^']*'|true|false|null))*)?\s*\]$/;
const inputs = exampleInputs.split("\n");

for (let i = 0; i < inputs.length; i++) {
Expand All @@ -52,6 +52,7 @@ export function fillFunctionCall(
if (language === "cpp" && regex.test(input)) {
const temp = input.slice(1, -1).split(",");
const newInput = `{${temp.join(",").replaceAll(`'`, `"`)}}`;
console.log(newInput);
header = header.replace(".", newInput);
// convert test case booleans to capitalized for Python
} else if (language === "python" && paramTypes[i] === "boolean")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default protectedProcedure
headerType === "stringArr" ||
headerType === "doubleArr"
) {
boilerPlate = `template<typename T>ostream& operator<<(ostream& os, const vector<T>& vec) {os << "{";for (size_t i = 0;i < vec.size(); ++i) {os << vec[i]; if (i != vec.size() - 1) os << ", ";}os << "}";return os;}int main() {${funcsToExecuteString};return 0;}`;
boilerPlate = `template<typename T>ostream& operator<<(ostream& os, const vector<T>& vec) {os << "{";for (size_t i = 0;i < vec.size(); ++i) {os << vec[i]; if (i != vec.size() - 1) os << ", ";}os << "}";return os;}int main() {${funcsToExecuteString}return 0;}`;
} else boilerPlate = `int main(){${funcsToExecuteString}}`;
}

Expand Down Expand Up @@ -152,7 +152,6 @@ export default protectedProcedure
});
}
}

const maxOutputs = Math.max(expectedOutputs.length, stdOuts.length);
let passCount = 0;
for (let i = 0; i < maxOutputs; i++)
Expand Down

0 comments on commit 28ce87e

Please sign in to comment.