Made errors mostly work as hoped
This commit is contained in:
@@ -4,8 +4,9 @@ if (NB_BUILD_TESTS)
|
||||
enable_testing()
|
||||
include(GoogleTest)
|
||||
add_executable(TestCore
|
||||
testErrors.cpp
|
||||
testProcesses.cpp
|
||||
./testErrors.cpp
|
||||
#./testProcesses.cpp
|
||||
./testUtils.cpp
|
||||
)
|
||||
target_link_libraries(TestCore
|
||||
NBCore
|
||||
|
||||
@@ -3,36 +3,35 @@
|
||||
#include "Errors.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "Logger.hpp"
|
||||
|
||||
using namespace nb;
|
||||
|
||||
class TestError : public ErrorBase<TestError> {
|
||||
class TestError : public Error<TestError> {
|
||||
using Base = Error<TestError>;
|
||||
public:
|
||||
using ErrorBase<TestError>::ErrorBase;
|
||||
using Base::Base;
|
||||
using Base::what;
|
||||
using Base::code;
|
||||
using Base::msg;
|
||||
using Base::trace;
|
||||
|
||||
enum ErrorCodes : unsigned int {
|
||||
enum Codes : unsigned int {
|
||||
A, B, C, D
|
||||
};
|
||||
|
||||
static const std::string type;
|
||||
static const ErrorCodeMap ErrorMessages;
|
||||
static const nb::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"}
|
||||
{TestError::Codes::A, "Hey!"},
|
||||
{TestError::Codes::B, "How"},
|
||||
{TestError::Codes::C, "You"},
|
||||
{TestError::Codes::D, "Doin"}
|
||||
};
|
||||
|
||||
|
||||
TEST(ErrorTest, Test) {
|
||||
EXPECT_EQ(1, 1);
|
||||
|
||||
std::stringstream sstream;
|
||||
|
||||
ASSERT_TRUE(nb::logger.isRunning());
|
||||
nb::logger.log("Hey!");
|
||||
std::cout << TestError(0, TestError(1, TestError(2))).what();
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
#define CODE_ERROR_LOCATIONS
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <iostream>
|
||||
#include "Processes.hpp"
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#define CODE_ERROR_LOCATIONS
|
||||
|
||||
#include "Utils.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace nb {
|
||||
|
||||
TEST(UtilsTest, Test) {
|
||||
ASSERT_STREQ(
|
||||
find_and_replace("Jeff", "e", "efe").c_str(),
|
||||
"Jefeff"
|
||||
);
|
||||
|
||||
auto tmp = find_and_replace("Naif", "a", "afa");
|
||||
ASSERT_STREQ(
|
||||
find_and_replace(tmp, "i", "ifi").c_str(),
|
||||
"Nafaifif"
|
||||
);
|
||||
|
||||
tmp = find_and_replace("aeiou", "a", "afa");
|
||||
tmp = find_and_replace(tmp, "e", "efe");
|
||||
tmp = find_and_replace(tmp, "i", "ifi");
|
||||
tmp = find_and_replace(tmp, "o", "ofo");
|
||||
tmp = find_and_replace(tmp, "u", "ufu");
|
||||
ASSERT_STREQ(
|
||||
tmp.c_str(),
|
||||
"afaefeifiofoufu"
|
||||
);
|
||||
|
||||
tmp = find_and_replace(tmp, "afa", "a");
|
||||
tmp = find_and_replace(tmp, "efe", "e");
|
||||
tmp = find_and_replace(tmp, "ifi", "i");
|
||||
tmp = find_and_replace(tmp, "ofo", "o");
|
||||
tmp = find_and_replace(tmp, "ufu", "u");
|
||||
ASSERT_STREQ(
|
||||
tmp.c_str(),
|
||||
"aeiou"
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace nb
|
||||
Reference in New Issue
Block a user