Package: meliorateapp
MeliorateMeliorate is a code generator and test runner for C++.It aims to:Simplify the writing and execution of tests.Minimise the amount of strange code (macro magic) often associated with C++ unit test libraries.Meliorate usesClangto identify test functions (functions beginning with the wordtest) and generates all code necessary to run test functions automatically.PrerequisitsRequires:Python3.7+Clang (dev only)Getting startedMeliorate comes in two parts:meliorate.hwhich includes themeliorate_runfunction for running tests and other useful parameters for customising test execution.meliorateappwhich is the code generator.meliorate.hshould be included into you project by adding a compiler include flag (-I) that points to theincludedirectory (andnottheinclude/melioratedirectory).Themeliorateappcan be installed from PyPi.pip install meliorateUsing MeliorateWrite some test functions:#include "meliorate/meliorate.h"

void test_that_something_is_true()
{
    // code goes here.
}

// Not extracted as a test function because the function name
// does not begin with "test".
int not_a_test_function()
{
    return 0;
}

void test_that_error_is_thrown()
{
    throw std::runtime_error("Something went wrong.");
}


void test_that_the_result_is_42()
{
    // code goes here.
}

// Not extracted as a test function because the function is static.
static void test_that_something_is_false()
{
    // code goes here.
}Add themeliorate_runfunction tomain:#include "meliorate/meliorate.h"

int main()
{
    meliorate_stop_on_error = false;
    return meliorate_run<std::exception>();
}Meliorate assumes your assertion library will use exceptions from the standard library by default (hence whymeliorate_runis parameterized withstd::exception). To use a custom assertion library, see theCustomising Assertionssection for more information.Run themeliorateappon the test directory:meliorateapp <path/to/test/directory>Check thatmeliorate_gen.cppis created in the test directory.Finally, compile and run you test program as normal, remembering to addmeliorate_gen.cppto your build process.The output will look something like:[RUN     ] test_that_something_is_true
[  PASSED]
[RUN     ] test_that_error_is_thrown
Something went wrong.
[  FAILED]
[RUN     ] test_that_the_result_is_42
[  PASSED]
1 tests FAILED out of 3You can force test execution to stop when an error occurs by settingmeliorate_stop_on_errorvariable totrueprior to calling themeliorate_runfunction.Customising AssertionsMeliorate does not provide any assertions, but by default assumes that the assertion library will use exceptions from the standard library. Should you wish to use another library, such assnowhouse, follow the instructions below:Provide a specialisation for themeliorate_handle_exceptionfunction. This function handles the printing of the exception when an error occurs. By default the function looks like:template <typename T>
void meliorate_handle_exception(T const& exception)
{
    std::cerr << exception.what() << std::endl;
}Provide the specialisation like so:template <typename T>
void meliorate_handle_exception(snowhouse::AssertionException const& exception)
{
    std::cerr << ex.GetMessage() << std::endl;
}Then set the template parameter for themeliorate_runfunction:#include "meliorate/meliorate.h"

int main()
{
    meliorate_stop_on_error = false;
    return meliorate_run<snowhouse::AssertionException>();
}