diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index ea2dfd7..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index 980fd57..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "configurations": [ - { - "name": "macos-clang-arm64", - "includePath": [ - "${workspaceFolder}/**" - ], - "compilerPath": "/usr/bin/clang", - "cStandard": "${default}", - "cppStandard": "${default}", - "intelliSenseMode": "macos-clang-arm64", - "compilerArgs": [ - "" - ] - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 698358d..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "C/C++ Runner: Debug Session", - "type": "lldb", - "request": "launch", - "args": [], - "cwd": "/Users/jaydev/Documents/cpJudge", - "program": "/Users/jaydev/Documents/cpJudge/build/Debug/outDebug" - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b9c6ac8..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "C_Cpp_Runner.cCompilerPath": "clang", - "C_Cpp_Runner.cppCompilerPath": "clang++", - "C_Cpp_Runner.debuggerPath": "lldb", - "C_Cpp_Runner.cStandard": "", - "C_Cpp_Runner.cppStandard": "", - "C_Cpp_Runner.msvcBatchPath": "", - "C_Cpp_Runner.useMsvc": false, - "C_Cpp_Runner.warnings": [ - "-Wall", - "-Wextra", - "-Wpedantic", - "-Wshadow", - "-Wformat=2", - "-Wcast-align", - "-Wconversion", - "-Wsign-conversion", - "-Wnull-dereference" - ], - "C_Cpp_Runner.msvcWarnings": [ - "/W4", - "/permissive-", - "/w14242", - "/w14287", - "/w14296", - "/w14311", - "/w14826", - "/w44062", - "/w44242", - "/w14905", - "/w14906", - "/w14263", - "/w44265", - "/w14928" - ], - "C_Cpp_Runner.enableWarnings": true, - "C_Cpp_Runner.warningsAsError": false, - "C_Cpp_Runner.compilerArgs": [], - "C_Cpp_Runner.linkerArgs": [], - "C_Cpp_Runner.includePaths": [], - "C_Cpp_Runner.includeSearch": [ - "*", - "**/*" - ], - "C_Cpp_Runner.excludeSearch": [ - "**/build", - "**/build/**", - "**/.*", - "**/.*/**", - "**/.vscode", - "**/.vscode/**" - ], - "C_Cpp_Runner.useAddressSanitizer": false, - "C_Cpp_Runner.useUndefinedSanitizer": false, - "C_Cpp_Runner.useLeakSanitizer": false, - "C_Cpp_Runner.showCompilationTime": false, - "C_Cpp_Runner.useLinkTimeOptimization": false, - "C_Cpp_Runner.msvcSecureNoWarnings": false -} \ No newline at end of file diff --git a/README.md b/README.md index beb8d42..572a53d 100644 --- a/README.md +++ b/README.md @@ -82,13 +82,19 @@ Example test files: Compile the solution: -``` +```bash +#Macos g++ solution.cpp -o solution +#Windows +g++ solution.cpp -o solution.exe ``` Compile the judge: -``` +```bash +#Macos +g++ cpjudge.cpp -o cpjudge +#Windows g++ cpjudge.cpp -o cpjudge ``` diff --git a/cpjudge.cpp b/cpjudge.cpp index 351d961..846ba7b 100644 --- a/cpjudge.cpp +++ b/cpjudge.cpp @@ -1,43 +1,50 @@ -#include +#include #include +#include #include -#include using namespace std; -string readFile(string path) +string +readFile (string path) { - ifstream file(path); - return string((istreambuf_iterator(file)), - istreambuf_iterator()); + ifstream file (path); + return string ((istreambuf_iterator (file)), + istreambuf_iterator ()); } -int main() +int +main () { - int total = 2; - int passed = 0; + int total = 2; + int passed = 0; - for(int i=1;i<=total;i++) + for (int i = 1; i <= total; i++) { - string input = "tests/input" + to_string(i) + ".txt"; - string expected = "tests/output" + to_string(i) + ".txt"; +#ifdef __APPLE__ + string input = "tests/input" + to_string (i) + ".txt"; + string cmd = "./solution < " + input + " > temp.txt"; +#elif _WIN32 + string input = ".\\tests\\input" + to_string (i) + ".txt"; + string cmd = "cmd /c \"solution.exe < " + input + " > temp.txt\""; + +#endif + string expected = "tests/output" + to_string (i) + ".txt"; - string cmd = "./solution < " + input + " > temp.txt"; - system(cmd.c_str()); + system (cmd.c_str ()); - string out = readFile("temp.txt"); - string exp = readFile(expected); + string out = readFile ("temp.txt"); + string exp = readFile (expected); - if(out.find(exp) != string::npos) + if (out.find (exp) != string::npos) { - cout << "Test " << i << " PASSED\n"; - passed++; + cout << "\033[32mTest " << i << " PASSED\033[0m\n"; + passed++; } - else + else { - cout << "Test " << i << " FAILED\n"; + cout << "\033[31mTest " << i << " FAILED\033[0m\n"; } } - - cout << "\nPassed " << passed << "/" << total << " tests\n"; + cout << "\nPassed " << passed << "/" << total << " tests\n"; } \ No newline at end of file diff --git a/cpjudgewin.exe b/cpjudgewin.exe new file mode 100644 index 0000000..1da63a2 Binary files /dev/null and b/cpjudgewin.exe differ diff --git a/solution.exe b/solution.exe new file mode 100644 index 0000000..3ee4405 Binary files /dev/null and b/solution.exe differ diff --git a/temp.txt b/temp.txt index d10aecc..a7381ac 100644 --- a/temp.txt +++ b/temp.txt @@ -1 +1 @@ --61964191 +-1824264137