From 48d2ba56dabdd11a5e11cd126d85568500e821ed Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 13 Jul 2024 03:45:32 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20gucc:=20use=20std=20ranges=20fro?= =?UTF-8?q?m=20C++23=20in=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gucc/CMakeLists.txt | 2 +- gucc/tests/unit-grub_config_gen.cpp | 32 +++++---------------------- gucc/tests/unit-locale.cpp | 34 +++++------------------------ 3 files changed, 13 insertions(+), 55 deletions(-) diff --git a/gucc/CMakeLists.txt b/gucc/CMakeLists.txt index fe7c2a3..8a088da 100644 --- a/gucc/CMakeLists.txt +++ b/gucc/CMakeLists.txt @@ -46,7 +46,7 @@ add_library(${PROJECT_NAME} #SHARED add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_DIR}/include) -target_link_libraries(${PROJECT_NAME} PUBLIC project_warnings project_options spdlog::spdlog fmt::fmt range-v3::range-v3 tomlplusplus::tomlplusplus cpr::cpr) +target_link_libraries(${PROJECT_NAME} PUBLIC project_warnings project_options spdlog::spdlog fmt::fmt tomlplusplus::tomlplusplus cpr::cpr) if(COS_INSTALLER_BUILD_TESTS) add_subdirectory(tests) diff --git a/gucc/tests/unit-grub_config_gen.cpp b/gucc/tests/unit-grub_config_gen.cpp index 78ef319..415b3e0 100644 --- a/gucc/tests/unit-grub_config_gen.cpp +++ b/gucc/tests/unit-grub_config_gen.cpp @@ -4,33 +4,13 @@ #include #include +#include #include #include #include #include -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wold-style-cast" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnull-dereference" -#pragma GCC diagnostic ignored "-Wuseless-cast" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -#include -#include -#include -#include - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - using namespace std::string_literals; using namespace std::string_view_literals; @@ -124,13 +104,13 @@ GRUB_DISABLE_OS_PROBER=false )"sv; inline auto filtered_res(std::string_view content) noexcept -> std::string { - auto&& result = content | ranges::views::split('\n') - | ranges::views::filter([](auto&& rng) { - auto&& line = std::string_view(&*rng.begin(), static_cast(ranges::distance(rng))); + auto&& result = content | std::ranges::views::split('\n') + | std::ranges::views::filter([](auto&& rng) { + auto&& line = std::string_view(&*rng.begin(), static_cast(std::ranges::distance(rng))); return !line.empty() && !line.starts_with("# "); }) - | ranges::views::join('\n') - | ranges::to(); + | std::ranges::views::join_with('\n') + | std::ranges::to(); return result + '\n'; } diff --git a/gucc/tests/unit-locale.cpp b/gucc/tests/unit-locale.cpp index 2de74a0..ca8f86a 100644 --- a/gucc/tests/unit-locale.cpp +++ b/gucc/tests/unit-locale.cpp @@ -6,34 +6,12 @@ #include #include +#include #include -#include - #include #include -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wold-style-cast" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnull-dereference" -#pragma GCC diagnostic ignored "-Wuseless-cast" -#pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -#include -#include -#include -#include - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - namespace fs = std::filesystem; using namespace std::string_view_literals; @@ -54,13 +32,13 @@ static constexpr auto LOCALE_GEN_TEST = R"(ru_RU.UTF-8 UTF-8 )"sv; inline auto filtered_res(std::string_view content) noexcept -> std::string { - auto&& result = content | ranges::views::split('\n') - | ranges::views::filter([](auto&& rng) { - auto&& line = std::string_view(&*rng.begin(), static_cast(ranges::distance(rng))); + auto&& result = content | std::ranges::views::split('\n') + | std::ranges::views::filter([](auto&& rng) { + auto&& line = std::string_view(&*rng.begin(), static_cast(std::ranges::distance(rng))); return !line.empty() && !line.starts_with('#'); }) - | ranges::views::join('\n') - | ranges::to(); + | std::ranges::views::join_with('\n') + | std::ranges::to(); return result + '\n'; }