NBEngine/engine/NBCore/tests/testErrors.cpp

44 lines
1002 B
C++

#define CODE_ERROR_LOCATIONS
#include "Errors.hpp"
#include <gtest/gtest.h>
#include <iostream>
#include <sstream>
#include "Logger.hpp"
using namespace nb;
class TestError : public ErrorBase<TestError> {
public:
using ErrorBase<TestError>::ErrorBase;
enum ErrorCodes : unsigned int {
A, B, C, D
};
static const std::string type;
static const ErrorCodeMap ErrorMessages;
};
const std::string TestError::type="TestError";
const ErrorCodeMap TestError::ErrorMessages{
{TestError::ErrorCodes::A, "Hey!"},
{TestError::ErrorCodes::B, "How"},
{TestError::ErrorCodes::C, "You"},
{TestError::ErrorCodes::D, "Doin"}
};
TEST(ErrorTest, Test) {
EXPECT_EQ(1, 1);
std::stringstream sstream;
nb::DefaultDebugLogger logr(std::cout, sstream);
ASSERT_TRUE(logr.run());
ASSERT_TRUE(logr.isRunning());
while (!logr.isRunning()){
1+1;
}
logr.log("Hey!");
logr.stop();
std::cout << "STRINGSTREAM:\n" << sstream.str();
}