Skip to content

Commit 0a02e61

Browse files
committed
Update template C++ test code
1 parent 8193e48 commit 0a02e61

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ curl -X POST http://localhost:3000/execute \
9999
-H "Content-Type: application/json" \
100100
-d '{
101101
"language": "cpp",
102-
"code": "int add(int a, int b) { return a + b; }\n",
102+
"code": "#include <iostream>\nusing namespace std;\nint main(){\ncout<<\"Hola!\n\";\nreturn 0;\n}\n",
103103
"runTests": true,
104-
"testCode": "extern int add(int a, int b);\n#include <cxxtest/TestSuite.h>\n\nclass AddTestSuite : public CxxTest::TestSuite {\npublic:\n void testAddPositiveNumbers() { TS_ASSERT_EQUALS(add(2, 3), 5); }\n void testAddNegativeNumbers() { TS_ASSERT_EQUALS(add(-1, 1), 0); }\n};"
104+
"testCode": "#include <cxxtest/TestSuite.h>\n#include <sstream>\n#include <iostream>\n#define main program_main\n#include \"program.cpp\"\n#undef main\nclass codewit_test : public CxxTest::TestSuite {\npublic:\nvoid testHolaMundo(){\nstd::stringstream out;\nstd::streambuf* cout_buf = std::cout.rdbuf();\nstd::cout.rdbuf(out.rdbuf());\nprogram_main();\nstd::cout.rdbuf(cout_buf);\nTS_ASSERT_EQUALS(\"Hola!\n\",out.str());}};\n"
105105
}'
106106
```
107107

codeeval.http

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Cookie: connect.sid=suhvferkuhvikerv
3333

3434
{
3535
"language": "cpp",
36-
"code": "int add(int a, int b) { return a + b; }\n",
36+
"code": "#include <iostream>\nusing namespace std;\nint main(){\ncout<<\"Hola!\n\";\nreturn 0;\n}\n",
3737
"runTests": true,
38-
"testCode": "extern int add(int a, int b);\n#include <cxxtest/TestSuite.h>\n\nclass AddTestSuite : public CxxTest::TestSuite {\npublic:\n void testAddPositiveNumbers() { TS_ASSERT_EQUALS(add(2, 3), 5); }\n void testAddNegativeNumbers() { TS_ASSERT_EQUALS(add(-1, 1), 0); }\n};"
38+
"testCode": "#include <cxxtest/TestSuite.h>\n#include <sstream>\n#include <iostream>\n#define main program_main\n#include \"program.cpp\"\n#undef main\nclass codewit_test : public CxxTest::TestSuite {\npublic:\nvoid testHolaMundo(){\nstd::stringstream out;\nstd::streambuf* cout_buf = std::cout.rdbuf();\nstd::cout.rdbuf(out.rdbuf());\nprogram_main();\nstd::cout.rdbuf(cout_buf);\nTS_ASSERT_EQUALS(\"Hola!\n\",out.str());}};\n"
3939
}
4040

4141
###

executor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ async function generateCppTestRunner(uniqueDir) {
154154
const testHeaderPath = path.join(uniqueDir, 'test_program.h');
155155
const runnerCppPath = path.join(uniqueDir, 'runner.cpp');
156156
const runnerExecutablePath = path.join(uniqueDir, 'runner');
157-
const mainCppPath = path.join(uniqueDir, 'program.cpp');
158157

159158
await compileCode('cxxtestgen', ['--error-printer', '-o', runnerCppPath, testHeaderPath], uniqueDir);
160159
await compileCode('g++', ['-std=c++20', '-o', runnerExecutablePath, runnerCppPath], uniqueDir);

0 commit comments

Comments
 (0)