aboutsummaryrefslogtreecommitdiff
path: root/tests/assert.hpp
blob: 86f74f2b746b1983ff337ff85bbd3ee59bc76069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <cstdlib>
#include <iostream>

template <typename T>
static void assertEquals(const T &expected, const T &actual)
{
    if(expected != actual)
    {
        std::cerr << "Assertion failed!\nExpected: " << expected << ", actual: " << actual << std::endl;
        exit(1);
    }
}

static void fail(const std::string &errMsg)
{
    fprintf(stderr, "Fail:\n%.*s\n", errMsg.size(), errMsg.c_str());
    exit(1);
}