mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-02-02 22:07:13 +08:00
👷 gucc: use std ranges from C++23 in unit tests
This commit is contained in:
parent
809786d547
commit
48d2ba56da
@ -46,7 +46,7 @@ add_library(${PROJECT_NAME} #SHARED
|
|||||||
|
|
||||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_DIR}/include)
|
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)
|
if(COS_INSTALLER_BUILD_TESTS)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
@ -4,33 +4,13 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <ranges>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include <spdlog/sinks/callback_sink.h>
|
#include <spdlog/sinks/callback_sink.h>
|
||||||
#include <spdlog/spdlog.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_literals;
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
@ -124,13 +104,13 @@ GRUB_DISABLE_OS_PROBER=false
|
|||||||
)"sv;
|
)"sv;
|
||||||
|
|
||||||
inline auto filtered_res(std::string_view content) noexcept -> std::string {
|
inline auto filtered_res(std::string_view content) noexcept -> std::string {
|
||||||
auto&& result = content | ranges::views::split('\n')
|
auto&& result = content | std::ranges::views::split('\n')
|
||||||
| ranges::views::filter([](auto&& rng) {
|
| std::ranges::views::filter([](auto&& rng) {
|
||||||
auto&& line = std::string_view(&*rng.begin(), static_cast<size_t>(ranges::distance(rng)));
|
auto&& line = std::string_view(&*rng.begin(), static_cast<size_t>(std::ranges::distance(rng)));
|
||||||
return !line.empty() && !line.starts_with("# ");
|
return !line.empty() && !line.starts_with("# ");
|
||||||
})
|
})
|
||||||
| ranges::views::join('\n')
|
| std::ranges::views::join_with('\n')
|
||||||
| ranges::to<std::string>();
|
| std::ranges::to<std::string>();
|
||||||
return result + '\n';
|
return result + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,34 +6,12 @@
|
|||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <ranges>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include <fmt/core.h>
|
|
||||||
|
|
||||||
#include <spdlog/sinks/callback_sink.h>
|
#include <spdlog/sinks/callback_sink.h>
|
||||||
#include <spdlog/spdlog.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;
|
namespace fs = std::filesystem;
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
@ -54,13 +32,13 @@ static constexpr auto LOCALE_GEN_TEST = R"(ru_RU.UTF-8 UTF-8
|
|||||||
)"sv;
|
)"sv;
|
||||||
|
|
||||||
inline auto filtered_res(std::string_view content) noexcept -> std::string {
|
inline auto filtered_res(std::string_view content) noexcept -> std::string {
|
||||||
auto&& result = content | ranges::views::split('\n')
|
auto&& result = content | std::ranges::views::split('\n')
|
||||||
| ranges::views::filter([](auto&& rng) {
|
| std::ranges::views::filter([](auto&& rng) {
|
||||||
auto&& line = std::string_view(&*rng.begin(), static_cast<size_t>(ranges::distance(rng)));
|
auto&& line = std::string_view(&*rng.begin(), static_cast<size_t>(std::ranges::distance(rng)));
|
||||||
return !line.empty() && !line.starts_with('#');
|
return !line.empty() && !line.starts_with('#');
|
||||||
})
|
})
|
||||||
| ranges::views::join('\n')
|
| std::ranges::views::join_with('\n')
|
||||||
| ranges::to<std::string>();
|
| std::ranges::to<std::string>();
|
||||||
return result + '\n';
|
return result + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user