Skip to content

Commit 29b158a

Browse files
committed
Initial commit: basic CP local judge in C++
0 parents  commit 29b158a

File tree

13 files changed

+143
-0
lines changed

13 files changed

+143
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.vscode/c_cpp_properties.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "macos-clang-arm64",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"compilerPath": "/usr/bin/clang",
9+
"cStandard": "${default}",
10+
"cppStandard": "${default}",
11+
"intelliSenseMode": "macos-clang-arm64",
12+
"compilerArgs": [
13+
""
14+
]
15+
}
16+
],
17+
"version": 4
18+
}

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "C/C++ Runner: Debug Session",
6+
"type": "lldb",
7+
"request": "launch",
8+
"args": [],
9+
"cwd": "/Users/jaydev/Documents/cpJudge",
10+
"program": "/Users/jaydev/Documents/cpJudge/build/Debug/outDebug"
11+
}
12+
]
13+
}

.vscode/settings.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"C_Cpp_Runner.cCompilerPath": "clang",
3+
"C_Cpp_Runner.cppCompilerPath": "clang++",
4+
"C_Cpp_Runner.debuggerPath": "lldb",
5+
"C_Cpp_Runner.cStandard": "",
6+
"C_Cpp_Runner.cppStandard": "",
7+
"C_Cpp_Runner.msvcBatchPath": "",
8+
"C_Cpp_Runner.useMsvc": false,
9+
"C_Cpp_Runner.warnings": [
10+
"-Wall",
11+
"-Wextra",
12+
"-Wpedantic",
13+
"-Wshadow",
14+
"-Wformat=2",
15+
"-Wcast-align",
16+
"-Wconversion",
17+
"-Wsign-conversion",
18+
"-Wnull-dereference"
19+
],
20+
"C_Cpp_Runner.msvcWarnings": [
21+
"/W4",
22+
"/permissive-",
23+
"/w14242",
24+
"/w14287",
25+
"/w14296",
26+
"/w14311",
27+
"/w14826",
28+
"/w44062",
29+
"/w44242",
30+
"/w14905",
31+
"/w14906",
32+
"/w14263",
33+
"/w44265",
34+
"/w14928"
35+
],
36+
"C_Cpp_Runner.enableWarnings": true,
37+
"C_Cpp_Runner.warningsAsError": false,
38+
"C_Cpp_Runner.compilerArgs": [],
39+
"C_Cpp_Runner.linkerArgs": [],
40+
"C_Cpp_Runner.includePaths": [],
41+
"C_Cpp_Runner.includeSearch": [
42+
"*",
43+
"**/*"
44+
],
45+
"C_Cpp_Runner.excludeSearch": [
46+
"**/build",
47+
"**/build/**",
48+
"**/.*",
49+
"**/.*/**",
50+
"**/.vscode",
51+
"**/.vscode/**"
52+
],
53+
"C_Cpp_Runner.useAddressSanitizer": false,
54+
"C_Cpp_Runner.useUndefinedSanitizer": false,
55+
"C_Cpp_Runner.useLeakSanitizer": false,
56+
"C_Cpp_Runner.showCompilationTime": false,
57+
"C_Cpp_Runner.useLinkTimeOptimization": false,
58+
"C_Cpp_Runner.msvcSecureNoWarnings": false
59+
}

cpjudge

47.7 KB
Binary file not shown.

cpjudge.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <fstream>
3+
#include <string>
4+
#include <cstdlib>
5+
6+
using namespace std;
7+
8+
string readFile(string path)
9+
{
10+
ifstream file(path);
11+
return string((istreambuf_iterator<char>(file)),
12+
istreambuf_iterator<char>());
13+
}
14+
15+
int main()
16+
{
17+
int total = 2;
18+
int passed = 0;
19+
20+
for(int i=1;i<=total;i++)
21+
{
22+
string input = "tests/input" + to_string(i) + ".txt";
23+
string expected = "tests/output" + to_string(i) + ".txt";
24+
25+
string cmd = "./solution < " + input + " > temp.txt";
26+
system(cmd.c_str());
27+
28+
string out = readFile("temp.txt");
29+
string exp = readFile(expected);
30+
31+
if(out.find(exp) != string::npos)
32+
{
33+
cout << "Test " << i << " PASSED\n";
34+
passed++;
35+
}
36+
else
37+
{
38+
cout << "Test " << i << " FAILED\n";
39+
}
40+
}
41+
42+
cout << "\nPassed " << passed << "/" << total << " tests\n";
43+
}

solution

34.1 KB
Binary file not shown.

solution.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int a,b;
6+
cin >> a >> b;
7+
cout << a + b << endl;
8+
return 0;
9+
}

temp.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-61964191

tests/input1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)