Man im so tired This is wrong but I can taste it, im close

This commit is contained in:
NaifBanana
2026-04-10 00:31:11 -05:00
parent a927b96a99
commit b593b7e083
8 changed files with 182 additions and 59 deletions
+12 -2
View File
@@ -1,8 +1,11 @@
#define CODE_ERROR_LOCATIONS
#include "Errors.hpp"
#include <gtest/gtest.h>
#include "Errors.hpp"
#include <iostream>
#include <string>
#include "TypeTraits.hpp"
using namespace nb;
@@ -33,5 +36,12 @@ const ErrorCodeMap TestError::ErrorMessages{
TEST(ErrorTest, Test) {
std::cout << TestError(0, TestError(1, TestError(2))).what();
auto err = TestError(0, TestError(1));
nb::stream(std::cout,
"len string: ", err.what_str().length(), "\n",
"len wstring: ", err.what_str<std::wstring>().length(), "\n"
);
nb::stream(std::wcout,
err.what_str<std::wstring>(), L"\n"
);
}
+33
View File
@@ -4,6 +4,7 @@
#include <gtest/gtest.h>
#include <string>
#include "TypeTraits.hpp"
#include "Utils.hpp"
namespace nb {
@@ -112,5 +113,37 @@ TEST(UtilsTest, TestStrToWstr) {
);
}
struct A { bool x(); };
struct B { bool y(); };
struct C { bool x(); bool y; };
struct D : C {};
template <typename T>
using has_x = decltype(T::x);
template <typename T>
using has_y = decltype(T::y);
TEST(UtilsTest, TestIsDetected) {
auto ret = is_detected<has_x, A>::value;
ASSERT_TRUE(ret);
ret = is_detected<has_y, A>::value;
ASSERT_FALSE(ret);
ret = is_detected<has_y, B>::value;
ASSERT_TRUE(ret);
ret = is_detected<has_x, B>::value;
ASSERT_FALSE(ret);
ret = is_detected<has_x, C>::value;
ASSERT_TRUE(ret);
ret = is_detected<has_y, C>::value;
ASSERT_TRUE(ret);
ret = is_detected<has_x, D>::value;
ASSERT_TRUE(ret);
ret = is_detected<has_y, D>::value;
ASSERT_TRUE(ret);
}
} // namespace nb