Input Output Testing for C++

Greetings,

Is anyone aware of a tutorial on how to implement input output tests for C++ assignments on GitHub classrooms? I tried putting clang and g++ compile commands in the setup command and ./main as the run command, but the actions workflow does not recognize clang or g++. Any guidance would be appreciated.

Thanks!

I’m not aware of a tutorial, but you can use my script as an example:

https://github.com/kevinwortman/gggg

1 Like

g++ should work in autograding (I haven’t tried clang). Remember, the default output file from g++ is a.out. You probably want to specifiy the output filename in the g++ command; something like g++ -o main main.cpp.

Setting up the autograding tests would look something like:

{
  "tests": [
    {
      "name": "Test 1 - Hello World",
      "setup": "g++ -o HelloWorld HelloWorld.cpp",
      "run": "./HelloWorld",
      "input": "",
      "output": "Hello World!",
      "comparison": "included",
      "timeout": 2,
      "points": 10
    }
  ]
}

I’ve create a template repo to show how to use autograding with inputs and outputs:

You can see how the autograding tests run if you look at the .github/classroom/autograding.json file