Skip to content
Permalink
4bc58bfaca
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
36 lines (30 sloc) 1 KB
#define CATCH_CONFIG_RUNNER
#include <catch2/catch.hpp>
#include <iomanip>
#include <iostream>
#include "tests.cpp"
// There doesn't seem to be a way to get the total number of check/require
// statements from a Catch2 session. We will fortunately have to update
// this value manually as tests are added/removed.
const unsigned int TOTAL_ASSERTIONS = 13;
int main(int argc, char* argv[]) {
const int num_failed = Catch::Session().run(argc, argv);
const bool perfect = num_failed == 0;
if (perfect) {
std::cout
<< "Congratulations, you finished this assignment with a 100%!" << std::endl
<< "Looks like we need to make the next one harder. ;)" << std::endl
<< std::endl;
}
std::cout
<< "Passed "
<< (TOTAL_ASSERTIONS - num_failed) << '/' << TOTAL_ASSERTIONS
<< std::endl;
std::cout
<< "Your score: "
<< std::fixed
<< std::setprecision(2)
<< (1 - (static_cast<float>(num_failed) / TOTAL_ASSERTIONS)) * 100 << "%"
<< std::endl;
return perfect ? 0 : 1;
}