This is a simple library for grading C- and C++-language assignments. It runs each test case in a child process in order to capture common programming errors such as infinite loops and segmentation faults.
Get it
libgrading is available as a binary package for FreeBSD, a Homebrew tap for macOS and a PPA for Ubuntu Linux. You can also build from source.
FreeBSD
You can install a binary package with pkg install libgrading
or compile the devel/libgrading
port from source.
macOS
First, install Homebrew. Then, run brew install trombonehero/homebrew-grading/libgrading
.
Ubuntu 18.04
You can install a binary package from my grading software PPA:
sudo add-apt-repository ppa:professor-jon/grading-software
sudo apt-get update
sudo apt install libgrading-dev
Build it
The libgrading source code is hosted on GitHub. Releases are available on the GitHub releases page, and you can always get the most latest version by running either:
$ git clone https://github.com/trombonehero/libgrading.git
$ svn checkout https://github.com/trombonehero/libgrading
First, install libdistance. Then:
$ mkdir build
$ cd build
$ cmake .. # or cmake -G Ninja ..
$ make # or ninja
Use it
using namespace std;
struct AdditionExpectation
{
int x;
int y;
int sum;
};
void TestStudentFn(const AdditionExpectation& expected)
{
auto studentFunction = [](int x, int y) { return x + y + 1; };
int sum = studentFunction(expected.x, expected.y);
<< "some more detail to be output if this check fails";
}
{
{
"simple addition test",
" - first part of the long description\n"
" - second part of the long description",
TestStudentFn,
{ 2, 2, 5 },
0,
1,
},
{
"test name",
"long description ...",
[]()
{
int x = foo();
<< "the result of calling foo() should be 42"
;
double *x = nullptr;
double y = *x;
},
},
};
int main(int argc, char *argv[])
{
cout <<
"Grade: " << stats.
score << endl;
return 0;
}