Permalink
Cannot retrieve contributors at this time
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?
cse3150-grading/src/asgn2/main.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (30 sloc)
1 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |