Skip to content

Commit e7313c5

Browse files
testcase
1 parent eb9d9b1 commit e7313c5

File tree

9 files changed

+62
-1
lines changed

9 files changed

+62
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is a backend for grading C++ code in a secure and controlled manner.
44

55
## Motivation
66

7-
Code grading can be a difficult task, and this project aims to simplify that. No matter you want to teach people how to define a variable, how to write a function, how to write an algorithm, or how to write codes that calls other external api, `code-grader` provides a customizable framework to help you do that.
7+
Code grading can be a difficult task, and this project aims to simplify that. `code-grader` enables grading of different types of code, from one line of variable definition, to a complete project.
88

99
## Usage
1010

testcases/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
# Writing Test Cases
22

33
To add testcases to this folder, Please follow guidelines given in folders `example-x`. Upon commit, test cases will be automatically tested. Please make sure the answer can be run within the given runtime and memory.
4+
5+
## Overview
6+
7+
### example-1
8+
9+
This test case is used internally for unit testing. It expect `int main() { cout << "Hello << endl; }`
10+
11+
### simple-1
12+
13+
This test case demonstrate how `code-grader` can be used to grade variable definition. Any variable definition of type `int` that has value `1024` pass.
14+
15+
```cpp
16+
int x = 1024; // this will pass
17+
int y = 1000+24; // this will also pass
18+
auto z = 0x00000400; // this will also pass
19+
// however
20+
char x = 'a'; // this won't pass
21+
```

testcases/simple-1/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Writing Test Cases - 1
2+
3+
It is compulsory for a test case to contain the following files
4+
* answer.txt
5+
* prepend.txt
6+
* append.txt
7+
* input.txt
8+
* output.txt
9+
* testcase.json
10+
11+
If your test case's input and output is generated by a program/script, it's conventional to put the source code inside a folder called `__generate`

testcases/simple-1/answer.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
auto hello = 0x00000400;

testcases/simple-1/append.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
/// user code end
3+
4+
int *pos = &start + 1;
5+
6+
if (*pos == 1024)
7+
{
8+
cout << "Pass" << endl;
9+
}
10+
else
11+
{
12+
cout << "Fail" << endl;
13+
}
14+
}

testcases/simple-1/input.txt

Whitespace-only changes.

testcases/simple-1/output.txt

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

testcases/simple-1/prepend.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int start = 0;
8+
9+
/// user code start
10+

testcases/simple-1/testcase.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"RuntimeOptions": {
3+
"MemoryLimit": 64,
4+
"RuntimeLimit": 5
5+
}
6+
}

0 commit comments

Comments
 (0)