Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,16 @@ if(MSVC)
target_sources(_iris_internal_test_base INTERFACE "${CMAKE_CURRENT_LIST_DIR}/cpp.hint")
endif()

# Must be an executable so that its compile flags (e.g. -fPIE) match the tests
add_executable(_iris_internal_test_pch ${CMAKE_CURRENT_LIST_DIR}/pch.cpp)
target_link_libraries(_iris_internal_test_pch PRIVATE Iris::Iris iris_cxx_test Catch2::Catch2WithMain _iris_internal_test_base)
target_precompile_headers(_iris_internal_test_pch PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pch.hpp)
set_target_properties(_iris_internal_test_pch PROPERTIES CXX_EXTENSIONS OFF FOLDER "test")

function(iris_define_internal_test test_name)
iris_define_test(iris_${test_name} ${ARGN})
target_link_libraries(iris_${test_name}_test PRIVATE _iris_internal_test_base)
target_precompile_headers(iris_${test_name}_test REUSE_FROM _iris_internal_test_pch)
target_sources(iris_${test_name}_test PRIVATE FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_FUNCTION_LIST_DIR} FILES ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/iris_test.hpp)
set_target_properties(iris_${test_name}_test PROPERTIES FOLDER "test/iris")
endfunction()
Expand Down
Empty file added test/pch.cpp
Empty file.
39 changes: 39 additions & 0 deletions test/pch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef IRIS_ZZ_TEST_PCH_HPP
#define IRIS_ZZ_TEST_PCH_HPP

// SPDX-License-Identifier: MIT

#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_tostring.hpp>
#include <catch2/catch_template_test_macros.hpp>

#include <algorithm>
#include <array>
#include <bit>
#include <compare>
#include <concepts>
#include <exception>
#include <format>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <memory>
#include <optional>
#include <ranges>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <utility>
#include <variant>
#include <vector>
#include <version>

#include <cstddef>
#include <cstdint>

#endif
12 changes: 8 additions & 4 deletions test/unicode/string/utf8_invalid.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// TODO: we need secure "getenv" in iris library
#define _CRT_SECURE_NO_WARNINGS 1

#include "iris_test.hpp"

#include <iris/unicode/string.hpp>
Expand Down Expand Up @@ -29,11 +26,18 @@ TEST_CASE("utf8_invalid")
namespace unicode = iris::unicode;
using iris::throwf;

#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4996)
#endif
std::filesystem::path const IRIS_ROOT = [] {
char const* IRIS_ROOT_str = std::getenv("IRIS_ROOT");
char const* IRIS_ROOT_str = std::getenv("IRIS_ROOT"); // NOLINT(concurrency-mt-unsafe)
if (!IRIS_ROOT_str) throwf<std::invalid_argument>("IRIS_ROOT is not defined");
return std::filesystem::path(IRIS_ROOT_str);
}();
#ifdef _MSC_VER
# pragma warning(pop)
#endif

auto const test_file_path = IRIS_ROOT / "test" / "unicode" / "string" / "test_data" / "utf8_invalid.txt";
std::ifstream fs8(test_file_path);
Expand Down
Loading