cpp-ElementTree
Python ElementTree-alike XML API for C++
Classes | Functions
myunit Namespace Reference

myunit: Ultra tiny test framework. More...

Classes

struct  Test
 Internal descriptor for a test case, tracks the name of the unit where the test was defined, its name, and a reference to its closure. More...
 
struct  TestSetup
 Internal descriptor for a function to be executed once during unit initialization. More...
 

Functions

template<typename Exception , typename Expr >
Exception raises (Expr expr)
 Crash if an exception was not thrown. More...
 

Detailed Description

myunit: Ultra tiny test framework.

Works across multiple files, only one of which may contain MU_MAIN. Example:

#include <cassert>
#include "myunit.hpp"
MU_TEST(testName)
{
assert(1 == 2);
}
MU_MAIN

Function Documentation

template<typename Exception , typename Expr >
Exception myunit::raises ( Expr  expr)

Crash if an exception was not thrown.

Return the exception if it was thrown. the thrown exception value.

auto e = myunit::raises<std::runtime_error>([]() {
throw std::runtime_error("broken!");
});