Skip to content

Commit f962f82

Browse files
committed
test: add QTest integration for contest core logic
Add test1 suite testing the full contest data lifecycle: - testReadCdf: loads TestContest1.cdf, verifies title/tasks/contestants - testGetCompilerPath: verifies g++ and python are found on PATH - testJudgeAllAndCheckOutput: judges all test cases, checks expected scores - testWriteCdf: round-trip CDF serialization via writeToJson/readFromJson CMake changes: - enable_testing() + add_subdirectory(tests) in root CMakeLists.txt - Qt6::Test and SingleApplication linked for test1 target - Test data copied to build dir via file(COPY) at configure time - set_tests_properties ENVIRONMENT for Qt DLL path on Windows (cherry picked from commit 5391f24)
1 parent 4c615aa commit f962f82

15 files changed

Lines changed: 425 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ if(ENABLE_LTO)
308308
endif()
309309
endif()
310310

311+
# ==================================================================================
312+
# Tests
313+
# ==================================================================================
314+
315+
enable_testing()
316+
add_subdirectory(tests)
317+
311318
# ==================================================================================
312319
# Platform-dependent installation process and deployment
313320
# ==================================================================================

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(test1)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"contestTitle":"TestContest1","contestants":[{"checkJudged":[false,false],"compileMesaage":["",""],"compileState":[1,1],"contestantName":"user1","inputFiles":[[],[]],"judgingTime_date":0,"judgingTime_time":0,"judgingTime_timespec":0,"memoryUsed":[[],[]],"message":[[],[]],"result":[[],[]],"score":[[],[]],"sourceFile":["",""],"timeUsed":[[],[]]},{"checkJudged":[false,false],"compileMesaage":["",""],"compileState":[1,1],"contestantName":"user2","inputFiles":[[],[]],"judgingTime_date":0,"judgingTime_time":0,"judgingTime_timespec":0,"memoryUsed":[[],[]],"message":[[],[]],"result":[[],[]],"score":[[],[]],"sourceFile":["",""],"timeUsed":[[],[]]}],"tasks":[{"answerFileExtension":"out","comparisonMode":1,"compilerConfiguration":{"g++":"default","python":"default"},"diffArguments":"--ignore-space-change --text --brief","inputFileName":"aplusb.in","outputFileName":"aplusb.out","problemTitle":"aplusb","realPrecision":3,"sourceFileName":"aplusb","specialJudge":"","standardInputCheck":true,"standardOutputCheck":true,"subFolderCheck":false,"taskType":0,"testCases":[{"fullScore":100,"inputFiles":["aplusb/1.in"],"memoryLimit":512,"outputFiles":["aplusb/1.out"],"timeLimit":1000}]},{"answerFileExtension":"out","comparisonMode":0,"compilerConfiguration":{"g++":"default","python":"default"},"diffArguments":"--ignore-space-change --text --brief","inputFileName":"helloworld.in","outputFileName":"helloworld.out","problemTitle":"helloworld","realPrecision":3,"sourceFileName":"helloworld","specialJudge":"","standardInputCheck":true,"standardOutputCheck":true,"subFolderCheck":false,"taskType":0,"testCases":[{"fullScore":17,"inputFiles":["helloworld/1.in"],"memoryLimit":512,"outputFiles":["helloworld/1.out"],"timeLimit":1000},{"fullScore":17,"inputFiles":["helloworld/2.in"],"memoryLimit":512,"outputFiles":["helloworld/2.out"],"timeLimit":1000},{"fullScore":17,"inputFiles":["helloworld/3.in"],"memoryLimit":512,"outputFiles":["helloworld/3.out"],"timeLimit":1000},{"fullScore":17,"inputFiles":["helloworld/4.in"],"memoryLimit":512,"outputFiles":["helloworld/4.out"],"timeLimit":1000},{"fullScore":16,"inputFiles":["helloworld/5.in"],"memoryLimit":512,"outputFiles":["helloworld/5.out"],"timeLimit":1000},{"fullScore":16,"inputFiles":["helloworld/6.in"],"memoryLimit":512,"outputFiles":["helloworld/6.out"],"timeLimit":1000}]}],"version":"1.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21

0 commit comments

Comments
 (0)