Man im so tired This is wrong but I can taste it, im close
This commit is contained in:
@@ -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"
|
||||
);
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user