Honestly fuck if i know atp
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.26.0)
|
||||
|
||||
if (NB_BUILD_TESTS)
|
||||
enable_testing()
|
||||
include(GoogleTest)
|
||||
add_executable(TestCore
|
||||
./testErrors.cpp
|
||||
#./testProcesses.cpp
|
||||
./testUtils.cpp
|
||||
)
|
||||
target_link_libraries(TestCore
|
||||
NBCore
|
||||
GTest::gtest_main
|
||||
)
|
||||
enable_testing()
|
||||
include(GoogleTest)
|
||||
add_executable(TestCore
|
||||
./testErrors.cpp
|
||||
#./testProcesses.cpp
|
||||
./testUtils.cpp
|
||||
)
|
||||
target_link_libraries(TestCore
|
||||
NBCore
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
add_executable(LoggerTest
|
||||
./testLogger.cpp
|
||||
)
|
||||
target_link_libraries(LoggerTest
|
||||
NBCore
|
||||
)
|
||||
add_executable(LoggerTest
|
||||
./testLogger.cpp
|
||||
)
|
||||
target_link_libraries(LoggerTest
|
||||
NBCore
|
||||
)
|
||||
|
||||
gtest_discover_tests(TestCore)
|
||||
|
||||
gtest_discover_tests(TestCore)
|
||||
endif()
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string>
|
||||
#include <NBCore/DataTypes.hpp>
|
||||
#include <NBCore/TypeTraits.hpp>
|
||||
#include <NBCore/StringUtils.hpp>
|
||||
|
||||
@@ -22,7 +23,7 @@ TEST(UtilsTest, TestFindAndReplace) {
|
||||
|
||||
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, "i", "ifi");
|
||||
tmp = find_and_replace(tmp, "o", "ofo");
|
||||
tmp = find_and_replace(tmp, "u", "ufu");
|
||||
ASSERT_STREQ(
|
||||
@@ -46,7 +47,6 @@ TEST(UtilsTest, TestFindAndReplaceWstr) {
|
||||
find_and_replace<wchar_t>(L"Jeff", L"e", L"efe").c_str(),
|
||||
L"Jefeff"
|
||||
);
|
||||
|
||||
std::wstring tmp = find_and_replace<wchar_t>(L"Naif", L"a", L"afa");
|
||||
ASSERT_STREQ(
|
||||
find_and_replace<wchar_t>(tmp, L"i", L"ifi").c_str(),
|
||||
@@ -74,44 +74,6 @@ TEST(UtilsTest, TestFindAndReplaceWstr) {
|
||||
);
|
||||
}
|
||||
|
||||
/* TEST(UtilsTest, TestWstrToStr) {
|
||||
ASSERT_STREQ(
|
||||
nb::wstr_to_str(L"Hi!").c_str(),
|
||||
"Hi!"
|
||||
);
|
||||
ASSERT_STREQ(
|
||||
nb::wstr_to_str(L"Naif").c_str(),
|
||||
"Naif"
|
||||
);
|
||||
ASSERT_STREQ(
|
||||
nb::wstr_to_str(L"\r\r\r\n").c_str(),
|
||||
"\r\r\r\n"
|
||||
);
|
||||
ASSERT_STREQ(
|
||||
nb::wstr_to_str(L"Naif\ttalks\r\ra\t\nlot").c_str(),
|
||||
"Naif\ttalks\r\ra\t\nlot"
|
||||
);
|
||||
} */
|
||||
|
||||
/* TEST(UtilsTest, TestStrToWstr) {
|
||||
ASSERT_STREQ(
|
||||
nb::str_to_wstr("Hi!").c_str(),
|
||||
L"Hi!"
|
||||
);
|
||||
ASSERT_STREQ(
|
||||
nb::str_to_wstr("Naif").c_str(),
|
||||
L"Naif"
|
||||
);
|
||||
ASSERT_STREQ(
|
||||
nb::str_to_wstr("\r\r\r\n").c_str(),
|
||||
L"\r\r\r\n"
|
||||
);
|
||||
ASSERT_STREQ(
|
||||
nb::str_to_wstr("Naif\ttalks\r\ra\t\nlot").c_str(),
|
||||
L"Naif\ttalks\r\ra\t\nlot"
|
||||
);
|
||||
} */
|
||||
|
||||
struct A { bool x(); };
|
||||
struct B { bool y(); };
|
||||
struct C { bool x(); bool y; };
|
||||
@@ -145,4 +107,22 @@ TEST(UtilsTest, TestIsDetected) {
|
||||
ASSERT_TRUE(ret);
|
||||
}
|
||||
|
||||
} // namespace nb
|
||||
TEST(DataTypesTests, TestNDArray) {
|
||||
float* data_f = new float[9] {0,1,2,3,4,5,6,7,8};
|
||||
nb::NDArray<float, 2> arr({3, 3}, data_f);
|
||||
ASSERT_FLOAT_EQ(data_f[4], arr.at({1,1}));
|
||||
arr.at({1,1}) = 0.5;
|
||||
ASSERT_FLOAT_EQ(0.5, arr.at({1,1}));
|
||||
delete[] data_f;
|
||||
|
||||
unsigned int* data_ui = new unsigned int[8] {0,1,2,3,4,5,6,7};
|
||||
nb::NDArray<unsigned int, 3> arr3d({2,2,2}, data_ui);
|
||||
ASSERT_EQ(data_ui[5], arr3d.at({1,0,1}));
|
||||
arr3d.at({0,1,1}) = 23;
|
||||
ASSERT_EQ(23, arr3d.at({0,1,1}));
|
||||
delete[] data_ui;
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace nb
|
||||
|
||||
Reference in New Issue
Block a user