👷 gucc: use std ranges from C++23 in unit tests

This commit is contained in:
Vladislav Nepogodin 2024-07-13 03:45:32 +04:00
parent 809786d547
commit 48d2ba56da
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
3 changed files with 13 additions and 55 deletions

View File

@ -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)

View File

@ -4,33 +4,13 @@
#include <cassert>
#include <algorithm>
#include <ranges>
#include <string>
#include <string_view>
#include <spdlog/sinks/callback_sink.h>
#include <spdlog/spdlog.h>
#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 <range/v3/range/conversion.hpp>
#include <range/v3/view/filter.hpp>
#include <range/v3/view/join.hpp>
#include <range/v3/view/split.hpp>
#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<size_t>(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<size_t>(std::ranges::distance(rng)));
return !line.empty() && !line.starts_with("# ");
})
| ranges::views::join('\n')
| ranges::to<std::string>();
| std::ranges::views::join_with('\n')
| std::ranges::to<std::string>();
return result + '\n';
}

View File

@ -6,34 +6,12 @@
#include <filesystem>
#include <fstream>
#include <ranges>
#include <string_view>
#include <fmt/core.h>
#include <spdlog/sinks/callback_sink.h>
#include <spdlog/spdlog.h>
#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 <range/v3/range/conversion.hpp>
#include <range/v3/view/filter.hpp>
#include <range/v3/view/join.hpp>
#include <range/v3/view/split.hpp>
#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<size_t>(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<size_t>(std::ranges::distance(rng)));
return !line.empty() && !line.starts_with('#');
})
| ranges::views::join('\n')
| ranges::to<std::string>();
| std::ranges::views::join_with('\n')
| std::ranges::to<std::string>();
return result + '\n';
}