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

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stdexcept>

template <typename T>
static void assertEquals(const T &expected, const T &actual)
{
    if(expected != actual)
    {
        std::stringstream ss;
        ss << "Assertion failed!\nExpected: " << expected << ", actual: " << actual << std::endl;
        throw std::runtime_error(ss.str());
    }
}

static void fail(const std::string &errMsg)
{
    std::stringstream ss;
    ss << "Fail:\n" << errMsg << std::endl;
    throw std::runtime_error(ss.str());
}