From 7580fa544a11404bee61e26eb8b019853260ee0c Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 28 Sep 2024 18:31:49 -0400 Subject: [PATCH] zip iterator, random access --- CMakeLists.txt | 67 ++++-- include/blt/iterator/iterator.h | 131 ------------ include/blt/iterator/zip.h | 352 +++++++++++++++++++++++++++++++- include/blt/std/allocator.h | 8 +- include/blt/std/random.h | 6 + include/blt/std/vector.h | 20 +- libraries/parallel-hashmap | 2 +- src/blt/parse/argparse.cpp | 2 +- src/blt/parse/obj_loader.cpp | 2 +- tests/iterator_tests.cpp | 123 +++++++++++ tests/src/container_test.cpp | 4 +- tests/src/nbt_tests.cpp | 2 +- tests/src/nbt_tests.h | 2 +- tests/src/profiling_tests.h | 2 +- tests/src/string_tests.cpp | 17 +- tests/src/utility_test.cpp | 2 +- 16 files changed, 563 insertions(+), 179 deletions(-) create mode 100644 tests/iterator_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 11b7c39..9495926 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 1.0.1) -set(BLT_TEST_VERSION 0.0.1) +set(BLT_VERSION 1.0.2) set(BLT_TARGET BLT) @@ -34,6 +33,8 @@ if(${BLT_DISABLE_STATS}) add_compile_definitions(BLT_DISABLE_STATS) endif () +find_program(MOLD "mold") + configure_file(include/blt/config.h.in config/blt/config.h @ONLY) message("Enabling library compilation") @@ -138,28 +139,62 @@ install(FILES ${CMAKE_BINARY_DIR}/config/blt/config.h DESTINATION ${CMAKE_INSTAL set_target_properties(${BLT_TARGET} PROPERTIES VERSION ${BLT_VERSION}) set_target_properties(${BLT_TARGET} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) +if (NOT ${MOLD} STREQUAL MOLD-NOTFOUND) + target_compile_options(${BLT_TARGET} PUBLIC -fuse-ld=mold) +endif () install(TARGETS ${BLT_TARGET} CONFIGURATIONS RelWithDebInfo LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +macro(blt_add_project name source type) + + project(${name}-${type}) + + add_executable(${name}-${type} ${source}) + + target_link_libraries(${name}-${type} PRIVATE BLT) + + target_compile_options(${name}-${type} PRIVATE -Wall -Wextra -Wpedantic -Wno-comment) + target_link_options(${name}-${type} PRIVATE -Wall -Wextra -Wpedantic -Wno-comment) + target_compile_definitions(${name}-${type} PRIVATE BLT_DEBUG_LEVEL=${DEBUG_LEVEL}) + + if (NOT ${MOLD} STREQUAL MOLD-NOTFOUND) + target_compile_options(${name}-${type} PUBLIC -fuse-ld=mold) + endif () + + if (${TRACK_ALLOCATIONS}) + target_compile_definitions(${name}-${type} PRIVATE BLT_TRACK_ALLOCATIONS=1) + endif () + + if (${ENABLE_ADDRSAN} MATCHES ON) + target_compile_options(${name}-${type} PRIVATE -fsanitize=address) + target_link_options(${name}-${type} PRIVATE -fsanitize=address) + endif () + + if (${ENABLE_UBSAN} MATCHES ON) + target_compile_options(${name}-${type} PRIVATE -fsanitize=undefined) + target_link_options(${name}-${type} PRIVATE -fsanitize=undefined) + endif () + + if (${ENABLE_TSAN} MATCHES ON) + target_compile_options(${name}-${type} PRIVATE -fsanitize=thread) + target_link_options(${name}-${type} PRIVATE -fsanitize=thread) + endif () + + add_test(NAME ${name} COMMAND ${name}-${type}) + + set(failRegex "\\[WARN\\]" "FAIL" "ERROR" "FATAL" "exception") + set_property(TEST ${name} PROPERTY FAIL_REGULAR_EXPRESSION "${failRegex}") + + project(${BLT_TARGET}) +endmacro() + if (${BUILD_TESTS}) - message("Building test version ${BLT_TEST_VERSION}") - project(BLT_TESTS VERSION ${BLT_TEST_VERSION}) + message("Building tests for version ${BLT_VERSION}") - include_directories(tests/include) - - file(GLOB_RECURSE TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tests/src/*.cpp") - - message("Using files ${TEST_FILES}") - - add_executable(BLT_TESTS ${TEST_FILES}) - - target_link_libraries(BLT_TESTS PRIVATE BLT) - - include(cmake/warnings.cmake) - include(cmake/sanitizers.cmake) + blt_add_project(blt-iterator tests/iterator_tests.cpp test) message("Built tests") endif () diff --git a/include/blt/iterator/iterator.h b/include/blt/iterator/iterator.h index 5f9e9a7..51c4cfc 100644 --- a/include/blt/iterator/iterator.h +++ b/include/blt/iterator/iterator.h @@ -59,118 +59,6 @@ namespace blt template> class pair_wrapper; - template - class zip_wrapper; - - template - class zip_iterator_storage; - - template - class zip_iterator_storage_rev; - - template - class zip_forward_iterator - { - public: - explicit zip_forward_iterator(Iter... iter): iter(std::make_tuple(iter...)) - {} - - std::tuple...> operator*() const - { - return std::apply([](auto& ... i) { return std::make_tuple(*i...); }, iter); - } - - friend bool operator==(const zip_forward_iterator& a, const zip_forward_iterator& b) - { - return a.iter == b.iter; - } - - friend bool operator!=(const zip_forward_iterator& a, const zip_forward_iterator& b) - { - return !(a.iter == b.iter); - } - - zip_forward_iterator& operator++() - { - std::apply([](auto& ... i) { ((++i), ...); }, iter); - return *this; - } - - zip_forward_iterator operator++(int) - { - auto tmp = *this; - ++*this; - return tmp; - } - - auto base() - { - return iter; - } - - protected: - std::tuple iter; - }; - - template - class zip_bidirectional_iterator : public zip_forward_iterator - { - public: - using zip_forward_iterator::zip_forward_iterator; - - zip_bidirectional_iterator& operator--() - { - std::apply([](auto& ... i) { ((--i), ...); }, this->iter); - return *this; - } - - zip_bidirectional_iterator operator--(int) - { - auto tmp = *this; - --*this; - return tmp; - } - }; - - template - class zip_wrapper : public zip_forward_iterator - { - public: - using zip_forward_iterator::zip_forward_iterator; - - using iterator_category = std::forward_iterator_tag; - using value_type = std::tuple...>; - using difference_type = blt::ptrdiff_t; - using pointer = value_type; - using reference = value_type; - }; - - template - class zip_wrapper : public zip_bidirectional_iterator - { - public: - using zip_bidirectional_iterator::zip_bidirectional_iterator; - - using iterator_category = std::bidirectional_iterator_tag; - using value_type = std::tuple...>; - using difference_type = blt::ptrdiff_t; - using pointer = value_type; - using reference = value_type; - }; - - template - class zip_wrapper : public zip_bidirectional_iterator - { - public: - using zip_bidirectional_iterator::zip_bidirectional_iterator; - - using iterator_category = std::bidirectional_iterator_tag; - using value_type = std::tuple...>; - using difference_type = blt::ptrdiff_t; - using pointer = value_type; - using reference = value_type; - }; - /** * struct which is returned by the enumerator. * @tparam T type to store. @@ -590,25 +478,6 @@ namespace blt return CompleteEnumerator{b->begin(), b->end(), static_cast(std::distance(b->begin(), b->end()))}; } }; - - template - class zip_iterator_storage - { - - }; - - template - class zip_iterator_storage - { - - }; - - template - class zip_iterator_storage - { - - }; - } /** diff --git a/include/blt/iterator/zip.h b/include/blt/iterator/zip.h index f8f197d..812b7cd 100644 --- a/include/blt/iterator/zip.h +++ b/include/blt/iterator/zip.h @@ -24,7 +24,357 @@ namespace blt { - + + namespace iterator + { + template + class zip_wrapper; + + template + class zip_iterator_storage; + + template + class zip_iterator_storage_rev; + + template + class zip_forward_iterator + { + public: + explicit zip_forward_iterator(Iter... iter): iter(std::make_tuple(iter...)) + {} + + std::tuple...> operator*() const + { + return std::apply([](auto& ... i) { return std::make_tuple(*i...); }, iter); + } + + friend bool operator==(const zip_forward_iterator& a, const zip_forward_iterator& b) + { + return a.iter == b.iter; + } + + friend bool operator!=(const zip_forward_iterator& a, const zip_forward_iterator& b) + { + return !(a.iter == b.iter); + } + + zip_forward_iterator& operator++() + { + std::apply([](auto& ... i) { ((++i), ...); }, iter); + return *this; + } + + zip_forward_iterator operator++(int) + { + auto tmp = *this; + ++*this; + return tmp; + } + + auto base() + { + return iter; + } + + protected: + std::tuple iter; + }; + + template + class zip_bidirectional_iterator : public zip_forward_iterator + { + public: + using zip_forward_iterator::zip_forward_iterator; + + zip_bidirectional_iterator& operator--() + { + std::apply([](auto& ... i) { ((--i), ...); }, this->iter); + return *this; + } + + zip_bidirectional_iterator operator--(int) + { + auto tmp = *this; + --*this; + return tmp; + } + }; + + template + class zip_random_access_iterator : public zip_bidirectional_iterator + { + private: + template + static blt::ptrdiff_t sub(const zip_random_access_iterator& a, const zip_random_access_iterator& b, + std::integer_sequence) + { + auto min = std::min(std::get(a.iter) - std::get(b.iter)...); + return min; + } + public: + using zip_bidirectional_iterator::zip_bidirectional_iterator; + + zip_random_access_iterator& operator+=(blt::ptrdiff_t n) + { + std::apply([n](auto& ... i) { ((i += n), ...); }, this->iter); + return *this; + } + + zip_random_access_iterator& operator-=(blt::ptrdiff_t n) + { + std::apply([n](auto& ... i) { ((i -= n), ...); }, this->iter); + return *this; + } + + friend zip_random_access_iterator operator+(const zip_random_access_iterator& a, blt::ptrdiff_t n) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i + n)...}; }, a.iter); + } + + friend zip_random_access_iterator operator+(blt::ptrdiff_t n, const zip_random_access_iterator& a) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i + n)...}; }, a.iter); + } + + friend zip_random_access_iterator operator-(const zip_random_access_iterator& a, blt::ptrdiff_t n) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i - n)...}; }, a.iter); + } + + friend zip_random_access_iterator operator-(blt::ptrdiff_t n, const zip_random_access_iterator& a) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i - n)...}; }, a.iter); + } + + friend blt::ptrdiff_t operator-(const zip_random_access_iterator& a, const zip_random_access_iterator& b) + { + return sub(a, b, std::index_sequence_for()); + } + + auto operator[](blt::ptrdiff_t n) const + { + return *(*this + n); + } + + friend bool operator<(const zip_random_access_iterator& a, const zip_random_access_iterator& b) + { + return b - a > 0; + } + + friend bool operator>(const zip_random_access_iterator& a, const zip_random_access_iterator& b) + { + return b < a; + } + + friend bool operator>=(const zip_random_access_iterator& a, const zip_random_access_iterator& b) + { + return !(a < b); // NOLINT + } + + friend bool operator<=(const zip_random_access_iterator& a, const zip_random_access_iterator& b) + { + return !(a > b); // NOLINT + } + }; + + template + class zip_wrapper + { + public: + using iterator_category = std::forward_iterator_tag; + using value_type = std::tuple...>; + using difference_type = blt::ptrdiff_t; + using pointer = value_type; + using reference = value_type; + + explicit zip_wrapper(Iter... iter): iter(std::make_tuple(iter...)) + {} + + std::tuple...> operator*() const + { + return std::apply([](auto& ... i) { return std::make_tuple(*i...); }, iter); + } + + friend bool operator==(const zip_wrapper& a, const zip_wrapper& b) + { + return a.iter == b.iter; + } + + friend bool operator!=(const zip_wrapper& a, const zip_wrapper& b) + { + return !(a.iter == b.iter); + } + + zip_wrapper& operator++() + { + std::apply([](auto& ... i) { ((++i), ...); }, iter); + return *this; + } + + zip_wrapper operator++(int) + { + auto tmp = *this; + ++*this; + return tmp; + } + + auto base() + { + return iter; + } + + protected: + std::tuple iter; + }; + + template + class zip_wrapper : public zip_wrapper + { + public: + using zip_wrapper::zip_wrapper; + + using iterator_category = std::bidirectional_iterator_tag; + using value_type = std::tuple...>; + using difference_type = blt::ptrdiff_t; + using pointer = value_type; + using reference = value_type; + + zip_wrapper& operator--() + { + std::apply([](auto& ... i) { ((--i), ...); }, this->iter); + return *this; + } + + zip_wrapper operator--(int) + { + auto tmp = *this; + --*this; + return tmp; + } + }; + + template + class zip_wrapper : public zip_wrapper + { + private: + template + static blt::ptrdiff_t sub(const zip_wrapper& a, const zip_wrapper& b, + std::integer_sequence) + { + auto min = std::min(std::get(a.iter) - std::get(b.iter)...); + return min; + } + public: + using zip_wrapper::zip_wrapper; + + using iterator_category = std::random_access_iterator_tag; + using value_type = std::tuple...>; + using difference_type = blt::ptrdiff_t; + using pointer = value_type; + using reference = value_type; + + using zip_bidirectional_iterator::zip_bidirectional_iterator; + + zip_wrapper& operator+=(blt::ptrdiff_t n) + { + std::apply([n](auto& ... i) { ((i += n), ...); }, this->iter); + return *this; + } + + zip_wrapper& operator-=(blt::ptrdiff_t n) + { + std::apply([n](auto& ... i) { ((i -= n), ...); }, this->iter); + return *this; + } + + friend zip_wrapper operator+(const zip_wrapper& a, blt::ptrdiff_t n) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i + n)...}; }, a.iter); + } + + friend zip_wrapper operator+(blt::ptrdiff_t n, const zip_wrapper& a) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i + n)...}; }, a.iter); + } + + friend zip_wrapper operator-(const zip_wrapper& a, blt::ptrdiff_t n) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i - n)...}; }, a.iter); + } + + friend zip_wrapper operator-(blt::ptrdiff_t n, const zip_wrapper& a) + { + return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i - n)...}; }, a.iter); + } + + friend blt::ptrdiff_t operator-(const zip_wrapper& a, const zip_wrapper& b) + { + return sub(a, b, std::index_sequence_for()); + } + + auto operator[](blt::ptrdiff_t n) const + { + return *(*this + n); + } + + friend bool operator<(const zip_wrapper& a, const zip_wrapper& b) + { + return b - a > 0; + } + + friend bool operator>(const zip_wrapper& a, const zip_wrapper& b) + { + return b < a; + } + + friend bool operator>=(const zip_wrapper& a, const zip_wrapper& b) + { + return !(a < b); // NOLINT + } + + friend bool operator<=(const zip_wrapper& a, const zip_wrapper& b) + { + return !(a > b); // NOLINT + } + }; + + template + class zip_iterator_storage + { + + }; + + template + class zip_iterator_storage + { + + }; + + template + class zip_iterator_storage + { + + }; + + template + class zip_iterator_storage_rev + { + + }; + + template + class zip_iterator_storage_rev + { + + }; + + template + class zip_iterator_storage_rev + { + + }; + } + } #endif //BLT_ITERATOR_ZIP diff --git a/include/blt/std/allocator.h b/include/blt/std/allocator.h index 91e7e5d..873c0e4 100644 --- a/include/blt/std/allocator.h +++ b/include/blt/std/allocator.h @@ -22,7 +22,7 @@ #include #include #include - #include + #include #include #include #include @@ -159,10 +159,10 @@ namespace blt */ inline std::optional search_for_block(block_storage* blk, size_t n) { - for (auto kv : blt::enumerate(blk->unallocated_blocks)) + for (auto [index, item] : blt::enumerate(blk->unallocated_blocks)) { - if (kv.second.n >= n) - return block_view{blk, kv.first, kv.second.n - n}; + if (item.n >= n) + return block_view{blk, index, item.n - n}; } return {}; } diff --git a/include/blt/std/random.h b/include/blt/std/random.h index 1e33e66..9ffad57 100644 --- a/include/blt/std/random.h +++ b/include/blt/std/random.h @@ -174,6 +174,12 @@ namespace blt::random return BLT_RANDOM_FUNCTION(seed, min, max); } + template + constexpr T get(T min, T max) + { + return BLT_RANDOM_FUNCTION(seed, min, max); + } + constexpr bool choice() { return BLT_RANDOM_DOUBLE(seed) < 0.5; diff --git a/include/blt/std/vector.h b/include/blt/std/vector.h index 5ed4d12..2cc3233 100644 --- a/include/blt/std/vector.h +++ b/include/blt/std/vector.h @@ -42,8 +42,8 @@ namespace blt using pointer = T*; using const_reference = const T&; using const_pointer = const T*; - using iterator = blt::ptr_iterator; - using const_iterator = blt::ptr_iterator; + using iterator = T*; + using const_iterator = const T*; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; public: @@ -131,24 +131,24 @@ namespace blt return buffer_[index]; } - constexpr inline pointer operator*() + constexpr inline reference operator*() { - return buffer_; + return *buffer_.data(); } - constexpr inline const_pointer operator*() const + constexpr inline const_reference operator*() const { - return buffer_; + return *buffer_.data(); } constexpr inline pointer data() { - return buffer_; + return buffer_.data(); } constexpr inline const_pointer data() const { - return buffer_; + return buffer_.data(); } constexpr inline reference front() @@ -290,8 +290,8 @@ namespace blt using const_reference = const value_type&; using pointer = value_type*; using const_pointer = const pointer; - using iterator = blt::ptr_iterator; - using const_iterator = blt::ptr_iterator; + using iterator = T*; + using const_iterator = const T*; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index 63acc33..7ef2e73 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit 63acc3336f941c6f324c88eb9ee4ce623a460cd5 +Subproject commit 7ef2e733416953b222851f9a360d7fc72d068ee5 diff --git a/src/blt/parse/argparse.cpp b/src/blt/parse/argparse.cpp index a467e2a..4f8477c 100644 --- a/src/blt/parse/argparse.cpp +++ b/src/blt/parse/argparse.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include "blt/std/utility.h" diff --git a/src/blt/parse/obj_loader.cpp b/src/blt/parse/obj_loader.cpp index af5eb3d..82a3c2d 100644 --- a/src/blt/parse/obj_loader.cpp +++ b/src/blt/parse/obj_loader.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include "blt/std/assert.h" diff --git a/tests/iterator_tests.cpp b/tests/iterator_tests.cpp new file mode 100644 index 0000000..5922a7a --- /dev/null +++ b/tests/iterator_tests.cpp @@ -0,0 +1,123 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +constexpr auto increasing_reverse_pairs = [](blt::size_t i, blt::size_t index, blt::size_t size) { return i == 0 ? index : (size - 1) - index; }; +constexpr auto increasing_pairs = [](blt::size_t, blt::size_t index, blt::size_t) { return index; }; +constexpr auto decreasing_pairs = [](blt::size_t, blt::size_t index, blt::size_t size) { return size - index; }; + +template +std::array make_array(Func&& func) +{ + std::array array; + for (auto&& [index, value] : blt::enumerate(array)) + value = blt::vec2(func(0, index, n), func(1, index, n)); + return array; +} + +constexpr blt::size_t array_size = 10; +auto array_1 = make_array(increasing_reverse_pairs); +auto array_2 = make_array(increasing_pairs); +auto array_3 = make_array(decreasing_pairs); + +void test_enumerate() +{ + blt::log_box_t box(std::cout, "Enumerate Tests", 25); + for (const auto& [index, item] : blt::enumerate(array_1)) + BLT_TRACE_STREAM << index << " : " << item << "\n"; + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).rev()) + BLT_TRACE_STREAM << index << " : " << item << "\n"; + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).take(3)) + { + BLT_TRACE_STREAM << index << " : " << item << "\n"; + BLT_ASSERT(index < 3); + } + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).take(3).rev()) + { + BLT_TRACE_STREAM << index << " : " << item << "\n"; + BLT_ASSERT(index < 3); + } + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).skip(3)) + { + BLT_TRACE_STREAM << index << " : " << item << "\n"; + BLT_ASSERT(index >= 3); + } + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).skip(3).rev()) + { + BLT_TRACE_STREAM << index << " : " << item << "\n"; + BLT_ASSERT(index >= 3); + } + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).skip(3).take(5)) + { + BLT_TRACE_STREAM << index << " : " << item << "\n"; + BLT_ASSERT(index >= 3 && index < (array_1.size() - 5) + 3); + } + + BLT_TRACE(""); + + for (const auto& [index, item] : blt::enumerate(array_1).skip(3).rev().take(5)) + { + BLT_TRACE_STREAM << index << " : " << item << "\n"; + BLT_ASSERT(index >= 5); + } +} + +void test_pairs() +{ + blt::log_box_t box(std::cout, "Pairs Tests", 25); +} + +void test_zip() +{ + blt::log_box_t box(std::cout, "Zip Tests", 25); +} + +int main() +{ + test_enumerate(); + std::cout << std::endl; + test_pairs(); + std::cout << std::endl; + test_zip(); +} \ No newline at end of file diff --git a/tests/src/container_test.cpp b/tests/src/container_test.cpp index ed6abb2..4f967f1 100644 --- a/tests/src/container_test.cpp +++ b/tests/src/container_test.cpp @@ -28,8 +28,8 @@ namespace blt::test void print(const T& ref) { BLT_TRACE_STREAM << "(" << ref.size() << ") ["; - for (auto v : blt::enumerate(ref)) - BLT_TRACE_STREAM << v.second << ((v.first != ref.size()-1) ? ", " : "]\n"); + for (auto [index, item] : blt::enumerate(ref)) + BLT_TRACE_STREAM << item << ((index != ref.size()-1) ? ", " : "]\n"); } void vector_run() diff --git a/tests/src/nbt_tests.cpp b/tests/src/nbt_tests.cpp index 1dc9ba3..44990d5 100644 --- a/tests/src/nbt_tests.cpp +++ b/tests/src/nbt_tests.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/tests/src/nbt_tests.h b/tests/src/nbt_tests.h index 187023d..a6eb0d0 100644 --- a/tests/src/nbt_tests.h +++ b/tests/src/nbt_tests.h @@ -15,7 +15,7 @@ namespace blt::tests { template T* generateRandomData(T* arr, size_t size, uint32_t seed = 0) { for (size_t i = 0; i < size; i++) - arr[i] = blt::random::randomInt_c(i * size + seed, std::numeric_limits::min(), std::numeric_limits::max()); + arr[i] = blt::random::random_t(i * size + seed).get(std::numeric_limits::min(), std::numeric_limits::max()); return arr; } diff --git a/tests/src/profiling_tests.h b/tests/src/profiling_tests.h index ac27a6c..94ebcd0 100644 --- a/tests/src/profiling_tests.h +++ b/tests/src/profiling_tests.h @@ -10,7 +10,7 @@ #include "blt/profiling/profiler_v2.h" #include "blt/std/logging.h" #include "blt/std/time.h" -#include "blt/std/format.h" +#include "blt/format/format.h" void print(const std::vector& vtr) { for (const auto& line : vtr) diff --git a/tests/src/string_tests.cpp b/tests/src/string_tests.cpp index 4f3216e..444b7cb 100644 --- a/tests/src/string_tests.cpp +++ b/tests/src/string_tests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace blt::test { @@ -32,27 +33,27 @@ namespace blt::test auto sv_splits_c = blt::string::split_sv(str, ' '); auto sv_splits_s = blt::string::split_sv(str, "LOT"); - for (auto v : blt::enumerate(s_splits_c)) + for (auto [index, item] : blt::enumerate(s_splits_c)) { - if (v.second != sv_splits_c[v.first]) + if (item != sv_splits_c[index]) { - BLT_WARN("THEY DO NOT MATCH!!! '%s' vs '%s'", v.second.c_str(), std::string(sv_splits_c[v.first]).c_str()); + BLT_WARN("THEY DO NOT MATCH!!! '%s' vs '%s'", item.c_str(), std::string(sv_splits_c[index]).c_str()); } else { - BLT_DEBUG(v.second); + BLT_DEBUG(item); } } BLT_INFO(""); - for (auto v : blt::enumerate(s_splits_s)) + for (auto [index, item] : blt::enumerate(s_splits_s)) { - if (v.second != sv_splits_s[v.first]) + if (item != sv_splits_s[index]) { - BLT_WARN("THEY DO NOT MATCH!!! '%s' vs '%s'", v.second.c_str(), std::string(sv_splits_s[v.first]).c_str()); + BLT_WARN("THEY DO NOT MATCH!!! '%s' vs '%s'", item.c_str(), std::string(sv_splits_s[index]).c_str()); } else { - BLT_DEBUG(v.second); + BLT_DEBUG(item); } } } diff --git a/tests/src/utility_test.cpp b/tests/src/utility_test.cpp index 20bd404..7dd5c9f 100644 --- a/tests/src/utility_test.cpp +++ b/tests/src/utility_test.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ #include -#include +#include #include #include #include