37 lines
793 B
C++
37 lines
793 B
C++
#define CODE_ERROR_LOCATIONS
|
|
|
|
#include "Errors.hpp"
|
|
#include <gtest/gtest.h>
|
|
#include <iostream>
|
|
|
|
using namespace nb;
|
|
|
|
class TestError : public Error<TestError> {
|
|
using Base = Error<TestError>;
|
|
public:
|
|
using Base::Base;
|
|
using Base::what;
|
|
using Base::code;
|
|
using Base::msg;
|
|
using Base::trace;
|
|
|
|
enum Codes : unsigned int {
|
|
A, B, C, D
|
|
};
|
|
|
|
static const std::string type;
|
|
static const nb::ErrorCodeMap ErrorMessages;
|
|
};
|
|
|
|
const std::string TestError::type="TestError";
|
|
const ErrorCodeMap TestError::ErrorMessages{
|
|
{TestError::Codes::A, "Hey!"},
|
|
{TestError::Codes::B, "How"},
|
|
{TestError::Codes::C, "You"},
|
|
{TestError::Codes::D, "Doin"}
|
|
};
|
|
|
|
|
|
TEST(ErrorTest, Test) {
|
|
std::cout << TestError(0, TestError(1, TestError(2))).what();
|
|
} |