Renamed NBCoreUtils to just NBCOre
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.26.0)
|
||||
project(gtest_Graphics VERSION 0.1.0 LANGUAGES C CXX)
|
||||
|
||||
add_subdirectory(./ErrorTest)
|
||||
add_subdirectory(./SmartStreamTest)
|
||||
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.26.0)
|
||||
project(gtest_Graphics VERSION 0.1.0 LANGUAGES C CXX)
|
||||
|
||||
add_executable(ErrorTest main.cpp)
|
||||
target_link_libraries(ErrorTest NBCore)
|
||||
@@ -0,0 +1,54 @@
|
||||
#define CODE_ERROR_LOCATIONS
|
||||
|
||||
#include "Errors.hpp"
|
||||
#include <iostream>
|
||||
#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"}
|
||||
};
|
||||
|
||||
int main() {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
THROW(TestError, TestError::ErrorCodes::D);
|
||||
} catch (const std::exception& e){
|
||||
THROW(TestError, TestError::ErrorCodes::C, e);
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
THROW(TestError, TestError::ErrorCodes::B, e);
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
THROW(TestError, TestError::ErrorCodes::A, e);
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
// THROW(Error, Error::ErrorCodes::UNDEFINED, e);
|
||||
Logger log(std::cout);
|
||||
std::cout << "Logger is starting: " << log.run() << std::endl;
|
||||
std::cout << "Logger is running: " << log.isRunning() << std::endl;
|
||||
log.error(e);
|
||||
log.stop();
|
||||
std::cout << "Logger is running: " << log.isRunning() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.26.0)
|
||||
project(gtest_Graphics VERSION 0.1.0 LANGUAGES C CXX)
|
||||
|
||||
add_executable(SmartStreamTest main.cpp)
|
||||
target_link_libraries(SmartStreamTest NBCore)
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
#include "SmartStreams.hpp"
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
auto test = nb::TerminalColor(9, 2030);
|
||||
|
||||
std::cout << test;
|
||||
|
||||
std::ofstream file;
|
||||
file.open("test.txt");
|
||||
if (file.is_open()) {
|
||||
file << test;
|
||||
}
|
||||
file.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user