diff --git a/CMakeLists.txt b/CMakeLists.txt index 72f244f2b..5f91ee3cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.30) project(subspace) # compile_commands.json is needed for Subdoc's documentation generation. diff --git a/sus/CMakeLists.txt b/sus/CMakeLists.txt index de3101fa8..a8a12a7c2 100644 --- a/sus/CMakeLists.txt +++ b/sus/CMakeLists.txt @@ -12,216 +12,256 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_library(subspace STATIC "") -add_library(subspace::lib ALIAS subspace) -target_link_libraries(subspace - fmt::fmt -) -target_sources(subspace PUBLIC - "assertions/check.h" - "assertions/debug_check.h" - "assertions/panic.h" - "assertions/panic.cc" - "assertions/unreachable.h" - "boxed/box.h" - "boxed/dyn.h" - "boxed/macros.h" - "choice/__private/all_values_are_unique.h" - "choice/__private/index_of_value.h" - "choice/__private/index_type.h" - "choice/__private/nothing.h" - "choice/__private/ops_concepts.h" - "choice/__private/pack_index.h" - "choice/__private/storage.h" - "choice/__private/type_list.h" - "choice/choice.h" - "choice/choice_types.h" - "choice/macros.h" - "cmp/__private/void_concepts.h" - "cmp/cmp.h" - "cmp/eq.h" - "cmp/ord.h" - "cmp/reverse.h" - "construct/__private/into_ref.h" - "construct/construct.h" - "construct/from.h" - "construct/into.h" - "construct/default.h" - "construct/safe_from_reference.h" - "construct/cast.h" - "collections/__private/slice_methods_impl.inc" - "collections/__private/slice_methods.inc" - "collections/__private/slice_mut_methods.inc" - "collections/__private/sort.h" - "collections/iterators/array_iter.h" - "collections/iterators/chunks.h" - "collections/iterators/drain.h" - "collections/iterators/slice_iter.h" - "collections/iterators/vec_iter.h" - "collections/iterators/windows.h" - "collections/array.h" - "collections/collections.h" - "collections/compat_deque.h" - "collections/compat_forward_list.h" - "collections/compat_list.h" - "collections/compat_map.h" - "collections/compat_queue.h" - "collections/compat_set.h" - "collections/compat_stack.h" - "collections/compat_unordered_map.h" - "collections/compat_unordered_set.h" - "collections/compat_vector.h" - "collections/concat.h" - "collections/join.h" - "collections/slice.h" - "collections/vec.h" - "env/env.h" - "env/var.cc" - "env/var.h" - "error/compat_error.h" - "error/error.h" - "fn/__private/signature.h" - "fn/fn.h" - "fn/fn_dyn.h" - "iter/__private/into_iterator_archetype.h" - "iter/__private/is_generator.h" - "iter/__private/iter_compare.h" - "iter/__private/iterator_end.h" - "iter/__private/step.h" - "iter/adaptors/by_ref.h" - "iter/adaptors/chain.h" - "iter/adaptors/cloned.h" - "iter/adaptors/copied.h" - "iter/adaptors/cycle.h" - "iter/adaptors/enumerate.h" - "iter/adaptors/filter.h" - "iter/adaptors/filter_map.h" - "iter/adaptors/flat_map.h" - "iter/adaptors/flatten.h" - "iter/adaptors/fuse.h" - "iter/adaptors/inspect.h" - "iter/adaptors/map.h" - "iter/adaptors/map_while.h" - "iter/adaptors/moved.h" - "iter/adaptors/peekable.h" - "iter/adaptors/reverse.h" - "iter/adaptors/scan.h" - "iter/adaptors/skip.h" - "iter/adaptors/skip_while.h" - "iter/adaptors/step_by.h" - "iter/adaptors/take.h" - "iter/adaptors/take_while.h" - "iter/adaptors/zip.h" - "iter/compat_ranges.h" - "iter/extend.h" - "iter/from_iterator.h" - "iter/generator.h" - "iter/into_iterator.h" - "iter/iterator.h" - "iter/iterator_concept.h" - "iter/iterator_defn.h" - "iter/iterator_impl.h" - "iter/iterator_loop.h" - "iter/iterator_ref.h" - "iter/once.h" - "iter/product.h" - "iter/repeat.h" - "iter/repeat_with.h" - "iter/size_hint.h" - "iter/size_hint_impl.h" - "iter/successors.h" - "iter/try_from_iterator.h" - "iter/zip.h" - "macros/__private/compiler_bugs.h" - "macros/assume.h" - "macros/arch.h" - "macros/builtin.h" - "macros/compiler.h" - "macros/eval_macro.h" - "macros/for_each.h" - "macros/inline.h" - "macros/lifetimebound.h" - "macros/no_unique_address.h" - "macros/nonnull.h" - "macros/remove_parens.h" - "marker/empty.h" - "marker/unsafe.h" - "mem/__private/data_size_finder.h" - "mem/__private/ref_concepts.h" - "mem/addressof.h" - "mem/clone.h" - "mem/copy.h" - "mem/forward.h" - "mem/move.h" - "mem/never_value_macros.h" - "mem/never_value.h" - "mem/relocate_macros.h" - "mem/relocate.h" - "mem/remove_rvalue_reference.h" - "mem/replace.h" - "mem/size_of.h" - "mem/swap.h" - "mem/take.h" - "num/__private/check_integer_overflow.h" - "num/__private/float_consts.inc" - "num/__private/float_methods.inc" - "num/__private/float_methods_impl.inc" - "num/__private/float_ordering.h" - "num/__private/intrinsics.h" - "num/__private/literals.h" - "num/__private/primitive_type.h" - "num/__private/signed_integer_consts.inc" - "num/__private/signed_integer_methods.inc" - "num/__private/signed_integer_methods_impl.inc" - "num/__private/unsigned_integer_consts.inc" - "num/__private/unsigned_integer_methods.inc" - "num/__private/unsigned_integer_methods_impl.inc" - "num/cast.h" - "num/float.h" - "num/float_concepts.h" - "num/float_impl.h" - "num/fp_category.h" - "num/integer_concepts.h" - "num/overflow_integer.h" - "num/signed_integer.h" - "num/signed_integer_impl.h" - "num/try_from_int_error.h" - "num/try_from_int_error_impl.h" - "num/num_concepts.h" - "num/unsigned_integer.h" - "num/unsigned_integer_impl.h" - "option/__private/is_option_type.h" - "option/__private/is_tuple_type.h" - "option/__private/marker.h" - "option/__private/storage.h" - "option/option_iter.h" - "option/option.h" - "option/compat_option.h" - "option/state.h" - "ops/range.h" - "ops/range_literals.h" - "ptr/copy.h" - "ptr/nonnull.h" - "ptr/as_ref.h" - "ptr/subclass.h" - "ptr/swap.h" - "result/__private/is_result_type.h" - "result/__private/marker.h" - "result/__private/storage.h" - "result/ok_void.h" - "result/result.h" - "string/__private/any_formatter.h" - "string/__private/bytes_formatter.h" - "string/__private/format_to_stream.h" - "string/compat_string.h" - "tuple/__private/storage.h" - "tuple/tuple.h" - "lib/lib.h" - "lib/lib.cc" -) +# Builds the Subspace library. Since the library depends on configuration macros, +# we need to rebuild the library any time those macros are used, so that we can +# test the modules build. +function(build_subspace_library) + cmake_parse_arguments(SUS + "" # No-arg options + "NAME" # Single-arg options + "DEFINE" # Multi-arg options + ${ARGN} # Parameters to parse + ) + + add_library(${SUS_NAME} STATIC + "assertions/panic.cc" + "env/var.cc" + "lib/lib.cc" + ) -# Subspace library -subspace_default_compile_options(subspace) + target_link_libraries(${SUS_NAME} + fmt::fmt + ) + + subspace_default_compile_options(${SUS_NAME}) + target_sources(${SUS_NAME} PUBLIC + "assertions/check.h" + "assertions/debug_check.h" + "assertions/panic.h" + "assertions/panic.cc" + "assertions/unreachable.h" + "boxed/box.h" + "boxed/dyn.h" + "boxed/macros.h" + "choice/__private/all_values_are_unique.h" + "choice/__private/index_of_value.h" + "choice/__private/index_type.h" + "choice/__private/nothing.h" + "choice/__private/ops_concepts.h" + "choice/__private/pack_index.h" + "choice/__private/storage.h" + "choice/__private/type_list.h" + "choice/choice.h" + "choice/choice_types.h" + "choice/macros.h" + "cmp/__private/void_concepts.h" + "cmp/cmp.h" + "cmp/eq.h" + "cmp/ord.h" + "cmp/reverse.h" + "construct/__private/into_ref.h" + "construct/construct.h" + "construct/from.h" + "construct/into.h" + "construct/default.h" + "construct/safe_from_reference.h" + "construct/cast.h" + "collections/__private/slice_methods_impl.inc" + "collections/__private/slice_methods.inc" + "collections/__private/slice_mut_methods.inc" + "collections/__private/sort.h" + "collections/iterators/array_iter.h" + "collections/iterators/chunks.h" + "collections/iterators/drain.h" + "collections/iterators/slice_iter.h" + "collections/iterators/vec_iter.h" + "collections/iterators/windows.h" + "collections/array.h" + "collections/collections.h" + "collections/compat_deque.h" + "collections/compat_forward_list.h" + "collections/compat_list.h" + "collections/compat_map.h" + "collections/compat_queue.h" + "collections/compat_set.h" + "collections/compat_stack.h" + "collections/compat_unordered_map.h" + "collections/compat_unordered_set.h" + "collections/compat_vector.h" + "collections/concat.h" + "collections/join.h" + "collections/slice.h" + "collections/vec.h" + "env/env.h" + "env/var.cc" + "env/var.h" + "error/compat_error.h" + "error/error.h" + "fn/__private/signature.h" + "fn/fn.h" + "fn/fn_dyn.h" + "iter/__private/into_iterator_archetype.h" + "iter/__private/is_generator.h" + "iter/__private/iter_compare.h" + "iter/__private/iterator_end.h" + "iter/__private/step.h" + "iter/adaptors/by_ref.h" + "iter/adaptors/chain.h" + "iter/adaptors/cloned.h" + "iter/adaptors/copied.h" + "iter/adaptors/cycle.h" + "iter/adaptors/enumerate.h" + "iter/adaptors/filter.h" + "iter/adaptors/filter_map.h" + "iter/adaptors/flat_map.h" + "iter/adaptors/flatten.h" + "iter/adaptors/fuse.h" + "iter/adaptors/inspect.h" + "iter/adaptors/map.h" + "iter/adaptors/map_while.h" + "iter/adaptors/moved.h" + "iter/adaptors/peekable.h" + "iter/adaptors/reverse.h" + "iter/adaptors/scan.h" + "iter/adaptors/skip.h" + "iter/adaptors/skip_while.h" + "iter/adaptors/step_by.h" + "iter/adaptors/take.h" + "iter/adaptors/take_while.h" + "iter/adaptors/zip.h" + "iter/compat_ranges.h" + "iter/extend.h" + "iter/from_iterator.h" + "iter/generator.h" + "iter/into_iterator.h" + "iter/iterator.h" + "iter/iterator_concept.h" + "iter/iterator_defn.h" + "iter/iterator_impl.h" + "iter/iterator_loop.h" + "iter/iterator_ref.h" + "iter/once.h" + "iter/product.h" + "iter/repeat.h" + "iter/repeat_with.h" + "iter/size_hint.h" + "iter/size_hint_impl.h" + "iter/successors.h" + "iter/try_from_iterator.h" + "iter/zip.h" + "macros/__private/compiler_bugs.h" + "macros/assume.h" + "macros/arch.h" + "macros/builtin.h" + "macros/compiler.h" + "macros/eval_macro.h" + "macros/for_each.h" + "macros/inline.h" + "macros/lifetimebound.h" + "macros/no_unique_address.h" + "macros/nonnull.h" + "macros/remove_parens.h" + "marker/empty.h" + "marker/unsafe.h" + "mem/__private/data_size_finder.h" + "mem/__private/ref_concepts.h" + "mem/addressof.h" + "mem/clone.h" + "mem/copy.h" + "mem/forward.h" + "mem/move.h" + "mem/never_value_macros.h" + "mem/never_value.h" + "mem/relocate_macros.h" + "mem/relocate.h" + "mem/remove_rvalue_reference.h" + "mem/replace.h" + "mem/size_of.h" + "mem/swap.h" + "mem/take.h" + "num/__private/check_integer_overflow.h" + "num/__private/float_consts.inc" + "num/__private/float_methods.inc" + "num/__private/float_methods_impl.inc" + "num/__private/float_ordering.h" + "num/__private/intrinsics.h" + "num/__private/literals.h" + "num/__private/primitive_type.h" + "num/__private/signed_integer_consts.inc" + "num/__private/signed_integer_methods.inc" + "num/__private/signed_integer_methods_impl.inc" + "num/__private/unsigned_integer_consts.inc" + "num/__private/unsigned_integer_methods.inc" + "num/__private/unsigned_integer_methods_impl.inc" + "num/cast.h" + "num/float.h" + "num/float_concepts.h" + "num/float_impl.h" + "num/fp_category.h" + "num/integer_concepts.h" + "num/overflow_integer.h" + "num/signed_integer.h" + "num/signed_integer_impl.h" + "num/try_from_int_error.h" + "num/try_from_int_error_impl.h" + "num/num_concepts.h" + "num/unsigned_integer.h" + "num/unsigned_integer_impl.h" + "option/__private/is_option_type.h" + "option/__private/is_tuple_type.h" + "option/__private/marker.h" + "option/__private/storage.h" + "option/option_iter.h" + "option/option.h" + "option/compat_option.h" + "option/state.h" + "ops/range.h" + "ops/range_literals.h" + "ptr/copy.h" + "ptr/nonnull.h" + "ptr/as_ref.h" + "ptr/subclass.h" + "ptr/swap.h" + "result/__private/is_result_type.h" + "result/__private/marker.h" + "result/__private/storage.h" + "result/ok_void.h" + "result/result.h" + "string/__private/any_formatter.h" + "string/__private/bytes_formatter.h" + "string/__private/format_to_stream.h" + "string/compat_string.h" + "tuple/__private/storage.h" + "tuple/tuple.h" + "lib/lib.h" + "lib/lib.cc" + ) + target_sources(${SUS_NAME} PUBLIC + FILE_SET CXX_MODULES + FILES "sus.cc" + ) + target_compile_definitions(${SUS_NAME} PRIVATE + ${SUS_DEFINE} + ) + add_library(${SUS_NAME}::lib ALIAS ${SUS_NAME}) + + if(SUBSPACE_BUILD_TESTS) + # Subspace test support + add_library(${SUS_NAME}_test_support STATIC "") + add_library(${SUS_NAME}::test_support ALIAS ${SUS_NAME}_test_support) + target_sources(${SUS_NAME}_test_support PUBLIC + "test/behaviour_types.h" + "test/behaviour_types_unittest.cc" + "test/ensure_use.cc" + "test/ensure_use.h" + "test/no_copy_move.h" + ) + subspace_test_default_compile_options(${SUS_NAME}_test_support) + target_link_libraries(${SUS_NAME}_test_support PRIVATE ${SUS_NAME}::lib) + endif() +endfunction() + +build_subspace_library(NAME subspace) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") @@ -234,18 +274,62 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND target_compile_options(subspace PUBLIC /w) endif() -if(${SUBSPACE_BUILD_TESTS}) - add_library(subspace_test_support STATIC "") - add_library(subspace::test_support ALIAS subspace_test_support) - target_sources(subspace_test_support PUBLIC - "test/behaviour_types.h" - "test/behaviour_types_unittest.cc" - "test/ensure_use.cc" - "test/ensure_use.h" - "test/no_copy_move.h" +include(CMakeParseArguments) + +function(add_subspace_test) + cmake_parse_arguments(SUS + "" # No-arg options + "NAME" # Single-arg options + "SRCS;DEFINE;COMPILE_OPTIONS;DEPS" # Multi-arg options + ${ARGN} # Parameters to parse + ) + + add_executable(${SUS_NAME} ${SUS_SRCS}) + subspace_test_default_compile_options(${SUS_NAME}) + target_compile_definitions(${SUS_NAME} PRIVATE ${SUS_DEFINE}) + target_compile_options(${SUS_NAME} PRIVATE ${SUS_COMPILE_OPTIONS}) + target_link_libraries(${SUS_NAME} PRIVATE + subspace::lib + subspace::test_support + fmt::fmt + gtest_main + ) + + set(test_module_name "${SUS_NAME}_module") + add_executable(${test_module_name} ${SUS_SRCS}) + subspace_test_default_compile_options(${test_module_name}) + target_compile_definitions(${test_module_name} PRIVATE + TEST_MODULE + ${SUS_DEFINE} + ) + target_compile_options(${test_module_name} PRIVATE ${SUS_COMPILE_OPTIONS}) + target_link_libraries(${test_module_name} PRIVATE + fmt::fmt + gtest_main ) - add_executable(subspace_unittests + if(SUS_DEFINE) + set(library_module_name "subspace_${SUS_NAME}") + build_subspace_library(NAME ${library_module_name} + DEFINE ${SUS_DEFINE} + ) + target_link_libraries(${test_module_name} PRIVATE + ${library_module_name} + ${library_module_name}::test_support + ) + else() + target_link_libraries(${test_module_name} PRIVATE + subspace::lib + subspace::test_support + ) + endif() + + gtest_discover_tests(${SUS_NAME}) + gtest_discover_tests(${test_module_name}) +endfunction() + +if(${SUBSPACE_BUILD_TESTS}) + set(subspace_unittest_list "assertions/check_unittest.cc" "assertions/panic_unittest.cc" "assertions/unreachable_unittest.cc" @@ -268,8 +352,6 @@ if(${SUBSPACE_BUILD_TESTS}) "collections/compat_unordered_map_unittest.cc" "collections/compat_unordered_set_unittest.cc" "collections/compat_vector_unittest.cc" - "collections/invalidation_off_size_unittest.cc" - "collections/invalidation_on_size_unittest.cc" "collections/slice_unittest.cc" "collections/vec_unittest.cc" "construct/from_unittest.cc" @@ -330,58 +412,31 @@ if(${SUBSPACE_BUILD_TESTS}) "tuple/tuple_unittest.cc" ) - add_executable(subspace_panic_elide_message_unittest - "assertions/panic_unittest.cc" - ) - - add_executable(subspace_overflow_unittests - "num/i8_overflow_unittest.cc" - "num/i16_overflow_unittest.cc" - "num/i32_overflow_unittest.cc" - "num/i64_overflow_unittest.cc" - "num/isize_overflow_unittest.cc" - "num/u8_overflow_unittest.cc" - "num/u16_overflow_unittest.cc" - "num/u32_overflow_unittest.cc" - "num/u64_overflow_unittest.cc" - "num/uptr_overflow_unittest.cc" - "num/usize_overflow_unittest.cc" - ) - - # Subspace test support - subspace_test_default_compile_options(subspace_test_support) - target_link_libraries(subspace_test_support subspace::lib) - - # Subspace unittests - subspace_test_default_compile_options(subspace_unittests) - target_link_libraries(subspace_unittests - subspace::lib - subspace::test_support - gtest_main + add_subspace_test(NAME subspace_unittests + SRCS ${subspace_unittest_list} ) - gtest_discover_tests(subspace_unittests) - - # Subspace panic unittests - subspace_test_default_compile_options(subspace_panic_elide_message_unittest) - target_compile_options(subspace_panic_elide_message_unittest PUBLIC - -DSUS_PANIC_ELIDE_MESSAGE + add_subspace_test(NAME subspace_iterator_invalidation_off_size_unittest + SRCS "collections/invalidation_off_size_unittest.cc" + DEFINE SUS_ITERATOR_INVALIDATION=0 ) - target_link_libraries(subspace_panic_elide_message_unittest - subspace::lib - subspace::test_support - gtest_main + add_subspace_test(NAME subspace_iterator_invalidation_on_size_unittest + SRCS "collections/invalidation_on_size_unittest.cc" + DEFINE SUS_ITERATOR_INVALIDATION=1 ) - gtest_discover_tests(subspace_panic_elide_message_unittest) - # Subspace overflow unittests - subspace_test_default_compile_options(subspace_overflow_unittests) - target_compile_options(subspace_overflow_unittests PUBLIC - -DSUS_CHECK_INTEGER_OVERFLOW=false - ) - target_link_libraries(subspace_overflow_unittests - subspace::lib - subspace::test_support - gtest_main + add_subspace_test(NAME subspace_overflow_unittests + SRCS + "num/i8_overflow_unittest.cc" + "num/i16_overflow_unittest.cc" + "num/i32_overflow_unittest.cc" + "num/i64_overflow_unittest.cc" + "num/isize_overflow_unittest.cc" + "num/u8_overflow_unittest.cc" + "num/u16_overflow_unittest.cc" + "num/u32_overflow_unittest.cc" + "num/u64_overflow_unittest.cc" + "num/uptr_overflow_unittest.cc" + "num/usize_overflow_unittest.cc" + DEFINE SUS_CHECK_INTEGER_OVERFLOW=false ) - gtest_discover_tests(subspace_overflow_unittests) endif() diff --git a/sus/assertions/panic_unittest.cc b/sus/assertions/panic_unittest.cc index 0647d0b4c..f5ea4fa58 100644 --- a/sus/assertions/panic_unittest.cc +++ b/sus/assertions/panic_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/assertions/panic.h" +#endif #include "fmt/format.h" #include "googletest/include/gtest/gtest.h" diff --git a/sus/boxed/box_unittest.cc b/sus/boxed/box_unittest.cc index dd9f75c49..fff49da2d 100644 --- a/sus/boxed/box_unittest.cc +++ b/sus/boxed/box_unittest.cc @@ -12,14 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/boxed/box.h" +#ifdef TEST_MODULE +import sus; + +# include "fmt/format.h" +# include "sus/assertions/check.h" +#else +# include "sus/boxed/box.h" +# include "sus/error/error.h" +# include "sus/iter/iterator.h" +# include "sus/iter/once.h" +# include "sus/ops/range.h" +# include "sus/prelude.h" +#endif #include "googletest/include/gtest/gtest.h" -#include "sus/error/error.h" -#include "sus/iter/iterator.h" -#include "sus/iter/once.h" -#include "sus/ops/range.h" -#include "sus/prelude.h" namespace test::box { struct MyError {}; diff --git a/sus/boxed/dyn_unittest.cc b/sus/boxed/dyn_unittest.cc index 902ff4a8f..363516de8 100644 --- a/sus/boxed/dyn_unittest.cc +++ b/sus/boxed/dyn_unittest.cc @@ -12,11 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/boxed/macros.h" +#else #include "sus/boxed/dyn.h" -#include "googletest/include/gtest/gtest.h" #include "sus/boxed/box.h" #include "sus/prelude.h" +#endif + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" namespace { using namespace sus::boxed; diff --git a/sus/choice/__private/storage.h b/sus/choice/__private/storage.h index f64b4fbc3..56367923a 100644 --- a/sus/choice/__private/storage.h +++ b/sus/choice/__private/storage.h @@ -737,12 +737,12 @@ union Storage> { }; template -static constexpr auto& construct_choice_storage(S& storage) { +constexpr auto& construct_choice_storage(S& storage) { return construct_choice_storage(storage, std::integral_constant()); } template -static constexpr auto& construct_choice_storage( +constexpr auto& construct_choice_storage( S& storage, std::integral_constant) { std::construct_at(&storage.more_); return construct_choice_storage(storage.more_, @@ -750,43 +750,43 @@ static constexpr auto& construct_choice_storage( } template -static constexpr auto& construct_choice_storage( +constexpr auto& construct_choice_storage( S& storage, std::integral_constant) { return storage; } template -static constexpr const auto& find_choice_storage(const S& storage) { +constexpr const auto& find_choice_storage(const S& storage) { return find_choice_storage(storage, std::integral_constant()); } template -static constexpr const auto& find_choice_storage( +constexpr const auto& find_choice_storage( const S& storage, std::integral_constant) { return find_choice_storage(storage.more_, std::integral_constant()); } template -static constexpr const auto& find_choice_storage( +constexpr const auto& find_choice_storage( const S& storage, std::integral_constant) { return storage; } template -static constexpr auto& find_choice_storage_mut(S& storage) { +constexpr auto& find_choice_storage_mut(S& storage) { return find_choice_storage_mut(storage, std::integral_constant()); } template -static constexpr auto& find_choice_storage_mut( +constexpr auto& find_choice_storage_mut( S& storage, std::integral_constant) { return find_choice_storage_mut(storage.more_, std::integral_constant()); } template -static constexpr auto& find_choice_storage_mut( +constexpr auto& find_choice_storage_mut( S& storage, std::integral_constant) { return storage; } diff --git a/sus/choice/choice_types_unittest.cc b/sus/choice/choice_types_unittest.cc index 3ddcf6e9b..89599f865 100644 --- a/sus/choice/choice_types_unittest.cc +++ b/sus/choice/choice_types_unittest.cc @@ -12,9 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/choice/macros.h" +#else #include "sus/choice/choice.h" #include "sus/construct/default.h" #include "sus/mem/relocate.h" +#endif + #include "sus/test/behaviour_types.h" using sus::construct::Default; diff --git a/sus/choice/choice_unittest.cc b/sus/choice/choice_unittest.cc index 8d578c815..b2a7b1012 100644 --- a/sus/choice/choice_unittest.cc +++ b/sus/choice/choice_unittest.cc @@ -12,18 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/choice/choice.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/choice/macros.h" +#include "sus/macros/__private/compiler_bugs.h" +#else +#include "sus/choice/choice.h" -#include "googletest/include/gtest/gtest.h" -#include "sus/assertions/unreachable.h" #include "sus/mem/forward.h" #include "sus/num/types.h" #include "sus/option/option.h" #include "sus/prelude.h" -#include "sus/test/no_copy_move.h" #include "sus/tuple/tuple.h" +#endif + +#include +#include +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" +#include "sus/assertions/unreachable.h" +#include "sus/test/no_copy_move.h" + namespace { enum class Order { diff --git a/sus/cmp/eq_unittest.cc b/sus/cmp/eq_unittest.cc index efdf76a54..b88b96ea5 100644 --- a/sus/cmp/eq_unittest.cc +++ b/sus/cmp/eq_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/cmp/eq.h" +#endif #include "googletest/include/gtest/gtest.h" diff --git a/sus/cmp/ord_unittest.cc b/sus/cmp/ord_unittest.cc index 382aef66d..c179a97e4 100644 --- a/sus/cmp/ord_unittest.cc +++ b/sus/cmp/ord_unittest.cc @@ -12,11 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/cmp/ord.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/num/types.h" #include "sus/prelude.h" +#endif + +#include "sus/macros/__private/compiler_bugs.h" #include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/cmp/reverse_unittest.cc b/sus/cmp/reverse_unittest.cc index 2311fad91..c12534f60 100644 --- a/sus/cmp/reverse_unittest.cc +++ b/sus/cmp/reverse_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/cmp/reverse.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { using namespace sus::cmp; diff --git a/sus/collections/array_unittest.cc b/sus/collections/array_unittest.cc index 8bd4c44bd..08fd9a7c4 100644 --- a/sus/collections/array_unittest.cc +++ b/sus/collections/array_unittest.cc @@ -12,12 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/collections/array.h" -#include -#include - -#include "googletest/include/gtest/gtest.h" #include "sus/cmp/eq.h" #include "sus/cmp/ord.h" #include "sus/construct/into.h" @@ -27,6 +26,13 @@ #include "sus/mem/relocate.h" #include "sus/num/types.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include +#include + +#include "googletest/include/gtest/gtest.h" +#include "fmt/format.h" #include "sus/test/ensure_use.h" using sus::collections::Array; diff --git a/sus/collections/compat_deque_unittest.cc b/sus/collections/compat_deque_unittest.cc index 88aa94ef7..9bd862e3f 100644 --- a/sus/collections/compat_deque_unittest.cc +++ b/sus/collections/compat_deque_unittest.cc @@ -12,11 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_deque.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/compat_forward_list_unittest.cc b/sus/collections/compat_forward_list_unittest.cc index a8748be8c..8ab7491ea 100644 --- a/sus/collections/compat_forward_list_unittest.cc +++ b/sus/collections/compat_forward_list_unittest.cc @@ -12,11 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_forward_list.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include +#include "googletest/include/gtest/gtest.h" namespace sus::test::compat_forward_list { diff --git a/sus/collections/compat_list_unittest.cc b/sus/collections/compat_list_unittest.cc index 0a693ea87..f2ab0126b 100644 --- a/sus/collections/compat_list_unittest.cc +++ b/sus/collections/compat_list_unittest.cc @@ -12,11 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_list.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/compat_map_unittest.cc b/sus/collections/compat_map_unittest.cc index 32f053ec2..3c23270c9 100644 --- a/sus/collections/compat_map_unittest.cc +++ b/sus/collections/compat_map_unittest.cc @@ -12,13 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_map.h" +#include "sus/iter/compat_ranges.h" +#include "sus/prelude.h" +#endif // TEST_MODULE + +#include #include #include "googletest/include/gtest/gtest.h" -#include "sus/iter/compat_ranges.h" -#include "sus/prelude.h" namespace { diff --git a/sus/collections/compat_queue_unittest.cc b/sus/collections/compat_queue_unittest.cc index 7f6c73d4d..973c7fc25 100644 --- a/sus/collections/compat_queue_unittest.cc +++ b/sus/collections/compat_queue_unittest.cc @@ -12,11 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_queue.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/compat_set_unittest.cc b/sus/collections/compat_set_unittest.cc index 933f13975..489c04258 100644 --- a/sus/collections/compat_set_unittest.cc +++ b/sus/collections/compat_set_unittest.cc @@ -12,12 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_set.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/option/option.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/compat_stack_unittest.cc b/sus/collections/compat_stack_unittest.cc index afa4b8916..84aedece2 100644 --- a/sus/collections/compat_stack_unittest.cc +++ b/sus/collections/compat_stack_unittest.cc @@ -12,11 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_stack.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/compat_unordered_map_unittest.cc b/sus/collections/compat_unordered_map_unittest.cc index 08c746207..252d0b916 100644 --- a/sus/collections/compat_unordered_map_unittest.cc +++ b/sus/collections/compat_unordered_map_unittest.cc @@ -12,13 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_unordered_map.h" +#include "sus/iter/compat_ranges.h" +#include "sus/prelude.h" +#endif // TEST_MODULE + #include +#include #include "googletest/include/gtest/gtest.h" -#include "sus/iter/compat_ranges.h" -#include "sus/prelude.h" namespace { diff --git a/sus/collections/compat_unordered_set_unittest.cc b/sus/collections/compat_unordered_set_unittest.cc index 8d62b85f2..377f2564b 100644 --- a/sus/collections/compat_unordered_set_unittest.cc +++ b/sus/collections/compat_unordered_set_unittest.cc @@ -12,12 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_unordered_set.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/option/option.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/compat_vector_unittest.cc b/sus/collections/compat_vector_unittest.cc index 4ac5c2241..d4e468b75 100644 --- a/sus/collections/compat_vector_unittest.cc +++ b/sus/collections/compat_vector_unittest.cc @@ -12,11 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/collections/compat_vector.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/collections/invalidation_off_size_unittest.cc b/sus/collections/invalidation_off_size_unittest.cc index 54a02f1a5..b1bf32816 100644 --- a/sus/collections/invalidation_off_size_unittest.cc +++ b/sus/collections/invalidation_off_size_unittest.cc @@ -14,11 +14,16 @@ #define SUS_ITERATOR_INVALIDATION 0 +#ifdef TEST_MODULE +// This test isn't supported in modules yet (DO NOT SUBMIT) +#else #include "sus/collections/array.h" #include "sus/collections/slice.h" -#include "sus/macros/compiler.h" #include "sus/prelude.h" +#include "sus/macros/compiler.h" +#include "sus/macros/__private/compiler_bugs.h" + using sus::Array; using sus::Slice; @@ -36,3 +41,4 @@ constexpr usize slice_padding = 0u static_assert(alignof(Slice) == alignof(i32*)); static_assert(sizeof(Slice) == sizeof(i32*) + sizeof(usize) + slice_padding); +#endif diff --git a/sus/collections/invalidation_on_size_unittest.cc b/sus/collections/invalidation_on_size_unittest.cc index 2266318f2..4c5200bf1 100644 --- a/sus/collections/invalidation_on_size_unittest.cc +++ b/sus/collections/invalidation_on_size_unittest.cc @@ -14,6 +14,9 @@ #define SUS_ITERATOR_INVALIDATION 1 +#ifdef TEST_MODULE +// This test isn't supported in modules yet (DO NOT SUBMIT) +#else #include "sus/collections/array.h" #include "sus/collections/slice.h" #include "sus/prelude.h" @@ -41,3 +44,4 @@ static_assert(alignof(Slice) == alignof(usize*)); static_assert(sizeof(Slice) == round_up(sizeof(i32*) + sizeof(usize) + sizeof(usize*), alignof(usize*))); +#endif diff --git a/sus/collections/slice_unittest.cc b/sus/collections/slice_unittest.cc index b2c28cb8c..711ed0e57 100644 --- a/sus/collections/slice_unittest.cc +++ b/sus/collections/slice_unittest.cc @@ -12,11 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/collections/slice.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/assertions/check.h" +#include "sus/macros/lifetimebound.h" +#else +#include "sus/collections/slice.h" -#include "googletest/include/gtest/gtest.h" #include "sus/collections/array.h" #include "sus/collections/vec.h" #include "sus/construct/into.h" @@ -27,6 +30,12 @@ #include "sus/num/types.h" #include "sus/prelude.h" #include "sus/result/result.h" +#endif + +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" #include "sus/test/no_copy_move.h" diff --git a/sus/collections/vec_unittest.cc b/sus/collections/vec_unittest.cc index f22acaa31..02b3cf7a2 100644 --- a/sus/collections/vec_unittest.cc +++ b/sus/collections/vec_unittest.cc @@ -12,16 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#include "sus/mem/relocate_macros.h" +#else #include "sus/collections/vec.h" -#include -#include -#include "googletest/include/gtest/gtest.h" #include "sus/iter/extend.h" #include "sus/iter/iterator.h" #include "sus/mem/move.h" #include "sus/prelude.h" +#endif + +#include +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/construct/cast_unittest.cc b/sus/construct/cast_unittest.cc index da6b391bf..67df7e612 100644 --- a/sus/construct/cast_unittest.cc +++ b/sus/construct/cast_unittest.cc @@ -12,10 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#include "sus/assertions/check.h" +#else #include "sus/construct/cast.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif // TEST_MODULE + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/construct/default_unittest.cc b/sus/construct/default_unittest.cc index e5727fb45..a80002e73 100644 --- a/sus/construct/default_unittest.cc +++ b/sus/construct/default_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if TEST_MODULE +import sus; +#else #include "sus/construct/default.h" +#endif using sus::construct::Default; diff --git a/sus/construct/from_unittest.cc b/sus/construct/from_unittest.cc index a37fcca07..7d4b4249a 100644 --- a/sus/construct/from_unittest.cc +++ b/sus/construct/from_unittest.cc @@ -12,10 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/construct/from.h" #include "sus/construct/into.h" #include "sus/result/result.h" +#endif // TEST_MODULE using sus::construct::From; using sus::construct::TryFrom; diff --git a/sus/construct/into_unittest.cc b/sus/construct/into_unittest.cc index 3b3314b9d..8def5c6cd 100644 --- a/sus/construct/into_unittest.cc +++ b/sus/construct/into_unittest.cc @@ -12,17 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/construct/into.h" -#include "googletest/include/gtest/gtest.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/mem/forward.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/__private/compiler_bugs.h" #include "sus/test/behaviour_types.h" using sus::construct::From; using sus::construct::Into; -using sus::construct::__private::IntoRef; using namespace sus::test; namespace { diff --git a/sus/env/var_unittest.cc b/sus/env/var_unittest.cc index 457182006..7a598bc3f 100644 --- a/sus/env/var_unittest.cc +++ b/sus/env/var_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/env/var.h" +#endif #include "googletest/include/gtest/gtest.h" diff --git a/sus/error/error_unittest.cc b/sus/error/error_unittest.cc index e943f1127..1eba9c7fd 100644 --- a/sus/error/error_unittest.cc +++ b/sus/error/error_unittest.cc @@ -12,15 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/error/error.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/assertions/check.h" +#include "sus/assertions/unreachable.h" +#else +#include "sus/error/error.h" -#include "googletest/include/gtest/gtest.h" #include "sus/boxed/box.h" #include "sus/env/var.h" #include "sus/mem/clone.h" #include "sus/prelude.h" +#endif + +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" namespace test::error { diff --git a/sus/fn/fn_concepts_unittest.cc b/sus/fn/fn_concepts_unittest.cc index ccf9a6474..720d9fd77 100644 --- a/sus/fn/fn_concepts_unittest.cc +++ b/sus/fn/fn_concepts_unittest.cc @@ -12,14 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/fn/fn_concepts.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/assertions/check.h" +#else +#include "sus/fn/fn_concepts.h" -#include "googletest/include/gtest/gtest.h" #include "sus/mem/move.h" #include "sus/prelude.h" #include "sus/tuple/tuple.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/fn/fn_dyn_unittest.cc b/sus/fn/fn_dyn_unittest.cc index e5d5eafb3..1d315a233 100644 --- a/sus/fn/fn_dyn_unittest.cc +++ b/sus/fn/fn_dyn_unittest.cc @@ -12,11 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if TEST_MODULE +import sus; +#else #include "sus/fn/fn_dyn.h" -#include "googletest/include/gtest/gtest.h" #include "sus/boxed/box.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { using namespace sus::fn; diff --git a/sus/iter/compat_ranges_unittest.cc b/sus/iter/compat_ranges_unittest.cc index dee0dc4c0..717122af6 100644 --- a/sus/iter/compat_ranges_unittest.cc +++ b/sus/iter/compat_ranges_unittest.cc @@ -12,8 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/compat_ranges.h" +#include "sus/collections/vec.h" +#include "sus/iter/empty.h" +#include "sus/iter/iterator.h" +#include "sus/prelude.h" +#endif + +#include #include #include #include @@ -22,10 +34,6 @@ #include #include "googletest/include/gtest/gtest.h" -#include "sus/collections/vec.h" -#include "sus/iter/empty.h" -#include "sus/iter/iterator.h" -#include "sus/prelude.h" namespace { diff --git a/sus/iter/empty_unittest.cc b/sus/iter/empty_unittest.cc index 7cd9f1876..6fa422bc1 100644 --- a/sus/iter/empty_unittest.cc +++ b/sus/iter/empty_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/empty.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/iter/generator_unittest.cc b/sus/iter/generator_unittest.cc index 8b981309d..24a5064a8 100644 --- a/sus/iter/generator_unittest.cc +++ b/sus/iter/generator_unittest.cc @@ -12,11 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/generator.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/iterator.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" #include "sus/test/no_copy_move.h" namespace { diff --git a/sus/iter/iterator_unittest.cc b/sus/iter/iterator_unittest.cc index 1fe928830..6c81171c2 100644 --- a/sus/iter/iterator_unittest.cc +++ b/sus/iter/iterator_unittest.cc @@ -12,12 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/iter/iterator.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/assertions/check.h" +#include "sus/mem/relocate_macros.h" +#else +#include "sus/iter/iterator.h" -#include "googletest/include/gtest/gtest.h" -#include "sus/assertions/unreachable.h" #include "sus/cmp/eq.h" #include "sus/collections/array.h" #include "sus/collections/vec.h" @@ -28,11 +30,17 @@ #include "sus/iter/empty.h" #include "sus/iter/into_iterator.h" #include "sus/iter/zip.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/mem/never_value.h" #include "sus/mem/replace.h" #include "sus/num/overflow_integer.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" +#include "sus/assertions/unreachable.h" +#include "sus/macros/__private/compiler_bugs.h" #include "sus/test/no_copy_move.h" using sus::collections::Array; diff --git a/sus/iter/once_with_unittest.cc b/sus/iter/once_with_unittest.cc index f7b8dcf6f..a38bdbb59 100644 --- a/sus/iter/once_with_unittest.cc +++ b/sus/iter/once_with_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/once_with.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/iter/repeat_unittest.cc b/sus/iter/repeat_unittest.cc index b77695de3..b61eb4abe 100644 --- a/sus/iter/repeat_unittest.cc +++ b/sus/iter/repeat_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/repeat.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/iter/repeat_with_unittest.cc b/sus/iter/repeat_with_unittest.cc index d4538c0b9..5de11858a 100644 --- a/sus/iter/repeat_with_unittest.cc +++ b/sus/iter/repeat_with_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/repeat_with.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/iter/successors_unittest.cc b/sus/iter/successors_unittest.cc index 1466bc82a..395b81cc5 100644 --- a/sus/iter/successors_unittest.cc +++ b/sus/iter/successors_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/iter/successors.h" -#include "googletest/include/gtest/gtest.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/marker/unsafe_unittest.cc b/sus/marker/unsafe_unittest.cc index 6bf7cb25d..1768e285b 100644 --- a/sus/marker/unsafe_unittest.cc +++ b/sus/marker/unsafe_unittest.cc @@ -12,10 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/marker/unsafe.h" +#endif #include +#include "fmt/format.h" #include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/mem/addressof_unittest.cc b/sus/mem/addressof_unittest.cc index 7a9d923ce..b2a1f99c7 100644 --- a/sus/mem/addressof_unittest.cc +++ b/sus/mem/addressof_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/mem/addressof.h" +#endif #include "googletest/include/gtest/gtest.h" #include "sus/macros/__private/compiler_bugs.h" diff --git a/sus/mem/clone_unittest.cc b/sus/mem/clone_unittest.cc index 66df9d79e..0f8a9c6ec 100644 --- a/sus/mem/clone_unittest.cc +++ b/sus/mem/clone_unittest.cc @@ -12,12 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/mem/clone.h" -#include "googletest/include/gtest/gtest.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/num/types.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/__private/compiler_bugs.h" using sus::mem::Clone; using sus::mem::clone; diff --git a/sus/mem/move_unittest.cc b/sus/mem/move_unittest.cc index 46e619620..b41c4800a 100644 --- a/sus/mem/move_unittest.cc +++ b/sus/mem/move_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/mem/move.h" +#endif #include "googletest/include/gtest/gtest.h" diff --git a/sus/mem/relocate_macros.h b/sus/mem/relocate_macros.h index 6c92b9771..8e3ad1f00 100644 --- a/sus/mem/relocate_macros.h +++ b/sus/mem/relocate_macros.h @@ -14,6 +14,8 @@ #pragma once +#include "sus/macros/compiler.h" + /// An attribute to allow a class to be passed in registers. /// /// This should only be used when the class is also marked as unconditionally diff --git a/sus/mem/relocate_unittest.cc b/sus/mem/relocate_unittest.cc index efa79b601..1f8cb63c3 100644 --- a/sus/mem/relocate_unittest.cc +++ b/sus/mem/relocate_unittest.cc @@ -12,10 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/mem/relocate_macros.h" +#else #include "sus/mem/relocate.h" #include "sus/num/types.h" #include "sus/prelude.h" +#endif + +#include namespace { diff --git a/sus/mem/size_of_unittest.cc b/sus/mem/size_of_unittest.cc index 5a810b197..f9008cb09 100644 --- a/sus/mem/size_of_unittest.cc +++ b/sus/mem/size_of_unittest.cc @@ -12,15 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/mem/size_of.h" +#include "sus/num/types.h" +#include "sus/prelude.h" +#endif #include #include "googletest/include/gtest/gtest.h" #include "sus/macros/compiler.h" #include "sus/macros/no_unique_address.h" -#include "sus/num/types.h" -#include "sus/prelude.h" namespace { diff --git a/sus/mem/swap_unittest.cc b/sus/mem/swap_unittest.cc index 71f0c768d..8004f8892 100644 --- a/sus/mem/swap_unittest.cc +++ b/sus/mem/swap_unittest.cc @@ -12,16 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/mem/swap.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/mem/relocate_macros.h" +#else +#include "sus/mem/swap.h" -#include "googletest/include/gtest/gtest.h" #include "sus/collections/array.h" -#include "sus/macros/builtin.h" #include "sus/mem/relocate.h" #include "sus/ops/range_literals.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/builtin.h" namespace { diff --git a/sus/mem/take_unittest.cc b/sus/mem/take_unittest.cc index c96c4945a..0779a0d82 100644 --- a/sus/mem/take_unittest.cc +++ b/sus/mem/take_unittest.cc @@ -12,13 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/mem/take.h" +#include "sus/num/types.h" +#include "sus/prelude.h" +#endif + #include #include "googletest/include/gtest/gtest.h" -#include "sus/num/types.h" -#include "sus/prelude.h" namespace sus::mem { namespace { diff --git a/sus/num/cast_unittest.cc b/sus/num/cast_unittest.cc index 05d8fe3b2..fc0c323f6 100644 --- a/sus/num/cast_unittest.cc +++ b/sus/num/cast_unittest.cc @@ -12,10 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/num/cast.h" +#include "sus/prelude.h" +#endif #include "googletest/include/gtest/gtest.h" -#include "sus/prelude.h" namespace { diff --git a/sus/num/f32_unittest.cc b/sus/num/f32_unittest.cc index 72df7ed02..39426714b 100644 --- a/sus/num/f32_unittest.cc +++ b/sus/num/f32_unittest.cc @@ -12,12 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include - -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/cmp/eq.h" #include "sus/cmp/ord.h" #include "sus/collections/array.h" @@ -25,6 +22,17 @@ #include "sus/num/__private/intrinsics.h" #include "sus/num/types.h" #include "sus/prelude.h" +#endif + +#include + +#include +#include +#include +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" #define F32_NEAR(a, b, c) \ EXPECT_NEAR((a).primitive_value, (b).primitive_value, (c).primitive_value); diff --git a/sus/num/f64_unittest.cc b/sus/num/f64_unittest.cc index 84f18411b..821c6765b 100644 --- a/sus/num/f64_unittest.cc +++ b/sus/num/f64_unittest.cc @@ -12,17 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else +#include "sus/cmp/eq.h" +#include "sus/cmp/ord.h" +#include "sus/collections/array.h" +#include "sus/num/types.h" +#include "sus/prelude.h" +#endif + +#include + #include #include #include #include +#include "fmt/format.h" #include "googletest/include/gtest/gtest.h" -#include "sus/cmp/eq.h" -#include "sus/cmp/ord.h" -#include "sus/collections/array.h" -#include "sus/num/types.h" -#include "sus/prelude.h" #define F64_NEAR(a, b, c) \ EXPECT_NEAR((a).primitive_value, (b).primitive_value, (c).primitive_value); diff --git a/sus/num/i16_overflow_unittest.cc b/sus/num/i16_overflow_unittest.cc index 2138b9fb8..9da1f43eb 100644 --- a/sus/num/i16_overflow_unittest.cc +++ b/sus/num/i16_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/i32_overflow_unittest.cc b/sus/num/i32_overflow_unittest.cc index 7e5c72c71..eb72a42ef 100644 --- a/sus/num/i32_overflow_unittest.cc +++ b/sus/num/i32_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/i64_overflow_unittest.cc b/sus/num/i64_overflow_unittest.cc index a070a342f..6ec69a79c 100644 --- a/sus/num/i64_overflow_unittest.cc +++ b/sus/num/i64_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/i8_overflow_unittest.cc b/sus/num/i8_overflow_unittest.cc index 906362cd3..ff1d4f24e 100644 --- a/sus/num/i8_overflow_unittest.cc +++ b/sus/num/i8_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/isize_overflow_unittest.cc b/sus/num/isize_overflow_unittest.cc index a89f1c824..f389e9be3 100644 --- a/sus/num/isize_overflow_unittest.cc +++ b/sus/num/isize_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/overflow_integer_unittest.cc b/sus/num/overflow_integer_unittest.cc index c00bde2d4..c82c04361 100644 --- a/sus/num/overflow_integer_unittest.cc +++ b/sus/num/overflow_integer_unittest.cc @@ -12,16 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/num/overflow_integer.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/assertions/check.h" +#else +#include "sus/num/overflow_integer.h" -#include "googletest/include/gtest/gtest.h" #include "sus/collections/array.h" #include "sus/iter/iterator.h" #include "sus/num/signed_integer.h" #include "sus/num/unsigned_integer.h" #include "sus/prelude.h" +#endif + +#include + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/u16_overflow_unittest.cc b/sus/num/u16_overflow_unittest.cc index c6753d53e..ca9deb8f4 100644 --- a/sus/num/u16_overflow_unittest.cc +++ b/sus/num/u16_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/u32_overflow_unittest.cc b/sus/num/u32_overflow_unittest.cc index c835e3d5c..9c1ba3362 100644 --- a/sus/num/u32_overflow_unittest.cc +++ b/sus/num/u32_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/u64_overflow_unittest.cc b/sus/num/u64_overflow_unittest.cc index 5d4f24c6c..484d13554 100644 --- a/sus/num/u64_overflow_unittest.cc +++ b/sus/num/u64_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/u8_overflow_unittest.cc b/sus/num/u8_overflow_unittest.cc index 1b8dbc6b0..89a9139e6 100644 --- a/sus/num/u8_overflow_unittest.cc +++ b/sus/num/u8_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/uptr_overflow_unittest.cc b/sus/num/uptr_overflow_unittest.cc index bb932342a..46c072b44 100644 --- a/sus/num/uptr_overflow_unittest.cc +++ b/sus/num/uptr_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/usize_overflow_unittest.cc b/sus/num/usize_overflow_unittest.cc index df33c271b..c14f5f657 100644 --- a/sus/num/usize_overflow_unittest.cc +++ b/sus/num/usize_overflow_unittest.cc @@ -12,8 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" #include "sus/test/ensure_use.h" namespace { diff --git a/sus/num/usize_unittest.cc b/sus/num/usize_unittest.cc index 65810fc6e..5170e3329 100644 --- a/sus/num/usize_unittest.cc +++ b/sus/num/usize_unittest.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - -#include "googletest/include/gtest/gtest.h" +#ifdef TEST_MODULE +import sus; +#else #include "sus/collections/array.h" #include "sus/construct/into.h" #include "sus/iter/__private/step.h" @@ -25,6 +25,12 @@ #include "sus/cmp/ord.h" #include "sus/prelude.h" #include "sus/tuple/tuple.h" +#endif + +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/ops/range_unittest.cc b/sus/ops/range_unittest.cc index f9740c173..bfdf44b88 100644 --- a/sus/ops/range_unittest.cc +++ b/sus/ops/range_unittest.cc @@ -12,14 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/ops/range.h" -#include - -#include "googletest/include/gtest/gtest.h" #include "sus/construct/default.h" #include "sus/macros/compiler.h" #include "sus/prelude.h" +#endif + +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/option/compat_option_unittest.cc b/sus/option/compat_option_unittest.cc index b5a84d447..f4580ccfd 100644 --- a/sus/option/compat_option_unittest.cc +++ b/sus/option/compat_option_unittest.cc @@ -12,12 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/option/compat_option.h" -#include "googletest/include/gtest/gtest.h" #include "sus/construct/into.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/__private/compiler_bugs.h" namespace { diff --git a/sus/option/option_types_unittest.cc b/sus/option/option_types_unittest.cc index 8b61d3497..40e4eebfe 100644 --- a/sus/option/option_types_unittest.cc +++ b/sus/option/option_types_unittest.cc @@ -12,9 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/construct/default.h" #include "sus/mem/relocate.h" #include "sus/option/option.h" +#endif + +#include + #include "sus/test/behaviour_types.h" #include "sus/test/no_copy_move.h" diff --git a/sus/option/option_unittest.cc b/sus/option/option_unittest.cc index 7b639bff9..8f3f91b6e 100644 --- a/sus/option/option_unittest.cc +++ b/sus/option/option_unittest.cc @@ -12,23 +12,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/option/option.h" +#ifdef TEST_MODULE +import sus; -#include -#include +#include "sus/mem/never_value_macros.h" +#else +#include "sus/option/option.h" -#include "fmt/std.h" -#include "googletest/include/gtest/gtest.h" #include "sus/collections/array.h" #include "sus/iter/from_iterator.h" #include "sus/iter/iterator.h" -#include "sus/macros/__private/compiler_bugs.h" -#include "sus/macros/builtin.h" #include "sus/mem/relocate.h" #include "sus/num/types.h" #include "sus/prelude.h" #include "sus/ptr/nonnull.h" #include "sus/result/result.h" +#endif + +#include +#include +#include + +#include "fmt/std.h" +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/__private/compiler_bugs.h" +#include "sus/macros/builtin.h" #include "sus/test/behaviour_types.h" #include "sus/test/no_copy_move.h" #include "sus/tuple/tuple.h" diff --git a/sus/ptr/as_ref_unittest.cc b/sus/ptr/as_ref_unittest.cc index 8c994810c..6b8100022 100644 --- a/sus/ptr/as_ref_unittest.cc +++ b/sus/ptr/as_ref_unittest.cc @@ -12,12 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/ptr/as_ref.h" +#include "sus/prelude.h" +#endif + #include #include "googletest/include/gtest/gtest.h" -#include "sus/prelude.h" namespace { using sus::Option; diff --git a/sus/ptr/nonnull_types_unittest.cc b/sus/ptr/nonnull_types_unittest.cc index 43656deac..dc8226d84 100644 --- a/sus/ptr/nonnull_types_unittest.cc +++ b/sus/ptr/nonnull_types_unittest.cc @@ -12,10 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/construct/default.h" #include "sus/macros/compiler.h" #include "sus/ptr/nonnull.h" #include "sus/mem/relocate.h" +#endif + +#include + #include "sus/test/behaviour_types.h" using sus::construct::Default; diff --git a/sus/ptr/nonnull_unittest.cc b/sus/ptr/nonnull_unittest.cc index 7ea25f515..1c04bf0be 100644 --- a/sus/ptr/nonnull_unittest.cc +++ b/sus/ptr/nonnull_unittest.cc @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/ptr/nonnull.h" -#include - -#include "googletest/include/gtest/gtest.h" #include "sus/construct/into.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/mem/forward.h" #include "sus/mem/never_value.h" #include "sus/mem/relocate.h" @@ -27,6 +26,13 @@ #include "sus/cmp/ord.h" #include "sus/option/option.h" #include "sus/prelude.h" +#endif + +#include + +#include "fmt/format.h" +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/__private/compiler_bugs.h" using sus::ptr::NonNull; diff --git a/sus/ptr/subclass_unittest.cc b/sus/ptr/subclass_unittest.cc index 85991e18a..4993da995 100644 --- a/sus/ptr/subclass_unittest.cc +++ b/sus/ptr/subclass_unittest.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/ptr/subclass.h" +#endif #include "googletest/include/gtest/gtest.h" diff --git a/sus/ptr/swap_unittest.cc b/sus/ptr/swap_unittest.cc index 46fc510c3..a60d5a9c6 100644 --- a/sus/ptr/swap_unittest.cc +++ b/sus/ptr/swap_unittest.cc @@ -12,12 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/ptr/swap.h" -#include "googletest/include/gtest/gtest.h" #include "sus/collections/array.h" #include "sus/mem/replace.h" #include "sus/prelude.h" +#endif + + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/result/result_types_unittest.cc b/sus/result/result_types_unittest.cc index 985dc937f..d2c5d6a26 100644 --- a/sus/result/result_types_unittest.cc +++ b/sus/result/result_types_unittest.cc @@ -12,9 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/construct/default.h" #include "sus/mem/relocate.h" #include "sus/result/result.h" +#endif + +#include + #include "sus/test/behaviour_types.h" #include "sus/test/no_copy_move.h" diff --git a/sus/result/result_unittest.cc b/sus/result/result_unittest.cc index 11556fe38..00483b00a 100644 --- a/sus/result/result_unittest.cc +++ b/sus/result/result_unittest.cc @@ -12,19 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/result/result.h" +#ifdef TEST_MODULE +import sus; -#include +#include "sus/assertions/check.h" +#else +#include "sus/result/result.h" -#include "fmt/std.h" -#include "googletest/include/gtest/gtest.h" #include "sus/collections/array.h" #include "sus/iter/iterator.h" #include "sus/iter/once.h" -#include "sus/macros/__private/compiler_bugs.h" #include "sus/mem/move.h" #include "sus/num/types.h" #include "sus/prelude.h" +#endif + +#include + +#include "fmt/std.h" +#include "googletest/include/gtest/gtest.h" +#include "sus/macros/__private/compiler_bugs.h" #include "sus/test/behaviour_types.h" #include "sus/test/no_copy_move.h" diff --git a/sus/string/compat_string_unittest.cc b/sus/string/compat_string_unittest.cc index 966bb2d65..949aa3466 100644 --- a/sus/string/compat_string_unittest.cc +++ b/sus/string/compat_string_unittest.cc @@ -12,11 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/assertions/check.h" +#else #include "sus/string/compat_string.h" -#include "googletest/include/gtest/gtest.h" #include "sus/iter/compat_ranges.h" #include "sus/prelude.h" +#endif + +#include "googletest/include/gtest/gtest.h" namespace { diff --git a/sus/sus.cc b/sus/sus.cc new file mode 100644 index 000000000..8d4625556 --- /dev/null +++ b/sus/sus.cc @@ -0,0 +1,806 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +module; +#include "sus/assertions/check.h" +#include "sus/assertions/debug_check.h" +#include "sus/assertions/panic.h" +#include "sus/assertions/unreachable.h" +#include "sus/boxed/__private/string_error.h" +#include "sus/boxed/box.h" +#include "sus/boxed/boxed.h" +#include "sus/boxed/dyn.h" +#include "sus/choice/__private/all_values_are_unique.h" +#include "sus/choice/__private/index_of_value.h" +#include "sus/choice/__private/index_type.h" +#include "sus/choice/__private/nothing.h" +#include "sus/choice/__private/ops_concepts.h" +#include "sus/choice/__private/pack_index.h" +#include "sus/choice/__private/storage.h" +#include "sus/choice/__private/type_list.h" +#include "sus/choice/choice.h" +#include "sus/choice/choice_types.h" +#include "sus/cmp/__private/void_concepts.h" +#include "sus/cmp/cmp.h" +#include "sus/cmp/eq.h" +#include "sus/cmp/ord.h" +#include "sus/cmp/reverse.h" +#include "sus/collections/__private/sort.h" +#include "sus/collections/array.h" +#include "sus/collections/collections.h" +#include "sus/collections/compat_deque.h" +#include "sus/collections/compat_forward_list.h" +#include "sus/collections/compat_list.h" +#include "sus/collections/compat_map.h" +#include "sus/collections/compat_pair_concept.h" +#include "sus/collections/compat_queue.h" +#include "sus/collections/compat_set.h" +#include "sus/collections/compat_stack.h" +#include "sus/collections/compat_unordered_map.h" +#include "sus/collections/compat_unordered_set.h" +#include "sus/collections/compat_vector.h" +#include "sus/collections/concat.h" +#include "sus/collections/iterators/array_iter.h" +#include "sus/collections/iterators/chunks.h" +#include "sus/collections/iterators/drain.h" +#include "sus/collections/iterators/slice_iter.h" +#include "sus/collections/iterators/split.h" +#include "sus/collections/iterators/vec_iter.h" +#include "sus/collections/iterators/windows.h" +#include "sus/collections/join.h" +#include "sus/collections/slice.h" +#include "sus/collections/vec.h" +#include "sus/construct/__private/into_ref.h" +#include "sus/construct/cast.h" +#include "sus/construct/construct.h" +#include "sus/construct/default.h" +#include "sus/construct/from.h" +#include "sus/construct/into.h" +#include "sus/construct/safe_from_reference.h" +#include "sus/env/env.h" +#include "sus/env/var.h" +#include "sus/error/compat_error.h" +#include "sus/error/error.h" +#include "sus/fn/__private/signature.h" +#include "sus/fn/fn.h" +#include "sus/fn/fn_concepts.h" +#include "sus/fn/fn_dyn.h" +#include "sus/iter/__private/into_iterator_archetype.h" +#include "sus/iter/__private/is_generator.h" +#include "sus/iter/__private/iter_compare.h" +#include "sus/iter/__private/iterator_archetype.h" +#include "sus/iter/__private/iterator_end.h" +#include "sus/iter/__private/range_begin.h" +#include "sus/iter/__private/step.h" +#include "sus/iter/adaptors/by_ref.h" +#include "sus/iter/adaptors/chain.h" +#include "sus/iter/adaptors/cloned.h" +#include "sus/iter/adaptors/copied.h" +#include "sus/iter/adaptors/cycle.h" +#include "sus/iter/adaptors/enumerate.h" +#include "sus/iter/adaptors/filter.h" +#include "sus/iter/adaptors/filter_map.h" +#include "sus/iter/adaptors/flat_map.h" +#include "sus/iter/adaptors/flatten.h" +#include "sus/iter/adaptors/fuse.h" +#include "sus/iter/adaptors/inspect.h" +#include "sus/iter/adaptors/map.h" +#include "sus/iter/adaptors/map_while.h" +#include "sus/iter/adaptors/moved.h" +#include "sus/iter/adaptors/peekable.h" +#include "sus/iter/adaptors/reverse.h" +#include "sus/iter/adaptors/scan.h" +#include "sus/iter/adaptors/skip.h" +#include "sus/iter/adaptors/skip_while.h" +#include "sus/iter/adaptors/step_by.h" +#include "sus/iter/adaptors/take.h" +#include "sus/iter/adaptors/take_while.h" +#include "sus/iter/adaptors/zip.h" +#include "sus/iter/compat_ranges.h" +#include "sus/iter/empty.h" +#include "sus/iter/extend.h" +#include "sus/iter/from_iterator.h" +#include "sus/iter/generator.h" +#include "sus/iter/into_iterator.h" +#include "sus/iter/iterator.h" +#include "sus/iter/iterator_concept.h" +#include "sus/iter/iterator_defn.h" +#include "sus/iter/iterator_impl.h" +#include "sus/iter/iterator_loop.h" +#include "sus/iter/iterator_ref.h" +#include "sus/iter/once.h" +#include "sus/iter/once_with.h" +#include "sus/iter/product.h" +#include "sus/iter/repeat.h" +#include "sus/iter/repeat_with.h" +#include "sus/iter/size_hint.h" +#include "sus/iter/size_hint_impl.h" +#include "sus/iter/successors.h" +#include "sus/iter/sum.h" +#include "sus/iter/try_from_iterator.h" +#include "sus/iter/zip.h" +#include "sus/lib/__private/forward_decl.h" +#include "sus/lib/lib.h" +#include "sus/macros/__private/compiler_bugs.h" +#include "sus/macros/arch.h" +#include "sus/macros/assume.h" +#include "sus/macros/builtin.h" +#include "sus/macros/compiler.h" +#include "sus/macros/eval_and_concat.h" +#include "sus/macros/eval_macro.h" +#include "sus/macros/for_each.h" +#include "sus/macros/inline.h" +#include "sus/macros/lifetimebound.h" +#include "sus/macros/no_unique_address.h" +#include "sus/macros/nonnull.h" +#include "sus/macros/pure.h" +#include "sus/macros/remove_parens.h" +#include "sus/marker/empty.h" +#include "sus/marker/unsafe.h" +#include "sus/mem/__private/data_size_finder.h" +#include "sus/mem/__private/ref_concepts.h" +#include "sus/mem/addressof.h" +#include "sus/mem/clone.h" +#include "sus/mem/copy.h" +#include "sus/mem/forward.h" +#include "sus/mem/move.h" +#include "sus/mem/never_value.h" +#include "sus/mem/relocate.h" +#include "sus/mem/remove_rvalue_reference.h" +#include "sus/mem/replace.h" +#include "sus/mem/size_of.h" +#include "sus/mem/swap.h" +#include "sus/mem/take.h" +#include "sus/num/__private/check_integer_overflow.h" +#include "sus/num/__private/float_ordering.h" +#include "sus/num/__private/int_log10.h" +#include "sus/num/__private/intrinsics.h" +#include "sus/num/__private/literals.h" +#include "sus/num/__private/primitive_type.h" +#include "sus/num/cast.h" +#include "sus/num/float.h" +#include "sus/num/float_concepts.h" +#include "sus/num/float_impl.h" +#include "sus/num/fp_category.h" +#include "sus/num/integer_concepts.h" +#include "sus/num/num_concepts.h" +#include "sus/num/overflow_integer.h" +#include "sus/num/signed_integer.h" +#include "sus/num/signed_integer_impl.h" +#include "sus/num/try_from_int_error.h" +#include "sus/num/try_from_int_error_impl.h" +#include "sus/num/types.h" +#include "sus/num/unsigned_integer.h" +#include "sus/num/unsigned_integer_impl.h" +#include "sus/ops/range.h" +#include "sus/ops/range_literals.h" +#include "sus/ops/try.h" +#include "sus/option/__private/is_option_type.h" +#include "sus/option/__private/is_tuple_type.h" +#include "sus/option/__private/marker.h" +#include "sus/option/__private/storage.h" +#include "sus/option/compat_option.h" +#include "sus/option/option.h" +#include "sus/option/option_iter.h" +#include "sus/option/state.h" +#include "sus/prelude.h" +#include "sus/ptr/as_ref.h" +#include "sus/ptr/copy.h" +#include "sus/ptr/nonnull.h" +#include "sus/ptr/subclass.h" +#include "sus/ptr/swap.h" +#include "sus/result/__private/is_result_type.h" +#include "sus/result/__private/marker.h" +#include "sus/result/__private/result_state.h" +#include "sus/result/__private/storage.h" +#include "sus/result/ok_void.h" +#include "sus/result/result.h" +#include "sus/string/__private/any_formatter.h" +#include "sus/string/__private/bytes_formatter.h" +#include "sus/string/__private/format_to_stream.h" +#include "sus/string/compat_string.h" +#include "sus/test/behaviour_types.h" +#include "sus/test/ensure_use.h" +#include "sus/test/no_copy_move.h" +#include "sus/tuple/__private/storage.h" +#include "sus/tuple/tuple.h" + +export module sus; + +export namespace sus { + // Functions + using sus::cast; + using sus::clone_into; + using sus::clone; + using sus::dyn; + using sus::err; + using sus::empty; + using sus::forward; + using sus::into; + using sus::move_into; + using sus::move; + using sus::none; + using sus::some; + using sus::try_into; + using sus::err; + using sus::ok; + using sus::tuple; + using sus::size_of; + using sus::data_size_of; + + // Classes + using sus::Array; + using sus::Box; + using sus::Option; + using sus::Result; + using sus::Slice; + using sus::Vec; + using sus::Choice; + using sus::Slice; + using sus::SliceMut; + using sus::Err; + using sus::Ok; + using sus::Tuple; + using sus::None; + using sus::Some; + + // Type Aliases + using sus::f32; + using sus::f64; + using sus::i16; + using sus::i32; + using sus::i64; + using sus::i8; + using sus::isize; + using sus::u16; + using sus::u32; + using sus::u64; + using sus::u8; + using sus::uptr; + using sus::usize; +} + +export namespace sus::assertions { + // Classes + using sus::assertions::PanicLocation; +} // namespace assertions + +export namespace sus::boxed { + // Classes + using sus::boxed::Box; + using sus::boxed::Dyn; + + // Functions + using sus::boxed::dyn; + + // Concepts + using sus::boxed::DynConcept; +} // namespace boxed + +export namespace sus::choice_type { + // Classes + using sus::choice_type::CanConvertToStorage; + using sus::choice_type::Choice; + + // Concepts + using sus::choice_type::ChoiceValueIsVoid; + + // Exposed to facilitate `sus_choice_types`. + namespace __private { + using sus::choice_type::__private::find_choice_storage_mut; + using sus::choice_type::__private::find_choice_storage; + using sus::choice_type::__private::TypeList; + using sus::choice_type::__private::MakeStorageType; + using sus::choice_type::__private::StorageIsSafelyConstructibleFromReference; + using sus::choice_type::__private::AllValuesAreUnique; + } +} // namespace choice_type + +export namespace sus::cmp { + // Classes + using sus::cmp::Reverse; + + // Functions + using sus::cmp::clamp; + using sus::cmp::max; + using sus::cmp::max_by; + using sus::cmp::max_by_key; + using sus::cmp::min; + using sus::cmp::min_by; + using sus::cmp::min_by_key; + + // Concepts + using sus::cmp::Eq; + using sus::cmp::ExclusiveOrd; + using sus::cmp::ExclusivePartialOrd; + using sus::cmp::ExclusiveStrongOrd; + using sus::cmp::Ord; + using sus::cmp::Ordering; + using sus::cmp::PartialOrd; + using sus::cmp::StrongOrd; +} // namespace cmp + +export namespace sus::collections::compat { + // Concepts + using sus::collections::compat::Pair; +} // namespace collections::compat + +export namespace sus::collections { + // Classes + using sus::collections::Array; + using sus::collections::ArrayIntoIter; + using sus::collections::Chunks; + using sus::collections::ChunksExact; + using sus::collections::ChunksExactMut; + using sus::collections::Drain; + using sus::collections::RChunks; + using sus::collections::RChunksExact; + using sus::collections::RChunksExactMut; + using sus::collections::RSplit; + using sus::collections::RSplitMut; + using sus::collections::RSplitN; + using sus::collections::Slice; + using sus::collections::SliceIter; + using sus::collections::SliceIterMut; + using sus::collections::SliceMut; + using sus::collections::Split; + using sus::collections::SplitInclusive; + using sus::collections::SplitInclusiveMut; + using sus::collections::SplitMut; + using sus::collections::SplitN; + using sus::collections::SplitNMut; + using sus::collections::Vec; + using sus::collections::VecIntoIter; + using sus::collections::Windows; + using sus::collections::WindowsMut; + + // Functions + using sus::collections::get; + + // Concepts + using sus::collections::Concat; + using sus::collections::Join; + + // Function aliases + using sus::collections::begin; + using sus::collections::end; + + namespace __private { + using ::sus::collections::__private::Storage; + } +} // namespace collections + +export namespace sus::construct { + // Classes + using sus::construct::CastImpl; + + // Functions + using sus::construct::cast; + using sus::construct::into; + using sus::construct::move_into; + using sus::construct::try_into; + + // Concepts + using sus::construct::Cast; + using sus::construct::Default; + using sus::construct::From; + using sus::construct::Into; + using sus::construct::SafelyConstructibleFromReference; + using sus::construct::TryFrom; + using sus::construct::TryInto; +} // namespace construct + +export namespace sus::env { + // Concepts + using sus::env::VarError; + + // Functions + using sus::env::set_var; + using sus::env::var; +} // namespace env + +export namespace sus::error { + // Classes + using sus::error::DynError; + using sus::error::ErrorImpl; + + // Functions + using sus::error::error_display; + using sus::error::error_source; + + // Concepts + using sus::error::Error; +} // namespace error + +export namespace sus::fn { + // Classes + using sus::fn::Anything; + using sus::fn::DynFn; + using sus::fn::DynFnMut; + using sus::fn::DynFnOnce; + using sus::fn::NonVoid; + + // Functions + using sus::fn::call; + using sus::fn::call_mut; + using sus::fn::call_once; + + // Concepts + using sus::fn::Fn; + using sus::fn::FnMut; + using sus::fn::FnOnce; + + // Type aliases + using sus::fn::Return; + using sus::fn::ReturnMut; + using sus::fn::ReturnOnce; +} // namespace fn + +export namespace sus::iter { + // Classes + using sus::iter::ByRef; + using sus::iter::Chain; + using sus::iter::Cloned; + using sus::iter::Copied; + using sus::iter::Cycle; + using sus::iter::Empty; + using sus::iter::Enumerate; + using sus::iter::Filter; + using sus::iter::FilterMap; + using sus::iter::FlatMap; + using sus::iter::Flatten; + using sus::iter::FromIteratorImpl; + using sus::iter::Fuse; + using sus::iter::Generator; + using sus::iter::Inspect; + using sus::iter::IteratorBase; + using sus::iter::IteratorOverRange; + using sus::iter::IteratorRange; + using sus::iter::IterRef; + using sus::iter::IterRefCounter; + using sus::iter::Map; + using sus::iter::MapWhile; + using sus::iter::Moved; + using sus::iter::Once; + using sus::iter::OnceWith; + using sus::iter::Peekable; + using sus::iter::Repeat; + using sus::iter::RepeatWith; + using sus::iter::Reverse; + using sus::iter::Scan; + using sus::iter::SizeHint; + using sus::iter::Skip; + using sus::iter::SkipWhile; + using sus::iter::StepBy; + using sus::iter::Successors; + using sus::iter::Take; + using sus::iter::TakeWhile; + using sus::iter::Zip; + + // Functions + using sus::iter::begin; + using sus::iter::empty; + using sus::iter::end; + using sus::iter::from_generator; + using sus::iter::from_iter; + using sus::iter::from_range; + using sus::iter::once; + using sus::iter::once_with; + using sus::iter::repeat; + using sus::iter::repeat_with; + using sus::iter::successors; + using sus::iter::try_from_iter; + using sus::iter::zip; + + // Concepts + using sus::iter::DoubleEndedIterator; + using sus::iter::ExactSizeIterator; + using sus::iter::Extend; + using sus::iter::FromIterator; + using sus::iter::IntoIterator; + using sus::iter::IntoIteratorAny; + using sus::iter::Iterator; + using sus::iter::IteratorAny; + using sus::iter::Product; + using sus::iter::Sum; + using sus::iter::TrustedLen; + + // Type Aliases + using sus::iter::IntoIteratorOutputType; + using sus::iter::Option; + + // Concept Aliases + using sus::iter::Into; + using sus::iter::TriviallyRelocatable; + + namespace __private { + using sus::iter::__private::IteratorArchetype; + using sus::iter::__private::IntoIteratorArchetype; + using sus::iter::__private::TrustedLenMarker; + using sus::iter::__private::Step; + } +} // namespace iter + +export namespace sus::marker { + // Classes + using sus::marker::EmptyMarker; + using sus::marker::UnsafeFnMarker; + + // Variables + using sus::marker::empty; + using sus::marker::unsafe_fn; +} // namespace marker + +export namespace sus::mem { + // Classes + using sus::mem::NeverValueConstructor; + + // Functions + using sus::mem::addressof; + using sus::mem::clone; + using sus::mem::clone_into; + using sus::mem::clone_or_forward; + using sus::mem::data_size_of; + using sus::mem::forward; + using sus::mem::move; + using sus::mem::replace; + using sus::mem::size_of; + using sus::mem::swap; + using sus::mem::swap_nonoverlapping; + using sus::mem::take; + using sus::mem::take_and_destruct; + using sus::mem::take_copy_and_destruct; + + // Concepts + using sus::mem::Clone; + using sus::mem::CloneFrom; + using sus::mem::CloneOrRef; + using sus::mem::Copy; + using sus::mem::CopyOrRef; + using sus::mem::CopyOrRefOrVoid; + using sus::mem::IsMoveRef; + using sus::mem::Move; + using sus::mem::MoveOrRef; + using sus::mem::MoveOrRefOrVoid; + using sus::mem::NeverValueField; + using sus::mem::TrivialCopy; + using sus::mem::TriviallyRelocatable; + + // Type Aliases + using sus::mem::remove_rvalue_reference; + + namespace __private { + using sus::mem::__private::HasCloneFromMethod; + } +} // namespace mem + +export namespace sus::num { + // Classes + using sus::num::f32; + using sus::num::f64; + using sus::num::i16; + using sus::num::i32; + using sus::num::i64; + using sus::num::i8; + using sus::num::isize; + using sus::num::OverflowInteger; + using sus::num::TryFromIntError; + using sus::num::u16; + using sus::num::u32; + using sus::num::u64; + using sus::num::u8; + using sus::num::uptr; + using sus::num::usize; + + // Enums + using sus::num::FpCategory; + + // Concepts + using sus::num::Add; + using sus::num::AddAssign; + using sus::num::BitAnd; + using sus::num::BitAndAssign; + using sus::num::BitNot; + using sus::num::BitOr; + using sus::num::BitOrAssign; + using sus::num::BitXor; + using sus::num::BitXorAssign; + using sus::num::Div; + using sus::num::DivAssign; + using sus::num::Float; + using sus::num::Integer; + using sus::num::IntegerNumeric; + using sus::num::IntegerPointer; + using sus::num::Mul; + using sus::num::MulAssign; + using sus::num::Neg; + using sus::num::PrimitiveEnum; + using sus::num::PrimitiveEnumClass; + using sus::num::PrimitiveFloat; + using sus::num::PrimitiveInteger; + using sus::num::Rem; + using sus::num::RemAssign; + using sus::num::Shl; + using sus::num::ShlAssign; + using sus::num::Shr; + using sus::num::ShrAssign; + using sus::num::Signed; + using sus::num::SignedPrimitiveEnum; + using sus::num::SignedPrimitiveEnumClass; + using sus::num::SignedPrimitiveInteger; + using sus::num::Sub; + using sus::num::SubAssign; + using sus::num::Unsigned; + using sus::num::UnsignedNumeric; + using sus::num::UnsignedPointer; + using sus::num::UnsignedPrimitiveEnum; + using sus::num::UnsignedPrimitiveEnumClass; + using sus::num::UnsignedPrimitiveInteger; + + namespace __private { + using sus::num::__private::float_is_nan_quiet; + } +} // namespace num + +export namespace sus::ops { + // Classes + using sus::ops::Range; + using sus::ops::RangeFrom; + using sus::ops::RangeFull; + using sus::ops::RangeTo; + using sus::ops::TryImpl; + + // Functions + using sus::ops::range; + using sus::ops::range_from; + using sus::ops::range_to; + using sus::ops::try_from_default; + using sus::ops::try_from_output; + using sus::ops::try_into_output; + using sus::ops::try_is_success; + using sus::ops::try_preserve_error; + + // Concepts + using sus::ops::RangeBounds; + using sus::ops::Try; + using sus::ops::TryDefault; + using sus::ops::TryErrorConvertibleTo; + + // Type Aliases + using sus::ops::TryOutputType; + using sus::ops::TryRemapOutputType; +} // namespace ops + +export namespace sus::option { + // Classes + using sus::option::Option; + using sus::option::OptionIter; + + // Functions + using sus::option::none; + using sus::option::some; + + // Function Aliases + using sus::option::begin; + using sus::option::end; +} // namespace option + +export namespace sus::prelude { + using sus::collections::Vec; + using sus::marker::unsafe_fn; + using sus::num::f32; + using sus::num::f64; + using sus::num::i16; + using sus::num::i32; + using sus::num::i64; + using sus::num::i8; + using sus::num::isize; + using sus::num::u16; + using sus::num::u32; + using sus::num::u64; + using sus::num::u8; + using sus::num::uptr; + using sus::num::usize; + using sus::option::Option; +} // namespace prelude + +export namespace sus::ptr { + // Classes + using sus::ptr::NonNull; + + // Functions + using sus::ptr::as_ref; + using sus::ptr::copy; + using sus::ptr::copy_nonoverlapping; + using sus::ptr::swap_nonoverlapping; + + // Concepts + using sus::ptr::SameOrSubclassOf; +} // namespace ptr + +export namespace sus::result { + // Classes + using sus::result::OkVoid; + using sus::result::Result; + + // Functions + using sus::result::err; + using sus::result::ok; + + // Type Aliases + using sus::result::Once; + using sus::result::ResultState; + using sus::result::StoragePointer; + + // Function Aliases + using sus::result::begin; + using sus::result::end; + + // Concept Aliases + using sus::result::IsTrivialCopyAssignOrRef; + using sus::result::IsTrivialCopyCtorOrRef; + using sus::result::IsTrivialDtorOrRef; + using sus::result::IsTrivialMoveAssignOrRef; + using sus::result::IsTrivialMoveCtorOrRef; + using sus::result::VoidOrEq; + using sus::result::VoidOrOrd; + using sus::result::VoidOrPartialOrd; + using sus::result::VoidOrWeakOrd; +} // namespace result + +export namespace sus::tuple_type { + // Classes + using sus::tuple_type::Tuple; + + // Functions + using sus::tuple_type::get; + using sus::tuple_type::tuple; +} // namespace tuple_type + +#if !defined(SUS_PRELUDE_NO_IMPORT) || SUS_PRELUDE_NO_IMPORT +export using sus::prelude::Vec; +export using sus::prelude::unsafe_fn; +export using sus::prelude::f32; +export using sus::prelude::f64; +export using sus::prelude::i16; +export using sus::prelude::i32; +export using sus::prelude::i64; +export using sus::prelude::i8; +export using sus::prelude::isize; +export using sus::prelude::u16; +export using sus::prelude::u32; +export using sus::prelude::u64; +export using sus::prelude::u8; +export using sus::prelude::uptr; +export using sus::prelude::usize; +export using sus::prelude::Option; +#endif + +export using ::operator""_f32; +export using ::operator""_f64; +export using ::operator""_i16; +export using ::operator""_i32; +export using ::operator""_i64; +export using ::operator""_i8; +export using ::operator""_isize; +export using ::operator""_r; +export using ::operator""_rs; +export using ::operator""_u16; +export using ::operator""_u32; +export using ::operator""_u64; +export using ::operator""_u8; +export using ::operator""_usize; + +export using ::sus::panic; +export using ::sus::unreachable; +export using ::sus::unreachable_unchecked; diff --git a/sus/test/behaviour_types_unittest.cc b/sus/test/behaviour_types_unittest.cc index 50a5dfeb0..3e8c54dc3 100644 --- a/sus/test/behaviour_types_unittest.cc +++ b/sus/test/behaviour_types_unittest.cc @@ -12,10 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sus/test/behaviour_types.h" - +#ifdef TEST_MODULE +import sus; +#else #include "sus/construct/default.h" #include "sus/mem/relocate.h" +#endif + +#include + +#include "sus/test/behaviour_types.h" using sus::construct::Default; using sus::mem::TriviallyRelocatable; diff --git a/sus/tuple/__private/storage.h b/sus/tuple/__private/storage.h index 8458c8134..4517d0d97 100644 --- a/sus/tuple/__private/storage.h +++ b/sus/tuple/__private/storage.h @@ -106,68 +106,67 @@ struct TupleStorage : TupleStorage { }; template -static constexpr const auto& find_tuple_storage(const S& storage) { +constexpr const auto& find_tuple_storage(const S& storage) { return find_tuple_storage(storage, std::integral_constant()); } template -static constexpr const auto& find_tuple_storage( +constexpr const auto& find_tuple_storage( const S& storage, std::integral_constant) { return find_tuple_storage(static_cast(storage), std::integral_constant()); } template -static constexpr const S& find_tuple_storage( +constexpr const S& find_tuple_storage( const S& storage, std::integral_constant) { return storage; } template -static constexpr auto& find_tuple_storage_mut(S& storage) { +constexpr auto& find_tuple_storage_mut(S& storage) { return find_tuple_storage_mut(storage, std::integral_constant()); } template -static constexpr auto& find_tuple_storage_mut( +constexpr auto& find_tuple_storage_mut( S& storage, std::integral_constant) { return find_tuple_storage_mut(static_cast(storage), std::integral_constant()); } template -static constexpr S& find_tuple_storage_mut(S& storage, - std::integral_constant) { +constexpr S& find_tuple_storage_mut(S& storage, std::integral_constant) { return storage; } template -constexpr inline auto storage_eq_impl(const S1& l, const S2& r) noexcept { +constexpr auto storage_eq_impl(const S1& l, const S2& r) noexcept { return find_tuple_storage(l).at() == find_tuple_storage(r).at(); -}; +} template -constexpr inline auto storage_eq(const S1& l, const S2& r, +constexpr auto storage_eq(const S1& l, const S2& r, std::index_sequence) noexcept { return (... && (storage_eq_impl(l, r))); -}; +} template -constexpr inline bool storage_cmp_impl(O& val, const S1& l, +constexpr bool storage_cmp_impl(O& val, const S1& l, const S2& r) noexcept { auto cmp = find_tuple_storage(l).at() <=> find_tuple_storage(r).at(); // Allow downgrading from equal to equivalent, but not the inverse. if (cmp != 0) val = cmp; // Short circuit by returning true when we find a difference. return val == 0; -}; +} template -constexpr inline auto storage_cmp(auto equal, const S1& l, const S2& r, +constexpr auto storage_cmp(auto equal, const S1& l, const S2& r, std::index_sequence) noexcept { auto val = equal; (... && (storage_cmp_impl(val, l, r))); return val; -}; +} } // namespace sus::tuple_type::__private diff --git a/sus/tuple/tuple_types_unittest.cc b/sus/tuple/tuple_types_unittest.cc index 2f9061830..66b5ddc19 100644 --- a/sus/tuple/tuple_types_unittest.cc +++ b/sus/tuple/tuple_types_unittest.cc @@ -12,8 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; +#else #include "sus/construct/default.h" #include "sus/mem/relocate.h" +#endif + +#include + #include "sus/test/behaviour_types.h" #include "sus/tuple/tuple.h" diff --git a/sus/tuple/tuple_unittest.cc b/sus/tuple/tuple_unittest.cc index b158fe6df..8e92aa19a 100644 --- a/sus/tuple/tuple_unittest.cc +++ b/sus/tuple/tuple_unittest.cc @@ -12,20 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef TEST_MODULE +import sus; + +#include "sus/macros/no_unique_address.h" +#else #include "sus/tuple/tuple.h" +#include "sus/mem/clone.h" +#include "sus/mem/copy.h" +#include "sus/mem/move.h" +#include "sus/num/types.h" +#include "sus/prelude.h" +#endif + #include // TODO: Replace with f32::NaN() #include #include #include // std::tuple_size. +#include "fmt/format.h" #include "googletest/include/gtest/gtest.h" -#include "sus/mem/clone.h" -#include "sus/mem/copy.h" -#include "sus/mem/move.h" -#include "sus/num/types.h" -#include "sus/prelude.h" #include "sus/test/no_copy_move.h" namespace {