From c37538f83688921c210d5afd522e70292693624b Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Thu, 21 Nov 2024 21:27:09 +0000 Subject: [PATCH] Better catch-utils --- libmamba/tests/CMakeLists.txt | 5 ++++- .../conda_url.hpp | 1 + .../{util => catch-utils}/msvc_catch_byte.cpp | 0 .../catch-utils/msvc_catch_string_view.cpp | 22 +++++++++++++++++++ .../tests/src/core/test_channel_context.cpp | 2 +- libmamba/tests/src/specs/test_channel.cpp | 2 +- 6 files changed, 29 insertions(+), 3 deletions(-) rename libmamba/tests/src/{catch-printer => catch-utils}/conda_url.hpp (97%) rename libmamba/tests/src/{util => catch-utils}/msvc_catch_byte.cpp (100%) create mode 100644 libmamba/tests/src/catch-utils/msvc_catch_string_view.cpp diff --git a/libmamba/tests/CMakeLists.txt b/libmamba/tests/CMakeLists.txt index bc7410a83a..a1069d4ea3 100644 --- a/libmamba/tests/CMakeLists.txt +++ b/libmamba/tests/CMakeLists.txt @@ -12,8 +12,11 @@ set( LIBMAMBA_TEST_SRCS include/mambatests.hpp src/test_main.cpp + # Catch utils + src/catch-utils/conda_url.hpp + src/catch-utils/msvc_catch_byte.cpp + src/catch-utils/msvc_catch_string_view.cpp # Utility library - src/util/msvc_catch_byte.cpp src/util/test_cast.cpp src/util/test_compare.cpp src/util/test_cryptography.cpp diff --git a/libmamba/tests/src/catch-printer/conda_url.hpp b/libmamba/tests/src/catch-utils/conda_url.hpp similarity index 97% rename from libmamba/tests/src/catch-printer/conda_url.hpp rename to libmamba/tests/src/catch-utils/conda_url.hpp index bc3ba072cd..78fccf30bd 100644 --- a/libmamba/tests/src/catch-printer/conda_url.hpp +++ b/libmamba/tests/src/catch-utils/conda_url.hpp @@ -3,6 +3,7 @@ // Distributed under the terms of the BSD 3-Clause License. // // The full license is in the file LICENSE, distributed with this software. +#pragma once #include diff --git a/libmamba/tests/src/util/msvc_catch_byte.cpp b/libmamba/tests/src/catch-utils/msvc_catch_byte.cpp similarity index 100% rename from libmamba/tests/src/util/msvc_catch_byte.cpp rename to libmamba/tests/src/catch-utils/msvc_catch_byte.cpp diff --git a/libmamba/tests/src/catch-utils/msvc_catch_string_view.cpp b/libmamba/tests/src/catch-utils/msvc_catch_string_view.cpp new file mode 100644 index 0000000000..836d17b9d8 --- /dev/null +++ b/libmamba/tests/src/catch-utils/msvc_catch_string_view.cpp @@ -0,0 +1,22 @@ +#ifdef _WIN32 + +// Catch compiled on `conda-forge` for MSVC doesn't support outputting `string_view`. +// So we have to define StringMaker for it ourselves. +// The declaration is present though, so this only causes link errors. + +#include +#include + +#include + +namespace Catch +{ + + std::string StringMaker::convert(std::string_view str) + { + return std::string(str); + } + +} + +#endif diff --git a/libmamba/tests/src/core/test_channel_context.cpp b/libmamba/tests/src/core/test_channel_context.cpp index 73afcf283b..2092ac95a4 100644 --- a/libmamba/tests/src/core/test_channel_context.cpp +++ b/libmamba/tests/src/core/test_channel_context.cpp @@ -13,7 +13,7 @@ #include "mamba/util/flat_set.hpp" #include "mamba/util/url_manip.hpp" -#include "catch-printer/conda_url.hpp" +#include "catch-utils/conda_url.hpp" #include "mambatests.hpp" diff --git a/libmamba/tests/src/specs/test_channel.cpp b/libmamba/tests/src/specs/test_channel.cpp index 922093b498..1266501120 100644 --- a/libmamba/tests/src/specs/test_channel.cpp +++ b/libmamba/tests/src/specs/test_channel.cpp @@ -12,7 +12,7 @@ #include "mamba/util/path_manip.hpp" #include "mamba/util/string.hpp" -#include "catch-printer/conda_url.hpp" +#include "catch-utils/conda_url.hpp" namespace {