diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e318162..a95f9bef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ option(ENABLE_GUILE "enable building guile module" off) option(ENABLE_BOOST_COROUTINE "run benchmarks with boost coroutine" off) option(immer_BUILD_TESTS "Build tests" ON) -option(immer_BUILD_ARCHIVE_TESTS "Build experimental archive tests" off) +option(immer_BUILD_PERSIST_TESTS "Build experimental persist tests" off) option(immer_BUILD_EXAMPLES "Build examples" ON) option(immer_BUILD_DOCS "Build docs" ON) option(immer_BUILD_EXTRAS "Build extras" ON) diff --git a/extra/fuzzer/CMakeLists.txt b/extra/fuzzer/CMakeLists.txt index ed9fe716..7aea77e0 100644 --- a/extra/fuzzer/CMakeLists.txt +++ b/extra/fuzzer/CMakeLists.txt @@ -14,7 +14,7 @@ endif() file(GLOB_RECURSE immer_fuzzers "*.cpp") foreach(TMP_PATH ${immer_fuzzers}) - string(FIND ${TMP_PATH} archive EXCLUDE_DIR_FOUND) + string(FIND ${TMP_PATH} persist EXCLUDE_DIR_FOUND) if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) list(REMOVE_ITEM immer_fuzzers ${TMP_PATH}) endif() @@ -36,6 +36,6 @@ foreach(_file IN LISTS immer_fuzzers) endif() endforeach() -if(immer_BUILD_ARCHIVE_TESTS) - add_subdirectory(archive) +if(immer_BUILD_PERSIST_TESTS) + add_subdirectory(persist) endif() diff --git a/extra/fuzzer/archive/CMakeLists.txt b/extra/fuzzer/persist/CMakeLists.txt similarity index 100% rename from extra/fuzzer/archive/CMakeLists.txt rename to extra/fuzzer/persist/CMakeLists.txt diff --git a/extra/fuzzer/archive/flex-vector.cpp b/extra/fuzzer/persist/flex-vector.cpp similarity index 94% rename from extra/fuzzer/archive/flex-vector.cpp rename to extra/fuzzer/persist/flex-vector.cpp index 530398c6..3a162cb0 100644 --- a/extra/fuzzer/archive/flex-vector.cpp +++ b/extra/fuzzer/persist/flex-vector.cpp @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include #include @@ -38,13 +38,13 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, using size_t = std::uint8_t; const auto check_save_and_load = [&](const auto& vec) { - auto ar = immer::archive::rbts::make_save_archive_for(vec); - auto vector_id = immer::archive::container_id{}; + auto ar = immer::persist::rbts::make_save_archive_for(vec); + auto vector_id = immer::persist::container_id{}; std::tie(ar, vector_id) = - immer::archive::rbts::save_to_archive(vec, ar); + immer::persist::rbts::save_to_archive(vec, ar); auto loader = - immer::archive::rbts::make_loader_for(vec, to_load_archive(ar)); + immer::persist::rbts::make_loader_for(vec, to_load_archive(ar)); auto loaded = loader.load(vector_id); require_eq(vec, loaded); }; diff --git a/extra/fuzzer/archive/fuzz-set.cpp b/extra/fuzzer/persist/fuzz-set.cpp similarity index 89% rename from extra/fuzzer/archive/fuzz-set.cpp rename to extra/fuzzer/persist/fuzz-set.cpp index 942e175b..876f652d 100644 --- a/extra/fuzzer/archive/fuzz-set.cpp +++ b/extra/fuzzer/persist/fuzz-set.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -77,20 +77,20 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, case op_check: { const auto bitset = std::bitset(read(in)); auto ids = - std::vector>{}; + std::vector>{}; auto archive = - immer::archive::champ::container_archive_save{}; + immer::persist::champ::container_archive_save{}; for (auto index = std::size_t{}; index < var_count; ++index) { if (bitset[index]) { - auto set_id = immer::archive::node_id{}; + auto set_id = immer::persist::node_id{}; std::tie(archive, set_id) = - immer::archive::champ::save_to_archive(vars[index], + immer::persist::champ::save_to_archive(vars[index], archive); ids.emplace_back(index, set_id); } } - auto loader = immer::archive::champ::container_loader{ + auto loader = immer::persist::champ::container_loader{ to_load_archive(archive)}; for (const auto& [index, set_id] : ids) { diff --git a/flake.nix b/flake.nix index 470c6baa..6262608b 100644 --- a/flake.nix +++ b/flake.nix @@ -48,7 +48,7 @@ arximboldi-cereal = pkgs.callPackage ./nix/cereal.nix {inherit arximboldi-cereal-src;}; - archive-inputs = with pkgs; [ + persist-inputs = with pkgs; [ spdlog arximboldi-cereal xxHash @@ -79,8 +79,8 @@ checkPhase = '' ctest -D ExperimentalMemCheck valgrind --quiet --error-exitcode=99 --leak-check=full --errors-for-leak-kinds=all \ - --suppressions=./test/extra/archive/valgrind.supp \ - ./test/extra/archive/archive-tests + --suppressions=./test/extra/persist/valgrind.supp \ + ./test/extra/persist/persist-tests ''; }); }; @@ -103,7 +103,7 @@ fzf starship ] - ++ archive-inputs; + ++ persist-inputs; shellHook = self.checks.${system}.pre-commit-check.shellHook @@ -147,7 +147,7 @@ unit-tests = (withLLVM self.packages.${system}.immer).overrideAttrs (prev: { name = "immer-unit-tests"; - buildInputs = with pkgs; [catch2_3 boehmgc boost fmt] ++ archive-inputs; + buildInputs = with pkgs; [catch2_3 boehmgc boost fmt] ++ persist-inputs; nativeBuildInputs = with pkgs; [cmake ninja]; dontBuild = false; doCheck = true; @@ -159,7 +159,7 @@ cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Debug" "-Dimmer_BUILD_TESTS=ON" - "-Dimmer_BUILD_ARCHIVE_TESTS=ON" + "-Dimmer_BUILD_PERSIST_TESTS=ON" "-Dimmer_BUILD_EXAMPLES=OFF" "-DCXX_STANDARD=20" ]; diff --git a/immer/extra/archive/alias.hpp b/immer/extra/persist/alias.hpp similarity index 77% rename from immer/extra/archive/alias.hpp rename to immer/extra/persist/alias.hpp index bd05ae77..68a18e76 100644 --- a/immer/extra/archive/alias.hpp +++ b/immer/extra/persist/alias.hpp @@ -2,7 +2,7 @@ #include -namespace immer::archive { +namespace immer::persist { template struct type_alias @@ -41,16 +41,16 @@ struct type_alias } }; -} // namespace immer::archive +} // namespace immer::persist /** * Have to use this for fmt v9. */ template -struct fmt::formatter> : formatter +struct fmt::formatter> : formatter { template - auto format(const immer::archive::type_alias& value, + auto format(const immer::persist::type_alias& value, FormatContext& ctx) const { return formatter::format(value.value, ctx); @@ -58,9 +58,9 @@ struct fmt::formatter> : formatter }; template -struct std::hash> +struct std::hash> { - auto operator()(const immer::archive::type_alias& x) const + auto operator()(const immer::persist::type_alias& x) const { return hash{}(x.value); } diff --git a/immer/extra/archive/box/archive.hpp b/immer/extra/persist/box/archive.hpp similarity index 94% rename from immer/extra/archive/box/archive.hpp rename to immer/extra/persist/box/archive.hpp index df290500..ed3bfc5e 100644 --- a/immer/extra/archive/box/archive.hpp +++ b/immer/extra/persist/box/archive.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +#include +#include +#include #include #include @@ -12,7 +12,7 @@ #include -namespace immer::archive::box { +namespace immer::persist::box { template struct archive_save @@ -182,9 +182,9 @@ auto transform_archive(const archive_load& ar, F&& func) }; } -} // namespace immer::archive::box +} // namespace immer::persist::box -namespace immer::archive { +namespace immer::persist { template struct container_traits> @@ -196,7 +196,7 @@ struct container_traits> typename TransformF = boost::hana::id_t> using loader_t = box::loader; - using container_id = immer::archive::container_id; + using container_id = immer::persist::container_id; template static auto transform(F&& func) @@ -206,4 +206,4 @@ struct container_traits> } }; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/cereal/immer_map.hpp b/immer/extra/persist/cereal/immer_map.hpp similarity index 100% rename from immer/extra/archive/cereal/immer_map.hpp rename to immer/extra/persist/cereal/immer_map.hpp diff --git a/immer/extra/archive/cereal/immer_vector.hpp b/immer/extra/persist/cereal/immer_vector.hpp similarity index 100% rename from immer/extra/archive/cereal/immer_vector.hpp rename to immer/extra/persist/cereal/immer_vector.hpp diff --git a/immer/extra/archive/champ/archive.hpp b/immer/extra/persist/champ/archive.hpp similarity index 97% rename from immer/extra/archive/champ/archive.hpp rename to immer/extra/persist/champ/archive.hpp index 2083e840..adc484c6 100644 --- a/immer/extra/archive/champ/archive.hpp +++ b/immer/extra/persist/champ/archive.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -8,11 +8,11 @@ #include #include -#include +#include #include -namespace immer::archive::champ { +namespace immer::persist::champ { template struct inner_node_save @@ -211,4 +211,4 @@ to_load_archive(const container_archive_save& archive) }; } -} // namespace immer::archive::champ +} // namespace immer::persist::champ diff --git a/immer/extra/archive/champ/champ.hpp b/immer/extra/persist/champ/champ.hpp similarity index 99% rename from immer/extra/archive/champ/champ.hpp rename to immer/extra/persist/champ/champ.hpp index cc7831f3..9c3474fd 100644 --- a/immer/extra/archive/champ/champ.hpp +++ b/immer/extra/persist/champ/champ.hpp @@ -6,7 +6,7 @@ #include -namespace immer::archive { +namespace immer::persist { namespace champ { template @@ -186,4 +186,4 @@ save_to_archive(Container container, container_archive_save archive) } } // namespace champ -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/champ/load.hpp b/immer/extra/persist/champ/load.hpp similarity index 97% rename from immer/extra/archive/champ/load.hpp rename to immer/extra/persist/champ/load.hpp index ca358ba9..5ca77036 100644 --- a/immer/extra/archive/champ/load.hpp +++ b/immer/extra/persist/champ/load.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +#include +#include +#include #include @@ -11,7 +11,7 @@ #include -namespace immer::archive { +namespace immer::persist { namespace champ { class children_count_corrupted_exception : public archive_exception @@ -65,7 +65,7 @@ class nodes_loader using champ_t = immer::detail::hamts::champ; using node_t = typename champ_t::node_t; - using node_ptr = immer::archive::node_ptr; + using node_ptr = immer::persist::node_ptr; using values_t = immer::flex_vector>; @@ -251,4 +251,4 @@ class nodes_loader }; } // namespace champ -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/champ/save.hpp b/immer/extra/persist/champ/save.hpp similarity index 93% rename from immer/extra/archive/champ/save.hpp rename to immer/extra/persist/champ/save.hpp index 860f8a3b..fff70124 100644 --- a/immer/extra/archive/champ/save.hpp +++ b/immer/extra/persist/champ/save.hpp @@ -1,10 +1,10 @@ #pragma once -#include +#include #include -namespace immer::archive { +namespace immer::persist { namespace champ { template @@ -70,7 +70,7 @@ struct nodes_archive_builder node_id get_node_id(auto* ptr) { - auto [ar2, id] = immer::archive::champ::get_node_id(std::move(ar), ptr); + auto [ar2, id] = immer::persist::champ::get_node_id(std::move(ar), ptr); ar = std::move(ar2); return id; } @@ -98,4 +98,4 @@ auto save_nodes( } } // namespace champ -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/champ/traits.hpp b/immer/extra/persist/champ/traits.hpp similarity index 86% rename from immer/extra/archive/champ/traits.hpp rename to immer/extra/persist/champ/traits.hpp index e0faf05d..c5d35bb4 100644 --- a/immer/extra/archive/champ/traits.hpp +++ b/immer/extra/persist/champ/traits.hpp @@ -1,12 +1,12 @@ #pragma once -#include -#include -#include +#include +#include +#include #include -namespace immer::archive { +namespace immer::persist { /** * A bit of a hack but currently this is the simplest way to request a type of @@ -21,15 +21,15 @@ template struct champ_traits { using save_archive_t = - immer::archive::champ::container_archive_save; + immer::persist::champ::container_archive_save; using load_archive_t = - immer::archive::champ::container_archive_load; - using container_id = immer::archive::node_id; + immer::persist::champ::container_archive_load; + using container_id = immer::persist::node_id; template using loader_t = - immer::archive::champ::container_loader; + immer::persist::champ::container_loader; template static auto transform(F&& func) @@ -106,10 +106,10 @@ struct container_traits> template using loader_t = - immer::archive::champ::container_loader; }; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/common/archive.hpp b/immer/extra/persist/common/archive.hpp similarity index 95% rename from immer/extra/archive/common/archive.hpp rename to immer/extra/persist/common/archive.hpp index 4fac89e1..2b8a487c 100644 --- a/immer/extra/archive/common/archive.hpp +++ b/immer/extra/persist/common/archive.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include #include #include -namespace immer::archive { +namespace immer::persist { struct node_id_tag; using node_id = type_alias; @@ -93,4 +93,4 @@ auto transform(const immer::map>& map, F&& func) return result; } -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/errors.hpp b/immer/extra/persist/errors.hpp similarity index 90% rename from immer/extra/archive/errors.hpp rename to immer/extra/persist/errors.hpp index 8f0899dc..0dab6dd3 100644 --- a/immer/extra/archive/errors.hpp +++ b/immer/extra/persist/errors.hpp @@ -1,12 +1,12 @@ #pragma once -#include +#include #include #include -namespace immer::archive { +namespace immer::persist { class archive_exception : public std::invalid_argument { @@ -51,4 +51,4 @@ class invalid_children_count : public archive_exception } }; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/json/archivable.hpp b/immer/extra/persist/json/archivable.hpp similarity index 94% rename from immer/extra/archive/json/archivable.hpp rename to immer/extra/persist/json/archivable.hpp index decc815e..fb602536 100644 --- a/immer/extra/archive/json/archivable.hpp +++ b/immer/extra/persist/json/archivable.hpp @@ -1,16 +1,16 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include -namespace immer::archive { +namespace immer::persist { namespace detail { template @@ -171,4 +171,4 @@ void load_minimal( // archive. } -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/json/json_immer.hpp b/immer/extra/persist/json/json_immer.hpp similarity index 98% rename from immer/extra/archive/json/json_immer.hpp rename to immer/extra/persist/json/json_immer.hpp index 2f58e895..618b64af 100644 --- a/immer/extra/archive/json/json_immer.hpp +++ b/immer/extra/persist/json/json_immer.hpp @@ -7,7 +7,7 @@ * context (ImmerArchives) to serialize immer data structures. */ -namespace immer::archive { +namespace immer::persist { struct blackhole_output_archive { @@ -554,7 +554,7 @@ CEREAL_LOAD_FUNCTION_NAME(json_immer_input_archive& ar, ar.loadSize(st.size); } -} // namespace immer::archive +} // namespace immer::persist // tie input and output archives together namespace cereal { @@ -562,17 +562,17 @@ namespace traits { namespace detail { template struct get_output_from_input< - immer::archive::json_immer_input_archive> + immer::persist::json_immer_input_archive> { using type = - immer::archive::json_immer_output_archive; + immer::persist::json_immer_output_archive; }; template struct get_input_from_output< - immer::archive::json_immer_output_archive> + immer::persist::json_immer_output_archive> { using type = - immer::archive::json_immer_input_archive; + immer::persist::json_immer_input_archive; }; } // namespace detail } // namespace traits diff --git a/immer/extra/archive/json/json_immer_auto.hpp b/immer/extra/persist/json/json_immer_auto.hpp similarity index 97% rename from immer/extra/archive/json/json_immer_auto.hpp rename to immer/extra/persist/json/json_immer_auto.hpp index 911de150..1bab0d41 100644 --- a/immer/extra/archive/json/json_immer_auto.hpp +++ b/immer/extra/persist/json/json_immer_auto.hpp @@ -4,11 +4,11 @@ /** * This cereal archive automatically wraps values into - * immer::archive::archivable whenever possible and forwards into the "previous" + * immer::persist::archivable whenever possible and forwards into the "previous" * archive (which normally would be `json_immer_[out|in]put_archive`). */ -namespace immer::archive { +namespace immer::persist { /** * Adapted from cereal/archives/adapters.hpp @@ -500,23 +500,23 @@ CEREAL_LOAD_FUNCTION_NAME(json_immer_auto_input_archive& ar, ar.loadSize(st.size); } -} // namespace immer::archive +} // namespace immer::persist // tie input and output archives together namespace cereal::traits::detail { template struct get_output_from_input< - immer::archive::json_immer_auto_input_archive> + immer::persist::json_immer_auto_input_archive> { using type = - immer::archive::json_immer_auto_output_archive; + immer::persist::json_immer_auto_output_archive; }; template struct get_input_from_output< - immer::archive::json_immer_auto_output_archive> + immer::persist::json_immer_auto_output_archive> { - using type = immer::archive::json_immer_auto_input_archive; + using type = immer::persist::json_immer_auto_input_archive; }; } // namespace cereal::traits::detail diff --git a/immer/extra/archive/json/json_with_archive.hpp b/immer/extra/persist/json/json_with_archive.hpp similarity index 98% rename from immer/extra/archive/json/json_with_archive.hpp rename to immer/extra/persist/json/json_with_archive.hpp index 6245c269..dc4594b9 100644 --- a/immer/extra/archive/json/json_with_archive.hpp +++ b/immer/extra/persist/json/json_with_archive.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include #include +#include +#include #include @@ -12,7 +12,7 @@ * to_json_with_archive */ -namespace immer::archive { +namespace immer::persist { namespace detail { @@ -550,7 +550,7 @@ auto to_json_with_archive(const T& serializable) auto os = std::ostringstream{}; { auto ar = - immer::archive::json_immer_output_archive{os}; ar(serializable); if constexpr (!is_archive_empty()) { @@ -631,7 +631,7 @@ T from_json_with_archive(std::istream& is) auto archives = load_archives(is, load_initial_archives(is), reload_archive); - auto ar = immer::archive::json_immer_input_archive{ std::move(archives), is}; auto r = T{}; @@ -658,7 +658,7 @@ T from_json_with_archive_with_conversion(std::istream& is, auto archives = archives_old.transform(map); using Archives = decltype(archives); - auto ar = immer::archive::json_immer_input_archive{ std::move(archives), is}; auto r = T{}; @@ -729,4 +729,4 @@ auto convert_container( return result; } -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/json/json_with_archive_auto.hpp b/immer/extra/persist/json/json_with_archive_auto.hpp similarity index 96% rename from immer/extra/archive/json/json_with_archive_auto.hpp rename to immer/extra/persist/json/json_with_archive_auto.hpp index 6387eb94..80ecadf5 100644 --- a/immer/extra/archive/json/json_with_archive_auto.hpp +++ b/immer/extra/persist/json/json_with_archive_auto.hpp @@ -1,15 +1,15 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include -namespace immer::archive { +namespace immer::persist { template struct is_auto_ignored_type : boost::hana::false_ @@ -61,7 +61,7 @@ struct archivable_loader_wrapper container_id) { archivable arch; - immer::archive::load_minimal(ar.previous, arch, container_id); + immer::persist::load_minimal(ar.previous, arch, container_id); value = std::move(arch).container; } }; @@ -381,4 +381,4 @@ T from_json_with_auto_archive_with_conversion( is, map, archives_types); } -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/node_ptr.hpp b/immer/extra/persist/node_ptr.hpp similarity index 97% rename from immer/extra/archive/node_ptr.hpp rename to immer/extra/persist/node_ptr.hpp index 916607bd..a657eb74 100644 --- a/immer/extra/archive/node_ptr.hpp +++ b/immer/extra/persist/node_ptr.hpp @@ -4,7 +4,7 @@ #include -namespace immer::archive { +namespace immer::persist { template struct ptr_with_deleter @@ -120,4 +120,4 @@ class node_ptr ptr_with_deleter ptr; }; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/rbts/archive.hpp b/immer/extra/persist/rbts/archive.hpp similarity index 89% rename from immer/extra/archive/rbts/archive.hpp rename to immer/extra/persist/rbts/archive.hpp index eb60843a..aeb86d1e 100644 --- a/immer/extra/archive/rbts/archive.hpp +++ b/immer/extra/persist/rbts/archive.hpp @@ -1,9 +1,9 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -12,7 +12,7 @@ #include -namespace immer::archive::rbts { +namespace immer::persist::rbts { struct inner_node { @@ -147,14 +147,14 @@ auto transform_archive(const archive_load& ar, F&& func) }; } -} // namespace immer::archive::rbts +} // namespace immer::persist::rbts namespace std { template <> -struct hash +struct hash { - auto operator()(const immer::archive::rbts::rbts_info& x) const + auto operator()(const immer::persist::rbts::rbts_info& x) const { const auto boost_combine = [](std::size_t& seed, std::size_t hash) { seed ^= hash + 0x9e3779b9 + (seed << 6) + (seed >> 2); @@ -162,9 +162,9 @@ struct hash auto seed = std::size_t{}; boost_combine(seed, - hash{}(x.root.value)); + hash{}(x.root.value)); boost_combine(seed, - hash{}(x.tail.value)); + hash{}(x.tail.value)); return seed; } }; diff --git a/immer/extra/archive/rbts/load.hpp b/immer/extra/persist/rbts/load.hpp similarity index 98% rename from immer/extra/archive/rbts/load.hpp rename to immer/extra/persist/rbts/load.hpp index 93d5a26d..8f17aba7 100644 --- a/immer/extra/archive/rbts/load.hpp +++ b/immer/extra/persist/rbts/load.hpp @@ -1,9 +1,9 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -13,7 +13,7 @@ #include -namespace immer::archive::rbts { +namespace immer::persist::rbts { inline constexpr auto get_shift_for_depth(immer::detail::rbts::bits_t b, immer::detail::rbts::bits_t bl, @@ -572,4 +572,4 @@ make_loader_for(const immer::flex_vector&, return flex_vector_loader{std::move(ar)}; } -} // namespace immer::archive::rbts +} // namespace immer::persist::rbts diff --git a/immer/extra/archive/rbts/save.hpp b/immer/extra/persist/rbts/save.hpp similarity index 97% rename from immer/extra/archive/rbts/save.hpp rename to immer/extra/persist/rbts/save.hpp index 34eadbcb..b1bd1a76 100644 --- a/immer/extra/archive/rbts/save.hpp +++ b/immer/extra/persist/rbts/save.hpp @@ -1,8 +1,8 @@ #pragma once -#include +#include -namespace immer::archive::rbts { +namespace immer::persist::rbts { namespace detail { @@ -97,7 +97,7 @@ struct archive_builder node_id get_node_id(immer::detail::rbts::node* ptr) { auto [ar2, id] = - immer::archive::rbts::detail::get_node_id(std::move(ar), ptr); + immer::persist::rbts::detail::get_node_id(std::move(ar), ptr); ar = std::move(ar2); return id; } @@ -218,4 +218,4 @@ save_to_archive(immer::flex_vector vec, return {std::move(archive), vector_id}; } -} // namespace immer::archive::rbts +} // namespace immer::persist::rbts diff --git a/immer/extra/archive/rbts/traits.hpp b/immer/extra/persist/rbts/traits.hpp similarity index 84% rename from immer/extra/archive/rbts/traits.hpp rename to immer/extra/persist/rbts/traits.hpp index 2f22cb6c..9070be24 100644 --- a/immer/extra/archive/rbts/traits.hpp +++ b/immer/extra/persist/rbts/traits.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include -#include +#include +#include +#include -namespace immer::archive { +namespace immer::persist { template > { using save_archive_t = rbts::archive_save; using load_archive_t = rbts::archive_load; - using container_id = immer::archive::container_id; + using container_id = immer::persist::container_id; template @@ -39,7 +39,7 @@ struct container_traits> { using save_archive_t = rbts::archive_save; using load_archive_t = rbts::archive_load; - using container_id = immer::archive::container_id; + using container_id = immer::persist::container_id; template @@ -54,4 +54,4 @@ struct container_traits> } }; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/rbts/traverse.hpp b/immer/extra/persist/rbts/traverse.hpp similarity index 94% rename from immer/extra/archive/rbts/traverse.hpp rename to immer/extra/persist/rbts/traverse.hpp index fe9e69ba..15b9245d 100644 --- a/immer/extra/archive/rbts/traverse.hpp +++ b/immer/extra/persist/rbts/traverse.hpp @@ -1,10 +1,10 @@ #pragma once -#include +#include #include -namespace immer::archive::rbts::detail { +namespace immer::persist::rbts::detail { struct regular_pos_tag {}; @@ -96,4 +96,4 @@ struct visitor_helper } }; -} // namespace immer::archive::rbts::detail +} // namespace immer::persist::rbts::detail diff --git a/immer/extra/archive/traits.hpp b/immer/extra/persist/traits.hpp similarity index 74% rename from immer/extra/archive/traits.hpp rename to immer/extra/persist/traits.hpp index d2a6a691..7b480380 100644 --- a/immer/extra/archive/traits.hpp +++ b/immer/extra/persist/traits.hpp @@ -1,6 +1,6 @@ #pragma once -namespace immer::archive { +namespace immer::persist { /** * Define these traits to connect a type (vector_one) to its archive @@ -10,4 +10,4 @@ template struct container_traits {}; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/xxhash/xxhash.hpp b/immer/extra/persist/xxhash/xxhash.hpp similarity index 89% rename from immer/extra/archive/xxhash/xxhash.hpp rename to immer/extra/persist/xxhash/xxhash.hpp index 962c78b2..c476a294 100644 --- a/immer/extra/archive/xxhash/xxhash.hpp +++ b/immer/extra/persist/xxhash/xxhash.hpp @@ -2,7 +2,7 @@ #include -namespace immer::archive { +namespace immer::persist { template struct xx_hash; @@ -24,4 +24,4 @@ struct xx_hash std::size_t operator()(const T& val) const { return xx_hash_value(val); } }; -} // namespace immer::archive +} // namespace immer::persist diff --git a/immer/extra/archive/xxhash/xxhash_64.cpp b/immer/extra/persist/xxhash/xxhash_64.cpp similarity index 82% rename from immer/extra/archive/xxhash/xxhash_64.cpp rename to immer/extra/persist/xxhash/xxhash_64.cpp index cf1c87a5..8111b310 100644 --- a/immer/extra/archive/xxhash/xxhash_64.cpp +++ b/immer/extra/persist/xxhash/xxhash_64.cpp @@ -2,7 +2,7 @@ #include -namespace immer::archive { +namespace immer::persist { static_assert(sizeof(std::size_t) == 8); // 64 bits static_assert(sizeof(XXH64_hash_t) == sizeof(std::size_t)); @@ -12,4 +12,4 @@ std::size_t xx_hash_value_string(const std::string& str) return XXH3_64bits(str.c_str(), str.size()); } -} // namespace immer::archive +} // namespace immer::persist diff --git a/justfile b/justfile index 6351625a..e2f8cd92 100644 --- a/justfile +++ b/justfile @@ -10,23 +10,23 @@ build-valgrind-path := "build-valgrind-" + os() + "-" + arch() # Create a build directory for a Debug build without ASAN, so that valgrind can work mk-build-valgrind: (_mk-dir build-valgrind-path) - cd {{ build-valgrind-path }} ; cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -Dimmer_BUILD_TESTS=ON -Dimmer_BUILD_ARCHIVE_TESTS=ON -Dimmer_BUILD_EXAMPLES=OFF -DCXX_STANDARD=20 + cd {{ build-valgrind-path }} ; cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -Dimmer_BUILD_TESTS=ON -Dimmer_BUILD_PERSIST_TESTS=ON -Dimmer_BUILD_EXAMPLES=OFF -DCXX_STANDARD=20 [linux] run-valgrind: cd {{ build-valgrind-path }} ; ninja tests && ctest -D ExperimentalMemCheck [linux] -run-valgrind-archive: - cd {{ build-valgrind-path }} ; ninja archive-tests && valgrind --quiet --error-exitcode=99 --leak-check=full --errors-for-leak-kinds=all \ - --suppressions=../test/extra/archive/valgrind.supp \ - ./test/extra/archive/archive-tests +run-valgrind-persist: + cd {{ build-valgrind-path }} ; ninja persist-tests && valgrind --quiet --error-exitcode=99 --leak-check=full --errors-for-leak-kinds=all \ + --suppressions=../test/extra/persist/valgrind.supp \ + ./test/extra/persist/persist-tests build-asan-path := "build-asan-" + os() + "-" + arch() # Create a build directory for a Debug build with ASAN enabled mk-build-asan: (_mk-dir build-asan-path) - cd {{ build-asan-path }} ; cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -Dimmer_BUILD_TESTS=ON -Dimmer_BUILD_ARCHIVE_TESTS=ON -Dimmer_BUILD_EXAMPLES=OFF -DCXX_STANDARD=20 + cd {{ build-asan-path }} ; cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -Dimmer_BUILD_TESTS=ON -Dimmer_BUILD_PERSIST_TESTS=ON -Dimmer_BUILD_EXAMPLES=OFF -DCXX_STANDARD=20 run-tests-asan: cd {{ build-asan-path }} ; ninja tests && ninja test diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2661f043..9be24cc2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -37,6 +37,6 @@ foreach(_file IN LISTS immer_unit_tests) add_test("test/${_output}" ${_output}) endforeach() -if(immer_BUILD_ARCHIVE_TESTS) - add_subdirectory(extra/archive) +if(immer_BUILD_PERSIST_TESTS) + add_subdirectory(extra/persist) endif() diff --git a/test/extra/archive/CMakeLists.txt b/test/extra/archive/CMakeLists.txt deleted file mode 100644 index 4ab1fdfa..00000000 --- a/test/extra/archive/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -find_package(spdlog REQUIRED) -find_package(cereal REQUIRED) -find_package(xxHash 0.8 CONFIG REQUIRED) - -if(${CXX_STANDARD} LESS 20) - # Maybe no particular reason, but we're not targeting older compilers anyway. - message(FATAL_ERROR "archive requires C++20") -endif() - -include(CTest) - -add_executable( - archive-tests EXCLUDE_FROM_ALL - test_vectors.cpp - test_special_archive.cpp - test_special_archive_auto.cpp - test_champ.cpp - test_xxhash.cpp - test_box.cpp - test_conversion.cpp - test_circular_dependency_conversion.cpp - ${PROJECT_SOURCE_DIR}/immer/extra/archive/xxhash/xxhash_64.cpp) -target_precompile_headers(archive-tests PRIVATE - ) -add_dependencies(tests archive-tests) -add_test("test/archive-tests" archive-tests) -target_include_directories(archive-tests PRIVATE ${CMAKE_SOURCE_DIR}) -target_link_libraries( - archive-tests PRIVATE spdlog::spdlog Catch2::Catch2WithMain xxHash::xxhash) - -target_compile_options(archive-tests PRIVATE -O1 -fno-optimize-sibling-calls -g - -fno-omit-frame-pointer) -target_compile_options(archive-tests PRIVATE -Wno-unused-function) - -if(ENABLE_ASAN) - target_compile_options( - archive-tests PRIVATE -fsanitize-coverage=trace-pc-guard -fsanitize=address) - target_link_options(archive-tests PRIVATE -fsanitize=address) -endif() -target_compile_definitions(archive-tests PRIVATE BOOST_USE_ASAN=1) -target_compile_definitions( - archive-tests PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE - IMMER_NO_FREE_LIST=1) - -install(TARGETS archive-tests DESTINATION bin) -install(FILES valgrind.supp DESTINATION bin) diff --git a/test/extra/persist/CMakeLists.txt b/test/extra/persist/CMakeLists.txt new file mode 100644 index 00000000..1320a23b --- /dev/null +++ b/test/extra/persist/CMakeLists.txt @@ -0,0 +1,46 @@ +find_package(spdlog REQUIRED) +find_package(cereal REQUIRED) +find_package(xxHash 0.8 CONFIG REQUIRED) + +if(${CXX_STANDARD} LESS 20) + # Maybe no particular reason, but we're not targeting older compilers anyway. + message(FATAL_ERROR "persist requires C++20") +endif() + +include(CTest) + +add_executable( + persist-tests EXCLUDE_FROM_ALL + test_vectors.cpp + test_special_archive.cpp + test_special_archive_auto.cpp + test_champ.cpp + test_xxhash.cpp + test_box.cpp + test_conversion.cpp + test_circular_dependency_conversion.cpp + ${PROJECT_SOURCE_DIR}/immer/extra/persist/xxhash/xxhash_64.cpp) +target_precompile_headers(persist-tests PRIVATE + ) +add_dependencies(tests persist-tests) +add_test("test/persist-tests" persist-tests) +target_include_directories(persist-tests PRIVATE ${CMAKE_SOURCE_DIR}) +target_link_libraries( + persist-tests PRIVATE spdlog::spdlog Catch2::Catch2WithMain xxHash::xxhash) + +target_compile_options(persist-tests PRIVATE -O1 -fno-optimize-sibling-calls -g + -fno-omit-frame-pointer) +target_compile_options(persist-tests PRIVATE -Wno-unused-function) + +if(ENABLE_ASAN) + target_compile_options( + persist-tests PRIVATE -fsanitize-coverage=trace-pc-guard -fsanitize=address) + target_link_options(persist-tests PRIVATE -fsanitize=address) +endif() +target_compile_definitions(persist-tests PRIVATE BOOST_USE_ASAN=1) +target_compile_definitions( + persist-tests PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE + IMMER_NO_FREE_LIST=1) + +install(TARGETS persist-tests DESTINATION bin) +install(FILES valgrind.supp DESTINATION bin) diff --git a/test/extra/archive/cereal/immer_box.hpp b/test/extra/persist/cereal/immer_box.hpp similarity index 100% rename from test/extra/archive/cereal/immer_box.hpp rename to test/extra/persist/cereal/immer_box.hpp diff --git a/test/extra/archive/cereal/immer_set.hpp b/test/extra/persist/cereal/immer_set.hpp similarity index 100% rename from test/extra/archive/cereal/immer_set.hpp rename to test/extra/persist/cereal/immer_set.hpp diff --git a/test/extra/archive/cereal/immer_table.hpp b/test/extra/persist/cereal/immer_table.hpp similarity index 100% rename from test/extra/archive/cereal/immer_table.hpp rename to test/extra/persist/cereal/immer_table.hpp diff --git a/test/extra/archive/suppr.txt b/test/extra/persist/suppr.txt similarity index 100% rename from test/extra/archive/suppr.txt rename to test/extra/persist/suppr.txt diff --git a/test/extra/archive/test_box.cpp b/test/extra/persist/test_box.cpp similarity index 73% rename from test/extra/archive/test_box.cpp rename to test/extra/persist/test_box.cpp index 5044c1d2..1c100f6e 100644 --- a/test/extra/archive/test_box.cpp +++ b/test/extra/persist/test_box.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include "utils.hpp" @@ -14,18 +14,18 @@ TEST_CASE("Test saving a box") const auto test1 = Container{"hello"}; const auto test2 = Container{"world"}; - auto ar = immer::archive::box::make_save_archive_for(test1); + auto ar = immer::persist::box::make_save_archive_for(test1); - auto id1 = immer::archive::container_id{}; - std::tie(ar, id1) = immer::archive::box::save_to_archive(test1, ar); + auto id1 = immer::persist::container_id{}; + std::tie(ar, id1) = immer::persist::box::save_to_archive(test1, ar); - auto id2 = immer::archive::container_id{}; - std::tie(ar, id2) = immer::archive::box::save_to_archive(test2, ar); + auto id2 = immer::persist::container_id{}; + std::tie(ar, id2) = immer::persist::box::save_to_archive(test2, ar); SECTION("Save again, same id") { - auto id3 = immer::archive::container_id{}; - std::tie(ar, id3) = immer::archive::box::save_to_archive(test2, ar); + auto id3 = immer::persist::container_id{}; + std::tie(ar, id3) = immer::persist::box::save_to_archive(test2, ar); REQUIRE(id3 == id2); } @@ -35,11 +35,11 @@ TEST_CASE("Test saving a box") SECTION("Via JSON") { const auto archive = - from_json>( ar_str); auto loader = - immer::archive::box::make_loader_for(Container{}, archive); + immer::persist::box::make_loader_for(Container{}, archive); const auto loaded1 = loader.load(id1); REQUIRE(loaded1 == test1); @@ -52,7 +52,7 @@ TEST_CASE("Test saving a box") SECTION("Via archive transformation") { - auto loader = immer::archive::box::make_loader_for(Container{}, + auto loader = immer::persist::box::make_loader_for(Container{}, to_load_archive(ar)); const auto loaded1 = loader.load(id1); @@ -68,20 +68,20 @@ TEST_CASE("Test saving and mutating a box") using Container = immer::box; auto test1 = Container{"hello"}; - auto ar = immer::archive::box::make_save_archive_for(test1); + auto ar = immer::persist::box::make_save_archive_for(test1); - auto id1 = immer::archive::container_id{}; - std::tie(ar, id1) = immer::archive::box::save_to_archive(test1, ar); + auto id1 = immer::persist::container_id{}; + std::tie(ar, id1) = immer::persist::box::save_to_archive(test1, ar); test1 = std::move(test1).update([](auto str) { return str + " world"; }); - auto id2 = immer::archive::container_id{}; - std::tie(ar, id2) = immer::archive::box::save_to_archive(test1, ar); + auto id2 = immer::persist::container_id{}; + std::tie(ar, id2) = immer::persist::box::save_to_archive(test1, ar); REQUIRE(id1 != id2); auto loader = - immer::archive::box::make_loader_for(Container{}, to_load_archive(ar)); + immer::persist::box::make_loader_for(Container{}, to_load_archive(ar)); const auto loaded1 = loader.load(id1); REQUIRE(loaded1.get() == "hello"); @@ -112,7 +112,7 @@ TEST_CASE("Box: converting loader can handle exceptions") { const auto box = immer::box{123}; const auto [ar_save, box_id] = - immer::archive::box::save_to_archive(box, {}); + immer::persist::box::save_to_archive(box, {}); const auto ar_load = to_load_archive(ar_save); using Archive = std::decay_t; @@ -124,7 +124,7 @@ TEST_CASE("Box: converting loader can handle exceptions") }; using TransformF = std::decay_t; - using Loader = immer::archive::box::loader; @@ -141,7 +141,7 @@ TEST_CASE("Box: converting loader can handle exceptions") }; using TransformF = std::decay_t; - using Loader = immer::archive::box::loader; diff --git a/test/extra/archive/test_champ.cpp b/test/extra/persist/test_champ.cpp similarity index 90% rename from test/extra/archive/test_champ.cpp rename to test/extra/persist/test_champ.cpp index 40dfcf99..09dec730 100644 --- a/test/extra/archive/test_champ.cpp +++ b/test/extra/persist/test_champ.cpp @@ -1,8 +1,8 @@ #include #include -#include -#include +#include +#include #include "utils.hpp" @@ -10,7 +10,7 @@ using namespace test; using json_t = nlohmann::json; -using immer::archive::node_id; +using immer::persist::node_id; namespace { @@ -62,7 +62,7 @@ struct broken_hash if ("10" < str && str < "19") { return 123; } - return immer::archive::xx_hash{}(str); + return immer::persist::xx_hash{}(str); } std::size_t operator()(int map_key) const @@ -81,17 +81,17 @@ TEST_CASE("Test saving a set") using Container = immer::set; const auto set = gen_set(Container{}, 200); - const auto [ar, set_id] = immer::archive::champ::save_to_archive(set, {}); + const auto [ar, set_id] = immer::persist::champ::save_to_archive(set, {}); const auto ar_str = to_json(ar); // REQUIRE(ar_str == ""); SECTION("Load with the correct hash") { const auto loaded_archive = - from_json>( + from_json>( ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; const auto loaded = loader.load(set_id); REQUIRE(into_set(set).size() == set.size()); for (const auto& item : set) { @@ -106,33 +106,33 @@ TEST_CASE("Test saving a set") { using WrongContainer = immer::set; const auto loaded_archive = from_json< - immer::archive::champ::container_archive_load>( + immer::persist::champ::container_archive_load>( ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; REQUIRE_THROWS_AS( loader.load(set_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } } TEST_CASE("Test set with xxHash") { using Container = - immer::set>; + immer::set>; const auto set = gen_set(Container{}, 200); - const auto [ar, set_id] = immer::archive::champ::save_to_archive(set, {}); + const auto [ar, set_id] = immer::persist::champ::save_to_archive(set, {}); const auto ar_str = to_json(ar); // REQUIRE(ar_str == ""); SECTION("Load with the correct hash") { const auto loaded_archive = - from_json>( + from_json>( ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; const auto loaded = loader.load(set_id); REQUIRE(into_set(set).size() == set.size()); for (const auto& item : set) { @@ -150,11 +150,11 @@ TEST_CASE("Test archive conversion, no json") const auto set = gen_set(Container{}, 200); const auto set2 = gen_set(set, 300); - auto [ar, set_id] = immer::archive::champ::save_to_archive(set, {}); - auto set2_id = immer::archive::node_id{}; - std::tie(ar, set2_id) = immer::archive::champ::save_to_archive(set2, ar); + auto [ar, set_id] = immer::persist::champ::save_to_archive(set, {}); + auto set2_id = immer::persist::node_id{}; + std::tie(ar, set2_id) = immer::persist::champ::save_to_archive(set2, ar); - auto loader = immer::archive::champ::container_loader{to_load_archive(ar)}; + auto loader = immer::persist::champ::container_loader{to_load_archive(ar)}; const auto check_set = [&loader](auto id, const auto& expected) { const auto loaded = loader.load(id); @@ -180,11 +180,11 @@ TEST_CASE("Test save mutated set") using Container = immer::set; auto set = gen_set(Container{}, 200); - auto [ar, set_id] = immer::archive::champ::save_to_archive(set, {}); + auto [ar, set_id] = immer::persist::champ::save_to_archive(set, {}); set = std::move(set).insert("435"); - auto set_id2 = immer::archive::node_id{}; - std::tie(ar, set_id2) = immer::archive::champ::save_to_archive(set, ar); + auto set_id2 = immer::persist::node_id{}; + std::tie(ar, set_id2) = immer::persist::champ::save_to_archive(set, ar); REQUIRE(set_id != set_id2); } @@ -194,17 +194,17 @@ TEST_CASE("Test saving a map") using Container = immer::map; const auto map = gen_map(Container{}, 200); - const auto [ar, map_id] = immer::archive::champ::save_to_archive(map, {}); + const auto [ar, map_id] = immer::persist::champ::save_to_archive(map, {}); const auto ar_str = to_json(ar); // REQUIRE(ar_str == ""); SECTION("Load with the correct hash") { const auto loaded_archive = - from_json>( + from_json>( ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; const auto loaded = loader.load(map_id); REQUIRE(into_map(map).size() == map.size()); for (const auto& [key, value] : map) { @@ -220,13 +220,13 @@ TEST_CASE("Test saving a map") { using WrongContainer = immer::map; const auto loaded_archive = from_json< - immer::archive::champ::container_archive_load>( + immer::persist::champ::container_archive_load>( ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; REQUIRE_THROWS_AS( loader.load(map_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } } @@ -236,11 +236,11 @@ TEST_CASE("Test map archive conversion, no json") const auto map = gen_map(Container{}, 200); const auto map2 = gen_map(map, 300); - auto [ar, map_id] = immer::archive::champ::save_to_archive(map, {}); - auto map2_id = immer::archive::node_id{}; - std::tie(ar, map2_id) = immer::archive::champ::save_to_archive(map2, ar); + auto [ar, map_id] = immer::persist::champ::save_to_archive(map, {}); + auto map2_id = immer::persist::node_id{}; + std::tie(ar, map2_id) = immer::persist::champ::save_to_archive(map2, ar); - auto loader = immer::archive::champ::container_loader{to_load_archive(ar)}; + auto loader = immer::persist::champ::container_loader{to_load_archive(ar)}; const auto check_map = [&loader](auto id, const auto& expected) { const auto loaded = loader.load(id); @@ -266,11 +266,11 @@ TEST_CASE("Test map archive conversion, no json") TEST_CASE("Test save mutated map") { auto map = gen_map(immer::map{}, 200); - auto [ar, map_id] = immer::archive::champ::save_to_archive(map, {}); + auto [ar, map_id] = immer::persist::champ::save_to_archive(map, {}); map = std::move(map).set(999, "435"); - auto map_id2 = immer::archive::node_id{}; - std::tie(ar, map_id2) = immer::archive::champ::save_to_archive(map, ar); + auto map_id2 = immer::persist::node_id{}; + std::tie(ar, map_id2) = immer::persist::champ::save_to_archive(map, ar); REQUIRE(map_id != map_id2); } @@ -282,18 +282,18 @@ void test_table_types(Verify&& verify) const auto t1 = gen_table(T1{}, 0, 100); const auto t2 = gen_table(t1, 200, 210); - auto [ar, t1_id] = immer::archive::champ::save_to_archive(t1, {}); + auto [ar, t1_id] = immer::persist::champ::save_to_archive(t1, {}); - auto t2_id = immer::archive::node_id{}; - std::tie(ar, t2_id) = immer::archive::champ::save_to_archive(t2, ar); + auto t2_id = immer::persist::node_id{}; + std::tie(ar, t2_id) = immer::persist::champ::save_to_archive(t2, ar); const auto ar_str = to_json(ar); // REQUIRE(ar_str == ""); const auto loaded_archive = - from_json>(ar_str); + from_json>(ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; const auto check = [&loader, &verify](auto id, const auto& expected) { const auto loaded = loader.load(id); @@ -334,9 +334,9 @@ TEST_CASE("Test saving a table") }; REQUIRE_THROWS_AS(test1(), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); REQUIRE_THROWS_AS(test2(), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } TEST_CASE("Test saving a table, no json") @@ -345,15 +345,15 @@ TEST_CASE("Test saving a table, no json") const auto t1 = gen_table(table_t{}, 0, 100); const auto t2 = gen_table(t1, 200, 210); - auto [ar, t1_id] = immer::archive::champ::save_to_archive(t1, {}); + auto [ar, t1_id] = immer::persist::champ::save_to_archive(t1, {}); - auto t2_id = immer::archive::node_id{}; - std::tie(ar, t2_id) = immer::archive::champ::save_to_archive(t2, ar); + auto t2_id = immer::persist::node_id{}; + std::tie(ar, t2_id) = immer::persist::champ::save_to_archive(t2, ar); const auto ar_str = to_json(ar); // REQUIRE(ar_str == ""); - auto loader = immer::archive::champ::container_loader{to_load_archive(ar)}; + auto loader = immer::persist::champ::container_loader{to_load_archive(ar)}; const auto check = [&loader](auto id, const auto& expected) { const auto loaded = loader.load(id); @@ -373,16 +373,16 @@ TEST_CASE("Test saving a table, no json") TEST_CASE("Test modifying set nodes") { using Container = - immer::set>; + immer::set>; const auto expected_set = gen_set(Container{}, 30); const auto expected_set2 = expected_set.insert("thirty"); auto [ar, set_id] = - immer::archive::champ::save_to_archive(expected_set, {}); - auto set2_id = immer::archive::node_id{}; + immer::persist::champ::save_to_archive(expected_set, {}); + auto set2_id = immer::persist::node_id{}; std::tie(ar, set2_id) = - immer::archive::champ::save_to_archive(expected_set2, std::move(ar)); + immer::persist::champ::save_to_archive(expected_set2, std::move(ar)); const auto ar_str = to_json(ar); const auto expected_data = json_t::parse(ar_str); // REQUIRE(ar_str == ""); @@ -486,9 +486,9 @@ TEST_CASE("Test modifying set nodes") const auto load_set = [&data](auto id) { const auto loaded_archive = - from_json>( + from_json>( data.dump()); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; return loader.load(id); }; @@ -504,7 +504,7 @@ TEST_CASE("Test modifying set nodes") nodemap = 1343560971; REQUIRE_THROWS_AS( load_set(set_id), - immer::archive::champ::children_count_corrupted_exception); + immer::persist::champ::children_count_corrupted_exception); // Node 0 doesn't affect the second set REQUIRE(load_set(set2_id) == expected_set2); } @@ -515,7 +515,7 @@ TEST_CASE("Test modifying set nodes") datamap = 19407008; REQUIRE_THROWS_AS( load_set(set_id), - immer::archive::champ::data_count_corrupted_exception); + immer::persist::champ::data_count_corrupted_exception); // Node 0 doesn't affect the second set REQUIRE(load_set(set2_id) == expected_set2); } @@ -526,10 +526,10 @@ TEST_CASE("Test modifying set nodes") nodemap = 1; REQUIRE_THROWS_AS( load_set(set_id), - immer::archive::champ::children_count_corrupted_exception); + immer::persist::champ::children_count_corrupted_exception); REQUIRE_THROWS_AS( load_set(set2_id), - immer::archive::champ::children_count_corrupted_exception); + immer::persist::champ::children_count_corrupted_exception); } SECTION("Modify datamap of node 1") { @@ -538,10 +538,10 @@ TEST_CASE("Test modifying set nodes") datamap = 536875007; REQUIRE_THROWS_AS( load_set(set_id), - immer::archive::champ::data_count_corrupted_exception); + immer::persist::champ::data_count_corrupted_exception); REQUIRE_THROWS_AS( load_set(set2_id), - immer::archive::champ::data_count_corrupted_exception); + immer::persist::champ::data_count_corrupted_exception); } SECTION("Corrupt datamap but keep the same popcount") { @@ -550,10 +550,10 @@ TEST_CASE("Test modifying set nodes") datamap = 536875008; // This number also has 2 bits set REQUIRE_THROWS_AS( load_set(set_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); REQUIRE_THROWS_AS( load_set(set2_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } SECTION("Corrupt nodemap but keep the same popcount") { @@ -562,7 +562,7 @@ TEST_CASE("Test modifying set nodes") nodemap = 1343560460; // This number has the same number of bits set REQUIRE_THROWS_AS( load_set(set_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); // Node 0 doesn't affect the second set REQUIRE(load_set(set2_id) == expected_set2); } @@ -570,7 +570,7 @@ TEST_CASE("Test modifying set nodes") { auto& children = data["value0"][0]["children"]; children = {1, 2, 99, 4, 5, 6, 7, 8, 9, 10, 11}; - REQUIRE_THROWS_AS(load_set(set_id), immer::archive::invalid_node_id); + REQUIRE_THROWS_AS(load_set(set_id), immer::persist::invalid_node_id); REQUIRE(load_set(set2_id) == expected_set2); } SECTION("Same identity") @@ -578,9 +578,9 @@ TEST_CASE("Test modifying set nodes") // Have to keep the loader alive between loads, otherwise there's no way // to share the nodes. const auto loaded_archive = - from_json>( + from_json>( data.dump()); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; REQUIRE(loader.load(node_id{0}).identity() == loader.load(node_id{0}).identity()); } @@ -594,10 +594,10 @@ TEST_CASE("Test modifying nodes with collisions") const auto expected_set2 = expected_set.insert("thirty"); auto [ar, set_id] = - immer::archive::champ::save_to_archive(expected_set, {}); - auto set2_id = immer::archive::node_id{}; + immer::persist::champ::save_to_archive(expected_set, {}); + auto set2_id = immer::persist::node_id{}; std::tie(ar, set2_id) = - immer::archive::champ::save_to_archive(expected_set2, std::move(ar)); + immer::persist::champ::save_to_archive(expected_set2, std::move(ar)); const auto ar_str = to_json(ar); const auto expected_data = json_t::parse(ar_str); @@ -750,9 +750,9 @@ TEST_CASE("Test modifying nodes with collisions") const auto load_set = [&data](auto id) { const auto loaded_archive = - from_json>( + from_json>( data.dump()); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; return loader.load(id); }; @@ -783,9 +783,9 @@ TEST_CASE("Test champ archive conversion, map") using test::old_type; using old_map_t = - immer::map>; + immer::map>; using new_map_t = - immer::map>; + immer::map>; const auto map1 = [] { auto map = old_map_t{}; @@ -797,8 +797,8 @@ TEST_CASE("Test champ archive conversion, map") }(); const auto map2 = map1.set("345", old_type{.data = 345}); - auto [ar, map1_id] = immer::archive::champ::save_to_archive(map1, {}); - auto map2_id = immer::archive::node_id{}; + auto [ar, map1_id] = immer::persist::champ::save_to_archive(map1, {}); + auto map2_id = immer::persist::node_id{}; std::tie(ar, map2_id) = save_to_archive(map2, ar); // Confirm that map1 and map2 have structural sharing in the beginning. @@ -1226,7 +1226,7 @@ TEST_CASE("Test champ archive conversion, map") const auto load_archive_new_type = transform_archive(load_archive, convert_old_type_map); auto loader = - immer::archive::champ::container_loader{load_archive_new_type}; + immer::persist::champ::container_loader{load_archive_new_type}; const auto loaded_1 = loader.load(map1_id); const auto loaded_2 = loader.load(map2_id); @@ -1235,7 +1235,7 @@ TEST_CASE("Test champ archive conversion, map") SECTION("Loaded maps still share the structure") { - auto [ar, id] = immer::archive::champ::save_to_archive(loaded_1, {}); + auto [ar, id] = immer::persist::champ::save_to_archive(loaded_1, {}); std::tie(ar, id) = save_to_archive(loaded_1, ar); std::tie(ar, id) = save_to_archive(loaded_2, ar); @@ -1701,10 +1701,10 @@ TEST_CASE("Test champ archive conversion, table") using old_table_t = immer::table>; + immer::persist::xx_hash>; using new_table_t = immer::table>; + immer::persist::xx_hash>; const auto table1 = [] { auto table = old_table_t{}; @@ -1721,8 +1721,8 @@ TEST_CASE("Test champ archive conversion, table") .data = 345, }); - auto [ar, table1_id] = immer::archive::champ::save_to_archive(table1, {}); - auto table2_id = immer::archive::node_id{}; + auto [ar, table1_id] = immer::persist::champ::save_to_archive(table1, {}); + auto table2_id = immer::persist::node_id{}; std::tie(ar, table2_id) = save_to_archive(table2, ar); // Confirm that table1 and table2 have structural sharing in the beginning. @@ -2050,19 +2050,19 @@ TEST_CASE("Test champ archive conversion, table") .data2 = fmt::format("_{}_", val.data), }; }, - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::table{}; }); const auto load_archive_new_type = transform_archive(load_archive, badly_convert_old_type); auto loader = - immer::archive::champ::container_loader{load_archive_new_type}; + immer::persist::champ::container_loader{load_archive_new_type}; REQUIRE_THROWS_AS( loader.load(table1_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); REQUIRE_THROWS_AS( loader.load(table2_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } SECTION("Valid conversion, ID is not changed") @@ -2070,7 +2070,7 @@ TEST_CASE("Test champ archive conversion, table") const auto load_archive_new_type = transform_archive(load_archive, convert_old_type_table); auto loader = - immer::archive::champ::container_loader{load_archive_new_type}; + immer::persist::champ::container_loader{load_archive_new_type}; const auto loaded_1 = loader.load(table1_id); const auto loaded_2 = loader.load(table2_id); @@ -2080,7 +2080,7 @@ TEST_CASE("Test champ archive conversion, table") SECTION("Loaded tables still share the structure") { auto [ar, id] = - immer::archive::champ::save_to_archive(loaded_1, {}); + immer::persist::champ::save_to_archive(loaded_1, {}); std::tie(ar, id) = save_to_archive(loaded_1, ar); std::tie(ar, id) = save_to_archive(loaded_2, ar); @@ -2457,7 +2457,7 @@ TEST_CASE("Test set conversion breaks counts") old_type{.id = "3", .data = 93}}; REQUIRE(old_set.size() == 3); const auto [old_save_archive, set_id] = - immer::archive::champ::save_to_archive(old_set, {}); + immer::persist::champ::save_to_archive(old_set, {}); const auto old_load_archive = to_load_archive(old_save_archive); const auto transform = [](const old_type& val) { @@ -2473,12 +2473,12 @@ TEST_CASE("Test set conversion breaks counts") using new_set_t = immer::set; using transform_t = std::decay_t; - auto loader = immer::archive::champ:: + auto loader = immer::persist::champ:: container_loader{ old_load_archive, transform}; REQUIRE_THROWS_AS(loader.load(set_id), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } namespace { @@ -2542,7 +2542,7 @@ TEST_CASE("Champ: converting loader can handle exceptions") return result; }(); const auto [ar_save, set_id] = - immer::archive::champ::save_to_archive(set, {}); + immer::persist::champ::save_to_archive(set, {}); const auto ar_load = to_load_archive(ar_save); using Archive = std::decay_t; @@ -2561,7 +2561,7 @@ TEST_CASE("Champ: converting loader can handle exceptions") }; using TransformF = std::decay_t; - using Loader = immer::archive::champ:: + using Loader = immer::persist::champ:: container_loader, Archive, TransformF>; auto loader = Loader{ar_load, transform}; const auto loaded = loader.load(set_id); @@ -2579,7 +2579,7 @@ TEST_CASE("Champ: converting loader can handle exceptions") }; using TransformF = std::decay_t; - using Loader = immer::archive::champ:: + using Loader = immer::persist::champ:: container_loader, Archive, TransformF>; auto loader = Loader{ar_load, transform}; REQUIRE_THROWS_WITH(loader.load(set_id), "it's 111"); @@ -2596,7 +2596,7 @@ TEST_CASE("Champ: converting loader can handle exceptions") }; using TransformF = std::decay_t; - using Loader = immer::archive::champ:: + using Loader = immer::persist::champ:: container_loader, Archive, TransformF>; auto loader = Loader{ar_load, transform}; REQUIRE_THROWS_WITH(loader.load(set_id), "it's 3"); diff --git a/test/extra/archive/test_circular_dependency_conversion.cpp b/test/extra/persist/test_circular_dependency_conversion.cpp similarity index 83% rename from test/extra/archive/test_circular_dependency_conversion.cpp rename to test/extra/persist/test_circular_dependency_conversion.cpp index 4b98cf46..b793f34c 100644 --- a/test/extra/archive/test_circular_dependency_conversion.cpp +++ b/test/extra/persist/test_circular_dependency_conversion.cpp @@ -1,12 +1,12 @@ #include -#include +#include #include "utils.hpp" -#include -#include -#include +#include +#include +#include #define DEFINE_OPERATIONS(name) \ bool operator==(const name& left, const name& right) \ @@ -50,7 +50,7 @@ struct key friend std::size_t xx_hash_value(const key& value) { - return immer::archive::xx_hash_value_string(value.str); + return immer::persist::xx_hash_value_string(value.str); } }; @@ -65,14 +65,14 @@ struct value_one (flex_vector_one, twos_flex), (immer::table>, + immer::persist::xx_hash>, twos_table), (immer::table>, + immer::persist::xx_hash>, twos_table_2), - (immer::map>, twos_map), - (immer::set>, twos_set) + (immer::map>, twos_map), + (immer::set>, twos_set) ); }; @@ -142,7 +142,7 @@ struct key friend std::size_t xx_hash_value(const key& value) { - return immer::archive::xx_hash_value_string(value.str); + return immer::persist::xx_hash_value_string(value.str); } }; @@ -157,14 +157,14 @@ struct value_one (flex_vector_one, twos_flex), (immer::table>, + immer::persist::xx_hash>, twos_table), (immer::table>, + immer::persist::xx_hash>, twos_table_2), - (immer::map>, twos_map), - (immer::set>, twos_set) + (immer::map>, twos_map), + (immer::set>, twos_set) ); }; @@ -222,7 +222,7 @@ TEST_CASE("Test exception while circular converting") const auto value = [&] { const auto t1 = immer::table>{two1}; + immer::persist::xx_hash>{two1}; const auto t2 = t1.insert(two2); return model::value_one{ .twos = {two1, two2}, @@ -234,17 +234,17 @@ TEST_CASE("Test exception while circular converting") }; }(); - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); const auto [json_str, model_archives] = - immer::archive::to_json_with_auto_archive(value, names); + immer::persist::to_json_with_auto_archive(value, names); // REQUIRE(json_str == ""); SECTION("Try to load") { const auto loaded = - immer::archive::from_json_with_auto_archive( + immer::persist::from_json_with_auto_archive( json_str, names); REQUIRE(loaded == value); } @@ -267,28 +267,28 @@ TEST_CASE("Test exception while circular converting") hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, hana::overload( - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::table>{}; + immer::persist::xx_hash>{}; }, convert_two_boxed)), hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, hana::overload( - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::set< format::two_boxed, - immer::archive::xx_hash>{}; + immer::persist::xx_hash>{}; }, convert_two_boxed)), hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, hana::overload( [convert_two_boxed](std::pair p, const auto& convert_container) { @@ -296,10 +296,10 @@ TEST_CASE("Test exception while circular converting") format::key{p.first.str}, convert_two_boxed(p.second, convert_container)); }, - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::map>{}; + immer::persist::xx_hash>{}; })), hana::make_pair( hana::type_c>, @@ -332,35 +332,35 @@ TEST_CASE("Test exception while circular converting") hana::type_c< immer::table>>, + immer::persist::xx_hash>>, old.twos_table), .twos_table_2 = convert_container( hana::type_c< immer::table>>, + immer::persist::xx_hash>>, old.twos_table_2), .twos_map = convert_container( hana::type_c< immer::map>>, + immer::persist::xx_hash>>, old.twos_map), .twos_set = convert_container( hana::type_c>>, + immer::persist::xx_hash>>, old.twos_set), }; }) ); auto format_load_archives = - immer::archive::transform_save_archive(model_archives, map); + immer::persist::transform_save_archive(model_archives, map); - REQUIRE_THROWS_AS(immer::archive::convert_container( + REQUIRE_THROWS_AS(immer::persist::convert_container( model_archives, format_load_archives, value.twos), - immer::archive::champ::hash_validation_failed_exception); + immer::persist::champ::hash_validation_failed_exception); } TEST_CASE("Test circular dependency archives", "[conversion]") @@ -386,7 +386,7 @@ TEST_CASE("Test circular dependency archives", "[conversion]") const auto value = [&] { const auto t1 = immer::table>{two1}; + immer::persist::xx_hash>{two1}; const auto t2 = t1.insert(two2); return model::value_one{ .twos = {two1, two2}, @@ -398,10 +398,10 @@ TEST_CASE("Test circular dependency archives", "[conversion]") }; }(); - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); - const auto model_archives = immer::archive::get_auto_archive(value, names); + const auto model_archives = immer::persist::get_auto_archive(value, names); /** * NOTE: There is a circular dependency between archives: to convert @@ -421,28 +421,28 @@ TEST_CASE("Test circular dependency archives", "[conversion]") hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, hana::overload( - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::table>{}; + immer::persist::xx_hash>{}; }, convert_two_boxed)), hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, hana::overload( - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::set< format::two_boxed, - immer::archive::xx_hash>{}; + immer::persist::xx_hash>{}; }, convert_two_boxed)), hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, hana::overload( [convert_two_boxed](std::pair p, const auto& convert_container) { @@ -450,10 +450,10 @@ TEST_CASE("Test circular dependency archives", "[conversion]") format::key{p.first.str}, convert_two_boxed(p.second, convert_container)); }, - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::map>{}; + immer::persist::xx_hash>{}; })), hana::make_pair( hana::type_c>, @@ -480,46 +480,46 @@ TEST_CASE("Test circular dependency archives", "[conversion]") hana::type_c< immer::table>>, + immer::persist::xx_hash>>, old.twos_table), .twos_table_2 = convert_container( hana::type_c< immer::table>>, + immer::persist::xx_hash>>, old.twos_table_2), .twos_map = convert_container( hana::type_c< immer::map>>, + immer::persist::xx_hash>>, old.twos_map), .twos_set = convert_container( hana::type_c>>, + immer::persist::xx_hash>>, old.twos_set), }; }) ); auto format_load_archives = - immer::archive::transform_save_archive(model_archives, map); + immer::persist::transform_save_archive(model_archives, map); (void) format_load_archives; // show_type qwe; - const auto format_names = immer::archive::get_archives_for_types( + const auto format_names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); SECTION("vector") { - const auto format_twos = immer::archive::convert_container( + const auto format_twos = immer::persist::convert_container( model_archives, format_load_archives, value.twos); SECTION("Same thing twice, same result") { - const auto format_twos_2 = immer::archive::convert_container( + const auto format_twos_2 = immer::persist::convert_container( model_archives, format_load_archives, value.twos); REQUIRE(format_twos.identity() == format_twos_2.identity()); } @@ -543,22 +543,22 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("Compare structure") { const auto [format_twos_json, ar] = - immer::archive::to_json_with_auto_archive(format_twos, + immer::persist::to_json_with_auto_archive(format_twos, format_names); const auto [model_twos_json, ar2] = - immer::archive::to_json_with_auto_archive(value.twos, names); + immer::persist::to_json_with_auto_archive(value.twos, names); REQUIRE(model_twos_json == format_twos_json); } } SECTION("flex_vector") { - const auto format_twos = immer::archive::convert_container( + const auto format_twos = immer::persist::convert_container( model_archives, format_load_archives, value.twos_flex); SECTION("Same thing twice, same result") { - const auto format_twos_2 = immer::archive::convert_container( + const auto format_twos_2 = immer::persist::convert_container( model_archives, format_load_archives, value.twos_flex); REQUIRE(format_twos.identity() == format_twos_2.identity()); } @@ -567,12 +567,12 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("table") { - const auto format_twos = immer::archive::convert_container( + const auto format_twos = immer::persist::convert_container( model_archives, format_load_archives, value.twos_table); SECTION("Same thing twice, same result") { - const auto format_twos_2 = immer::archive::convert_container( + const auto format_twos_2 = immer::persist::convert_container( model_archives, format_load_archives, value.twos_table); REQUIRE(format_twos.impl().root == format_twos_2.impl().root); } @@ -581,12 +581,12 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("map") { - const auto format_twos = immer::archive::convert_container( + const auto format_twos = immer::persist::convert_container( model_archives, format_load_archives, value.twos_map); SECTION("Same thing twice, same result") { - const auto format_twos_2 = immer::archive::convert_container( + const auto format_twos_2 = immer::persist::convert_container( model_archives, format_load_archives, value.twos_map); REQUIRE(format_twos.impl().root == format_twos_2.impl().root); } @@ -616,10 +616,10 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("Compare structure") { const auto [format_twos_json, ar] = - immer::archive::to_json_with_auto_archive(format_twos, + immer::persist::to_json_with_auto_archive(format_twos, format_names); const auto [model_twos_json, ar2] = - immer::archive::to_json_with_auto_archive(value.twos_map, + immer::persist::to_json_with_auto_archive(value.twos_map, names); REQUIRE(model_twos_json == format_twos_json); } @@ -627,12 +627,12 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("set") { - const auto format_twos = immer::archive::convert_container( + const auto format_twos = immer::persist::convert_container( model_archives, format_load_archives, value.twos_set); SECTION("Same thing twice, same result") { - const auto format_twos_2 = immer::archive::convert_container( + const auto format_twos_2 = immer::persist::convert_container( model_archives, format_load_archives, value.twos_set); REQUIRE(format_twos.impl().root == format_twos_2.impl().root); } @@ -640,10 +640,10 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("Compare structure") { const auto [format_twos_json, ar] = - immer::archive::to_json_with_auto_archive(format_twos, + immer::persist::to_json_with_auto_archive(format_twos, format_names); const auto [model_twos_json, ar2] = - immer::archive::to_json_with_auto_archive(value.twos_set, + immer::persist::to_json_with_auto_archive(value.twos_set, names); REQUIRE(model_twos_json == format_twos_json); } @@ -652,7 +652,7 @@ TEST_CASE("Test circular dependency archives", "[conversion]") SECTION("everything") { const auto convert = [&](const auto& value) { - return immer::archive::convert_container( + return immer::persist::convert_container( model_archives, format_load_archives, value); }; const auto format_value = [&] { @@ -663,17 +663,17 @@ TEST_CASE("Test circular dependency archives", "[conversion]") return result; }(); const auto [format_json_str, model_archives] = - immer::archive::to_json_with_auto_archive(format_value, + immer::persist::to_json_with_auto_archive(format_value, format_names); const auto [json_str, model_archives_] = - immer::archive::to_json_with_auto_archive(value, names); + immer::persist::to_json_with_auto_archive(value, names); REQUIRE(format_json_str == json_str); } SECTION("Test converting inside the archive vs outside") { const auto convert = [&](const auto& value) { - return immer::archive::convert_container( + return immer::persist::convert_container( model_archives, format_load_archives, value); }; diff --git a/test/extra/archive/test_conversion.cpp b/test/extra/persist/test_conversion.cpp similarity index 89% rename from test/extra/archive/test_conversion.cpp rename to test/extra/persist/test_conversion.cpp index cecd5931..dae3d705 100644 --- a/test/extra/archive/test_conversion.cpp +++ b/test/extra/persist/test_conversion.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include "utils.hpp" @@ -141,16 +141,16 @@ class Z; TEST_CASE("Convert between two hierarchies via JSON compatibility", "[conversion]") { - const auto model_names = immer::archive::get_archives_for_types( + const auto model_names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); - const auto format_names = immer::archive::get_archives_for_types( + const auto format_names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); (void) format_names; const auto value = model::make_example_history(); const auto [json_str, model_archives] = - immer::archive::to_json_with_auto_archive(value, model_names); + immer::persist::to_json_with_auto_archive(value, model_names); const auto map = hana::make_map( hana::make_pair(hana::type_c>, @@ -169,22 +169,22 @@ TEST_CASE("Convert between two hierarchies via JSON compatibility", ); auto format_load_archives = - immer::archive::transform_save_archive(model_archives, map); + immer::persist::transform_save_archive(model_archives, map); (void) format_load_archives; - const auto format_snapshots = immer::archive::convert_container( + const auto format_snapshots = immer::persist::convert_container( model_archives, format_load_archives, value.snapshots); { const auto [json_str2, archives] = - immer::archive::to_json_with_auto_archive(format_snapshots, + immer::persist::to_json_with_auto_archive(format_snapshots, format_names); (void) json_str2; REQUIRE(test::to_json(format_snapshots) == test::to_json(value.snapshots)); } { - const auto [json, ar] = immer::archive::to_json_with_auto_archive( + const auto [json, ar] = immer::persist::to_json_with_auto_archive( format::history{.snapshots = format_snapshots}, format_names); REQUIRE(json == json_str); } @@ -203,10 +203,10 @@ struct two_vectors TEST_CASE("Not every type is converted", "[conversion]") { - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); const auto [json_str, archives] = - immer::archive::to_json_with_auto_archive(two_vectors{}, names); + immer::persist::to_json_with_auto_archive(two_vectors{}, names); const auto map = hana::make_map(hana::make_pair(hana::type_c>, @@ -216,6 +216,6 @@ TEST_CASE("Not every type is converted", "[conversion]") ); const auto format_load_archives = - immer::archive::transform_save_archive(archives, map); + immer::persist::transform_save_archive(archives, map); (void) format_load_archives; } diff --git a/test/extra/archive/test_special_archive.cpp b/test/extra/persist/test_special_archive.cpp similarity index 93% rename from test/extra/archive/test_special_archive.cpp rename to test/extra/persist/test_special_archive.cpp index 94773e6c..0cf0585e 100644 --- a/test/extra/archive/test_special_archive.cpp +++ b/test/extra/persist/test_special_archive.cpp @@ -5,12 +5,12 @@ #include "utils.hpp" #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include // to save std::pair #include @@ -34,7 +34,7 @@ using test::vector_one; using json_t = nlohmann::json; template -using arch = immer::archive::archivable; +using arch = immer::persist::archivable; template std::string string_via_tie(const T& value) @@ -265,15 +265,15 @@ TEST_CASE("Special archive minimal test") }; const auto [json_str, archives] = - immer::archive::to_json_with_archive(test1); + immer::persist::to_json_with_archive(test1); // REQUIRE(json_str == ""); { auto full_load = - immer::archive::from_json_with_archive(json_str); + immer::persist::from_json_with_archive(json_str); REQUIRE(full_load == test1); - // REQUIRE(immer::archive::to_json_with_archive(full_load).first == ""); + // REQUIRE(immer::persist::to_json_with_archive(full_load).first == ""); } } @@ -313,13 +313,13 @@ TEST_CASE("Save with a special archive") }; const auto [json_str, archives] = - immer::archive::to_json_with_archive(test1); + immer::persist::to_json_with_archive(test1); SECTION("Try to save and load the archive") { const auto archives_json = [&archives = archives] { auto os = std::ostringstream{}; { - auto ar = immer::archive::json_immer_output_archive< + auto ar = immer::persist::json_immer_output_archive< cereal::JSONOutputArchive, std::decay_t>{os}; ar(123); @@ -330,7 +330,7 @@ TEST_CASE("Save with a special archive") // REQUIRE(archives_json == ""); const auto archives_loaded = [&archives_json] { using Archives = - decltype(immer::archive::detail::generate_archives_load( + decltype(immer::persist::detail::generate_archives_load( get_archives_types(test_data{}))); auto archives = Archives{}; @@ -342,7 +342,7 @@ TEST_CASE("Save with a special archive") { auto is = std::istringstream{archives_json}; - auto ar = immer::archive::json_immer_input_archive< + auto ar = immer::persist::json_immer_input_archive< cereal::JSONInputArchive, Archives>{archives, is}; ar(CEREAL_NVP(archives)); @@ -358,9 +358,9 @@ TEST_CASE("Save with a special archive") { auto full_load = - immer::archive::from_json_with_archive(json_str); + immer::persist::from_json_with_archive(json_str); REQUIRE(full_load == test1); - // REQUIRE(immer::archive::to_json_with_archive(full_load).first == ""); + // REQUIRE(immer::persist::to_json_with_archive(full_load).first == ""); } } @@ -412,12 +412,12 @@ TEST_CASE("Save with a special archive, special type is enclosed") test2.flex_ints.container.identity()); const auto [json_str, archives] = - immer::archive::to_json_with_archive(std::make_pair(test1, test2)); + immer::persist::to_json_with_archive(std::make_pair(test1, test2)); // REQUIRE(json_str == ""); { - auto [loaded1, loaded2] = immer::archive::from_json_with_archive< + auto [loaded1, loaded2] = immer::persist::from_json_with_archive< std::pair>(json_str); REQUIRE(loaded1 == test1); REQUIRE(loaded2 == test2); @@ -444,11 +444,11 @@ TEST_CASE("Special archive must load and save types that have no archive") const auto value = std::make_pair(val1, val2); const auto json_archive_str = - immer::archive::to_json_with_archive(value).first; + immer::persist::to_json_with_archive(value).first; REQUIRE(json_archive_str == test::to_json(value)); { - auto loaded = immer::archive::from_json_with_archive< + auto loaded = immer::persist::from_json_with_archive< std::decay_t>(json_archive_str); REQUIRE(loaded == value); } @@ -459,7 +459,7 @@ TEST_CASE("Special archive loads empty test_data") const auto value = test_data{}; // const auto json_archive_str = - // immer::archive::to_json_with_archive(value).first; + // immer::persist::to_json_with_archive(value).first; // REQUIRE(json_archive_str == ""); const auto json_archive_str = R"({ @@ -515,7 +515,7 @@ TEST_CASE("Special archive loads empty test_data") })"; { - auto loaded = immer::archive::from_json_with_archive< + auto loaded = immer::persist::from_json_with_archive< std::decay_t>(json_archive_str); REQUIRE(loaded == value); } @@ -526,7 +526,7 @@ TEST_CASE("Special archive throws cereal::Exception") const auto value = test_data{}; // const auto json_archive_str = - // immer::archive::to_json_with_archive(value).first; + // immer::persist::to_json_with_archive(value).first; // REQUIRE(json_archive_str == ""); const auto json_archive_str = R"({ @@ -575,7 +575,7 @@ TEST_CASE("Special archive throws cereal::Exception") })"; REQUIRE_THROWS_MATCHES( - immer::archive::from_json_with_archive(json_archive_str), + immer::persist::from_json_with_archive(json_archive_str), ::cereal::Exception, MessageMatches(Catch::Matchers::ContainsSubstring( "Failed to load a container ID 99 from the " @@ -633,14 +633,14 @@ TEST_CASE("Test recursive type") immer::box{v2}}, }; - const auto [json_str, archives] = immer::archive::to_json_with_archive(v3); + const auto [json_str, archives] = immer::persist::to_json_with_archive(v3); // REQUIRE(json_str == ""); { auto full_load = - immer::archive::from_json_with_archive(json_str); + immer::persist::from_json_with_archive(json_str); REQUIRE(full_load == v3); - REQUIRE(immer::archive::to_json_with_archive(full_load).first == + REQUIRE(immer::persist::to_json_with_archive(full_load).first == json_str); } } @@ -673,14 +673,14 @@ TEST_CASE("Test recursive type, saving the box triggers saving the box of the " }, }; - const auto [json_str, archives] = immer::archive::to_json_with_archive(v5); + const auto [json_str, archives] = immer::persist::to_json_with_archive(v5); // REQUIRE(json_str == ""); { const auto full_load = - immer::archive::from_json_with_archive(json_str); + immer::persist::from_json_with_archive(json_str); REQUIRE(full_load == v5); - REQUIRE(immer::archive::to_json_with_archive(full_load).first == + REQUIRE(immer::persist::to_json_with_archive(full_load).first == json_str); } } @@ -740,14 +740,14 @@ TEST_CASE("Test saving a map that contains the same map") }; const auto [json_str, archives] = - immer::archive::to_json_with_archive(value); + immer::persist::to_json_with_archive(value); // REQUIRE(json_str == ""); { const auto full_load = - immer::archive::from_json_with_archive(json_str); + immer::persist::from_json_with_archive(json_str); REQUIRE(full_load == value); - REQUIRE(immer::archive::to_json_with_archive(full_load).first == + REQUIRE(immer::persist::to_json_with_archive(full_load).first == json_str); } } @@ -764,7 +764,7 @@ TEST_CASE("Test non-unique names in the map") ); using IsUnique = - decltype(immer::archive::detail::are_type_names_unique(names)); + decltype(immer::persist::detail::are_type_names_unique(names)); static_assert(IsUnique::value, "Names are unique"); } } @@ -774,11 +774,11 @@ using test::new_type; using test::old_type; template -using map_t = immer::map>; +using map_t = immer::map>; template using table_t = - immer::table>; + immer::table>; // Some type that an application would serialize. Contains multiple vectors and // maps to demonstrate structural sharing. @@ -898,7 +898,7 @@ TEST_CASE("Test conversion with a special archive") }, }; const auto [json_str, archives] = - immer::archive::to_json_with_archive(value); + immer::persist::to_json_with_archive(value); // REQUIRE(json_str == ""); // Describe how to go from the old archive to the desired new archive. @@ -916,7 +916,7 @@ TEST_CASE("Test conversion with a special archive") // Having a JSON from serializing old_app_type and a conversion function, // we need to somehow load new_app_type. const new_app_type full_load = - immer::archive::from_json_with_archive_with_conversion( json_str, archives_conversions); @@ -934,7 +934,7 @@ TEST_CASE("Test conversion with a special archive") "Demonstrate that the loaded vectors and maps still share structure") { const auto [json_str, archives] = - immer::archive::to_json_with_archive(full_load); + immer::persist::to_json_with_archive(full_load); // For example, "x21x" is stored only once. const auto expected = json_t::parse(R"( { diff --git a/test/extra/archive/test_special_archive_auto.cpp b/test/extra/persist/test_special_archive_auto.cpp similarity index 88% rename from test/extra/archive/test_special_archive_auto.cpp rename to test/extra/persist/test_special_archive_auto.cpp index 34ebd8e6..a8fb2ff6 100644 --- a/test/extra/archive/test_special_archive_auto.cpp +++ b/test/extra/persist/test_special_archive_auto.cpp @@ -4,7 +4,7 @@ #include "utils.hpp" -#include +#include #include #define DEFINE_OPERATIONS(name) \ @@ -111,7 +111,7 @@ struct test_data_with_immer TEST_CASE("Auto-archiving") { constexpr auto names = [] { - return immer::archive::get_archives_for_types( + return immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map(hana::make_pair(hana::type_c>, BOOST_HANA_STRING("meta_meta")))); @@ -172,12 +172,12 @@ TEST_CASE("Auto-archiving") }; const auto [json_str, archives] = - immer::archive::to_json_with_auto_archive(value, archive_types); + immer::persist::to_json_with_auto_archive(value, archive_types); // REQUIRE(json_str == ""); { const auto loaded = - immer::archive::from_json_with_auto_archive( + immer::persist::from_json_with_auto_archive( json_str, archive_types); REQUIRE(loaded == value); } @@ -190,12 +190,12 @@ TEST_CASE("Auto-archive must load and save types that have no archive") const auto value = std::make_pair(val1, val2); const auto json_archive_str = - immer::archive::to_json_with_auto_archive(value, hana::make_map()) + immer::persist::to_json_with_auto_archive(value, hana::make_map()) .first; REQUIRE(json_archive_str == test::to_json(value)); { - auto loaded = immer::archive::from_json_with_auto_archive< + auto loaded = immer::persist::from_json_with_auto_archive< std::decay_t>(json_archive_str, hana::make_map()); INFO(loaded.first); INFO(loaded.second); @@ -237,13 +237,13 @@ TEST_CASE("Test save and load small type") const auto value = test_data_with_one_immer_member{ .ints = ints1, }; - const auto archive_types = immer::archive::get_auto_archives_types(value); + const auto archive_types = immer::persist::get_auto_archives_types(value); const auto [json_str, archives] = - immer::archive::to_json_with_auto_archive(value, archive_types); + immer::persist::to_json_with_auto_archive(value, archive_types); // REQUIRE(json_str == ""); { - const auto loaded = immer::archive::from_json_with_auto_archive< + const auto loaded = immer::persist::from_json_with_auto_archive< test_data_with_one_immer_member>(json_str, archive_types); INFO(test::to_json(loaded)); INFO(test::to_json(value)); @@ -257,11 +257,11 @@ using test::new_type; using test::old_type; template -using map_t = immer::map>; +using map_t = immer::map>; template using table_t = - immer::table>; + immer::table>; // Some type that an application would serialize. Contains multiple vectors and // maps to demonstrate structural sharing. @@ -337,14 +337,14 @@ TEST_CASE("Test conversion with auto-archive") }; constexpr auto old_names = [] { - return immer::archive::get_archives_for_types( + return immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); }; using OldArchiveTypes = decltype(old_names()); constexpr auto old_archive_types = OldArchiveTypes{}; const auto [json_str, archives] = - immer::archive::to_json_with_auto_archive(value, old_archive_types); + immer::persist::to_json_with_auto_archive(value, old_archive_types); // REQUIRE(json_str == ""); // Describe how to go from the old archive to the desired new archive. @@ -359,7 +359,7 @@ TEST_CASE("Test conversion with auto-archive") // Having a JSON from serializing old_app_type and a conversion function, // we need to somehow load new_app_type. - const new_app_type full_load = immer::archive:: + const new_app_type full_load = immer::persist:: from_json_with_auto_archive_with_conversion( json_str, archives_conversions, old_archive_types); @@ -390,7 +390,7 @@ struct key friend std::size_t xx_hash_value(const key& value) { - return immer::archive::xx_hash_value_string(value.str); + return immer::persist::xx_hash_value_string(value.str); } }; @@ -412,7 +412,7 @@ struct value_one BOOST_HANA_DEFINE_STRUCT( value_one, // (vector_one, twos), - (immer::table>, + (immer::table>, twos_table)); }; @@ -492,7 +492,7 @@ TEST_CASE("Test table with a funny value") const auto t1 = immer::table>{two1}; + immer::persist::xx_hash>{two1}; const auto two2 = champ_test::two_boxed{champ_test::value_two{ .ones = { @@ -507,18 +507,18 @@ TEST_CASE("Test table with a funny value") .twos_table = t1.insert(two2), }; - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); const auto [json_str, ar] = - immer::archive::to_json_with_auto_archive(value, names); + immer::persist::to_json_with_auto_archive(value, names); // REQUIRE(json_str == ""); const auto loaded = - immer::archive::from_json_with_auto_archive( + immer::persist::from_json_with_auto_archive( json_str, names); REQUIRE(loaded == value); } @@ -531,7 +531,7 @@ TEST_CASE("Test loading broken table") const auto t1 = immer::table>{two1}; + immer::persist::xx_hash>{two1}; const auto two2 = champ_test::two_boxed{champ_test::value_two{ .ones = { @@ -552,14 +552,14 @@ TEST_CASE("Test loading broken table") .twos_table = t1.insert(two2), }; - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); const auto [json_str, ar] = - immer::archive::to_json_with_auto_archive(value, names); + immer::persist::to_json_with_auto_archive(value, names); // REQUIRE(json_str == ""); constexpr auto expected_json_str = R"( @@ -616,7 +616,7 @@ TEST_CASE("Test loading broken table") { INFO(json_str); const auto loaded = - immer::archive::from_json_with_auto_archive( + immer::persist::from_json_with_auto_archive( json_str, names); REQUIRE(loaded == value); } @@ -625,7 +625,7 @@ TEST_CASE("Test loading broken table") { INFO(json.dump()); const auto loaded = - immer::archive::from_json_with_auto_archive( + immer::persist::from_json_with_auto_archive( json.dump(), names); REQUIRE(loaded == value); } @@ -637,7 +637,7 @@ TEST_CASE("Test loading broken table") { json["archives"]["twos_table"][1]["values"][0]["two"] = 0; REQUIRE_THROWS_MATCHES( - immer::archive::from_json_with_auto_archive< + immer::persist::from_json_with_auto_archive< champ_test::value_one>(json.dump(), names), ::cereal::Exception, MessageMatches(Catch::Matchers::ContainsSubstring( @@ -647,7 +647,7 @@ TEST_CASE("Test loading broken table") { json["archives"]["twos_table"][1]["values"][0]["two"] = 99; REQUIRE_THROWS_MATCHES( - immer::archive::from_json_with_auto_archive< + immer::persist::from_json_with_auto_archive< champ_test::value_one>(json.dump(), names), ::cereal::Exception, MessageMatches(Catch::Matchers::ContainsSubstring( @@ -659,7 +659,7 @@ TEST_CASE("Test loading broken table") { json["archives"]["twos_table"][0]["values"][0]["two"] = 99; REQUIRE_THROWS_MATCHES( - immer::archive::from_json_with_auto_archive( + immer::persist::from_json_with_auto_archive( json.dump(), names), ::cereal::Exception, MessageMatches(Catch::Matchers::ContainsSubstring( @@ -669,7 +669,7 @@ TEST_CASE("Test loading broken table") namespace test_no_auto { -using immer::archive::archivable; +using immer::persist::archivable; struct value_two; @@ -688,7 +688,7 @@ struct key friend std::size_t xx_hash_value(const key& value) { - return immer::archive::xx_hash_value_string(value.str); + return immer::persist::xx_hash_value_string(value.str); } }; @@ -712,7 +712,7 @@ struct value_one (vector_one, twos), (archivable>>, + immer::persist::xx_hash>>, twos_table)); }; @@ -783,7 +783,7 @@ auto get_archives_types(const value_one&) hana::make_pair( hana::type_c>>, + immer::persist::xx_hash>>, BOOST_HANA_STRING("table"))); } } // namespace test_no_auto @@ -796,7 +796,7 @@ TEST_CASE("Test table with a funny value no auto") const auto t1 = immer::table>{two1}; + immer::persist::xx_hash>{two1}; const auto two2 = test_no_auto::two_boxed{test_no_auto::value_two{ .ones = { @@ -811,11 +811,11 @@ TEST_CASE("Test table with a funny value no auto") .twos_table = t1.insert(two2), }; - const auto [json_str, ar] = immer::archive::to_json_with_archive(value); + const auto [json_str, ar] = immer::persist::to_json_with_archive(value); // REQUIRE(json_str == ""); const auto loaded = - immer::archive::from_json_with_archive( + immer::persist::from_json_with_archive( json_str); REQUIRE(loaded == value); } @@ -853,11 +853,11 @@ TEST_CASE("Structure breaks when hash is changed") .map = {{123, "123"}, {456, "456"}}, }; - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); const auto [json_str, ar] = - immer::archive::to_json_with_auto_archive(value, names); + immer::persist::to_json_with_auto_archive(value, names); // REQUIRE(json_str == ""); constexpr auto convert_pair = [](const std::pair& old) { @@ -867,7 +867,7 @@ TEST_CASE("Structure breaks when hash is changed") const auto map = hana::make_map(hana::make_pair( hana::type_c>, hana::overload(convert_pair, - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { // We just return the desired new type, but the hash // of int is not compatible with the hash of string. return immer::map{}; @@ -875,10 +875,10 @@ TEST_CASE("Structure breaks when hash is changed") ); - auto load_ar = immer::archive::transform_save_archive(ar, map); + auto load_ar = immer::persist::transform_save_archive(ar, map); - REQUIRE_THROWS_AS(immer::archive::convert_container(ar, load_ar, value.map), - immer::archive::champ::hash_validation_failed_exception); + REQUIRE_THROWS_AS(immer::persist::convert_container(ar, load_ar, value.map), + immer::persist::champ::hash_validation_failed_exception); } TEST_CASE("Converting between incompatible keys") @@ -888,10 +888,10 @@ TEST_CASE("Converting between incompatible keys") .table = {{901}, {902}}, }; - const auto names = immer::archive::get_archives_for_types( + const auto names = immer::persist::get_archives_for_types( hana::tuple_t, hana::make_map()); - const auto ar = immer::archive::get_auto_archive(value, names); + const auto ar = immer::persist::get_auto_archive(value, names); constexpr auto convert_pair = [](const std::pair& old) { return std::make_pair(fmt::format("_{}_", old.first), old.second); @@ -913,16 +913,16 @@ TEST_CASE("Converting between incompatible keys") hana::type_c>, hana::overload( convert_pair, - [](immer::archive::target_container_type_request) { - return immer::archive::champ::incompatible_hash_wrapper< + [](immer::persist::target_container_type_request) { + return immer::persist::champ::incompatible_hash_wrapper< immer::map>{}; })), hana::make_pair( hana::type_c>, hana::overload( convert_int_key, - [](immer::archive::target_container_type_request) { - return immer::archive::champ::incompatible_hash_wrapper< + [](immer::persist::target_container_type_request) { + return immer::persist::champ::incompatible_hash_wrapper< immer::table>{}; })), hana::make_pair( @@ -931,14 +931,14 @@ TEST_CASE("Converting between incompatible keys") [convert_int_key](int old) { return convert_int_key(int_key{old}).id; }, - [](immer::archive::target_container_type_request) { - return immer::archive::champ::incompatible_hash_wrapper< + [](immer::persist::target_container_type_request) { + return immer::persist::champ::incompatible_hash_wrapper< immer::set>{}; })) ); - auto load_ar = immer::archive::transform_save_archive(ar, map); + auto load_ar = immer::persist::transform_save_archive(ar, map); SECTION("maps") { constexpr auto convert_map = [convert_pair](const auto& map) { @@ -950,12 +950,12 @@ TEST_CASE("Converting between incompatible keys") }; const auto converted = - immer::archive::convert_container(ar, load_ar, value.map); + immer::persist::convert_container(ar, load_ar, value.map); REQUIRE(converted == convert_map(value.map)); // Converting the same thing should return the same data const auto converted_2 = - immer::archive::convert_container(ar, load_ar, value.map); + immer::persist::convert_container(ar, load_ar, value.map); REQUIRE(converted.identity() == converted_2.identity()); } SECTION("tables") @@ -969,12 +969,12 @@ TEST_CASE("Converting between incompatible keys") }; const auto converted = - immer::archive::convert_container(ar, load_ar, value.table); + immer::persist::convert_container(ar, load_ar, value.table); REQUIRE(converted == convert_table(value.table)); // Converting the same thing should return the same data const auto converted_2 = - immer::archive::convert_container(ar, load_ar, value.table); + immer::persist::convert_container(ar, load_ar, value.table); REQUIRE(converted.impl().root == converted_2.impl().root); } SECTION("sets") @@ -989,12 +989,12 @@ TEST_CASE("Converting between incompatible keys") }; const auto converted = - immer::archive::convert_container(ar, load_ar, value.set); + immer::persist::convert_container(ar, load_ar, value.set); REQUIRE(converted == convert_set(value.set)); // Converting the same thing should return the same data const auto converted_2 = - immer::archive::convert_container(ar, load_ar, value.set); + immer::persist::convert_container(ar, load_ar, value.set); REQUIRE(converted.impl().root == converted_2.impl().root); } } diff --git a/test/extra/archive/test_vectors.cpp b/test/extra/persist/test_vectors.cpp similarity index 92% rename from test/extra/archive/test_vectors.cpp rename to test/extra/persist/test_vectors.cpp index 0f911421..b0a7fea9 100644 --- a/test/extra/archive/test_vectors.cpp +++ b/test/extra/persist/test_vectors.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include "utils.hpp" @@ -24,25 +24,25 @@ namespace { using namespace test; -using immer::archive::container_id; -using immer::archive::rbts::save_to_archive; +using immer::persist::container_id; +using immer::persist::rbts::save_to_archive; using json_t = nlohmann::json; namespace hana = boost::hana; auto load_vec(const auto& json, std::size_t vec_id) { const auto archive = - test::from_json>(json); + test::from_json>(json); auto loader = - immer::archive::rbts::make_loader_for(test::example_vector{}, archive); + immer::persist::rbts::make_loader_for(test::example_vector{}, archive); return loader.load(container_id{vec_id}); } auto load_flex_vec(const auto& json, std::size_t vec_id) { const auto archive = - test::from_json>(json); - auto loader = immer::archive::rbts::make_loader_for( + test::from_json>(json); + auto loader = immer::persist::rbts::make_loader_for( test::example_flex_vector{}, archive); return loader.load(container_id{vec_id}); } @@ -58,14 +58,14 @@ TEST_CASE("Save and load multiple times into the same archive") example_vector{}, }; auto counter = std::size_t{}; - auto ar = immer::archive::rbts::make_save_archive_for(example_vector{}); + auto ar = immer::persist::rbts::make_save_archive_for(example_vector{}); const auto save_and_load = [&]() { const auto vec = test_vectors.back().push_back(++counter); test_vectors.push_back(vec); - auto vector_id = immer::archive::container_id{}; + auto vector_id = immer::persist::container_id{}; std::tie(ar, vector_id) = - immer::archive::rbts::save_to_archive(vec, ar); + immer::persist::rbts::save_to_archive(vec, ar); SPDLOG_DEBUG("start test size {}", vec.size()); { @@ -99,9 +99,9 @@ TEST_CASE("Save and load vectors with shared nodes") // Save them const auto save_vectors = [](const auto& vectors) -> std::pair> { + std::vector> { auto ar = example_archive_save{}; - auto ids = std::vector{}; + auto ids = std::vector{}; for (const auto& v : vectors) { auto [ar2, id] = save_to_archive(v, ar); ar = ar2; @@ -177,8 +177,8 @@ TEST_CASE("Save and load vectors and flex vectors with shared nodes") // Save them const auto save_vectors = [](example_archive_save ar, const auto& vectors) -> std::pair> { - auto ids = std::vector{}; + std::vector> { + auto ids = std::vector{}; for (const auto& v : vectors) { auto [ar2, id] = save_to_archive(v, ar); ar = ar2; @@ -191,8 +191,8 @@ TEST_CASE("Save and load vectors and flex vectors with shared nodes") auto ar = example_archive_save{}; const auto vectors = generate_vectors(); const auto flex_vectors = generate_flex_vectors(); - auto vector_ids = std::vector{}; - auto flex_vectors_ids = std::vector{}; + auto vector_ids = std::vector{}; + auto flex_vectors_ids = std::vector{}; std::tie(ar, vector_ids) = save_vectors(ar, vectors); std::tie(ar, flex_vectors_ids) = save_vectors(ar, flex_vectors); REQUIRE(!vector_ids.empty()); @@ -244,11 +244,11 @@ TEST_CASE("Archive in-place mutated vector") { auto vec = example_vector{1, 2, 3}; auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); vec = std::move(vec).push_back(90); - auto id2 = immer::archive::container_id{}; + auto id2 = immer::persist::container_id{}; std::tie(ar, id2) = save_to_archive(vec, ar); REQUIRE(id1 != id2); @@ -263,11 +263,11 @@ TEST_CASE("Archive in-place mutated flex_vector") { auto vec = example_flex_vector{1, 2, 3}; auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); vec = std::move(vec).push_back(90); - auto id2 = immer::archive::container_id{}; + auto id2 = immer::persist::container_id{}; std::tie(ar, id2) = save_to_archive(vec, ar); REQUIRE(id1 != id2); @@ -284,7 +284,7 @@ TEST_CASE("Test nodes reuse") const auto big_vec = small_vec + small_vec; auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(big_vec, ar); { @@ -313,7 +313,7 @@ TEST_CASE("Test saving and loading vectors of different lengths", "[slow]") for_each_generated_length( test::vector_one{}, 350, [&](const auto& vec) { auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); { @@ -330,7 +330,7 @@ TEST_CASE("Test saving and loading vectors of different lengths", "[slow]") auto ar = example_archive_save{}; for_each_generated_length( test::vector_one{}, 350, [&](const auto& vec) { - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); { @@ -362,7 +362,7 @@ TEST_CASE("Test flex vectors memory leak") for_each_generated_length_flex( test::flex_vector_one{}, max_length, [&](const auto& vec) { auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); { @@ -388,12 +388,12 @@ TEST_CASE("Test flex vectors memory leak") * inner node. */ auto ar = example_archive_save{}; - auto ids = std::vector{}; + auto ids = std::vector{}; auto vecs = std::vector>{}; for_each_generated_length_flex( test::flex_vector_one{}, max_length, [&](const auto& vec) { - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); ids.push_back(id1); vecs.push_back(vec); @@ -412,7 +412,7 @@ TEST_CASE("Test flex vectors memory leak") for_each_generated_length_flex( test::flex_vector_one{}, max_length, [&](const auto& vec) { auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); { @@ -450,7 +450,7 @@ TEST_CASE("Test saving and loading flex vectors of different lengths", "[slow]") for_each_generated_length_flex( test::flex_vector_one{}, 350, [&](const auto& vec) { auto ar = example_archive_save{}; - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); { @@ -467,7 +467,7 @@ TEST_CASE("Test saving and loading flex vectors of different lengths", "[slow]") auto ar = example_archive_save{}; for_each_generated_length_flex( test::vector_one{}, 350, [&](const auto& vec) { - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(vec, ar); // Loads correctly @@ -759,7 +759,7 @@ TEST_CASE("A loop with 2 nodes") } )"}; REQUIRE_THROWS_AS(load_flex_vec(json, 0), - immer::archive::archive_has_cycles); + immer::persist::archive_has_cycles); } namespace { @@ -840,14 +840,14 @@ TEST_CASE("Test vector with very big objects") const auto small_vec = gen(test::vector_one{}, 67); - auto ar = immer::archive::rbts::make_save_archive_for( + auto ar = immer::persist::rbts::make_save_archive_for( test::vector_one{}); - auto id1 = immer::archive::container_id{}; + auto id1 = immer::persist::container_id{}; std::tie(ar, id1) = save_to_archive(small_vec, ar); { // Loads correctly - auto loader = immer::archive::rbts::make_loader_for( + auto loader = immer::persist::rbts::make_loader_for( test::vector_one{}, to_load_archive(ar)); const auto loaded1 = loader.load(id1); REQUIRE(loaded1 == small_vec); @@ -906,21 +906,21 @@ TEST_CASE("Test modifying vector nodes") SECTION("Load non-existing vector") { REQUIRE_THROWS_AS(load_vec(data.dump(), 99), - immer::archive::archive_exception); + immer::persist::archive_exception); } SECTION("Invalid root id") { data["value0"]["vectors"][0]["root"] = 1; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::invalid_node_id); + immer::persist::invalid_node_id); } SECTION("Invalid tail id") { data["value0"]["vectors"][0]["tail"] = 999; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::invalid_node_id); + immer::persist::invalid_node_id); } SECTION("A leaf with too few elements") @@ -930,7 +930,7 @@ TEST_CASE("Test modifying vector nodes") // Leaf #3 should have two elements, but it has only one. item["value"] = {2}; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::rbts::vector_corrupted_exception); + immer::persist::rbts::vector_corrupted_exception); } SECTION("Mess with the tail") @@ -947,14 +947,14 @@ TEST_CASE("Test modifying vector nodes") { item["value"] = json_t::array(); REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::rbts::vector_corrupted_exception); + immer::persist::rbts::vector_corrupted_exception); } SECTION("Add too many elements") { // Three elements can't be in a leaf item["value"] = {6, 7, 8}; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::invalid_children_count); + immer::persist::invalid_children_count); } } @@ -966,7 +966,7 @@ TEST_CASE("Test modifying vector nodes") { item["value"]["children"] = std::vector(33, 2); REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::invalid_children_count); + immer::persist::invalid_children_count); } SECTION("Remove one") { @@ -978,20 +978,20 @@ TEST_CASE("Test modifying vector nodes") { item["value"]["children"] = {2, 4, 9}; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::invalid_node_id); + immer::persist::invalid_node_id); } SECTION("Node has itself as a child") { item["value"]["children"] = {2, 0, 4}; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::archive_has_cycles); + immer::persist::archive_has_cycles); } SECTION("Strict vector can not have relaxed nodes") { item["value"]["relaxed"] = true; REQUIRE_THROWS_AS( load_vec(data.dump(), 0), - immer::archive::rbts::relaxed_node_not_allowed_exception); + immer::persist::rbts::relaxed_node_not_allowed_exception); } } } @@ -1059,13 +1059,13 @@ TEST_CASE("Test modifying flex vector nodes") SECTION("Load non-existing vector") { REQUIRE_THROWS_AS(load_flex_vec(data.dump(), 99), - immer::archive::archive_exception); + immer::persist::archive_exception); } SECTION("Non-relaxed vector can not have relaxed nodes") { REQUIRE_THROWS_AS( load_vec(data.dump(), 0), - immer::archive::rbts::relaxed_node_not_allowed_exception); + immer::persist::rbts::relaxed_node_not_allowed_exception); } SECTION("Modify starting leaf") { @@ -1126,7 +1126,7 @@ TEST_CASE("Test modifying flex vector nodes") children = {2, 3, 4, 902, 4}; REQUIRE_THROWS_AS( load_flex_vec(data.dump(), 0), - immer::archive::rbts::same_depth_children_exception); + immer::persist::rbts::same_depth_children_exception); } SECTION("No children") { @@ -1144,7 +1144,7 @@ TEST_CASE("Test modifying flex vector nodes") const auto is_relaxed = GENERATE(false, true); item["value"]["relaxed"] = is_relaxed; REQUIRE_THROWS_AS(load_flex_vec(data.dump(), 0), - immer::archive::invalid_children_count); + immer::persist::invalid_children_count); } SECTION("Remove a child") { @@ -1167,7 +1167,7 @@ TEST_CASE("Test modifying flex vector nodes") item["value"]["relaxed"] = false; REQUIRE_THROWS_AS( load_flex_vec(data.dump(), 0), - immer::archive::rbts::vector_corrupted_exception); + immer::persist::rbts::vector_corrupted_exception); } SECTION("Relaxed works") { @@ -1292,7 +1292,7 @@ TEST_CASE("Test more inner nodes") REQUIRE(children == json_t::array({2, 35})); children = {2, 28}; REQUIRE_THROWS_AS(load_vec(data.dump(), 0), - immer::archive::rbts::same_depth_children_exception); + immer::persist::rbts::same_depth_children_exception); } SECTION("Strict vector can't contain relaxed nodes at all") { @@ -1304,7 +1304,7 @@ TEST_CASE("Test more inner nodes") item["relaxed"] = true; REQUIRE_THROWS_AS( load_vec(data.dump(), 0), - immer::archive::rbts::relaxed_node_not_allowed_exception); + immer::persist::rbts::relaxed_node_not_allowed_exception); } SECTION("Relaxed non-root") { @@ -1314,7 +1314,7 @@ TEST_CASE("Test more inner nodes") item["relaxed"] = true; REQUIRE_THROWS_AS( load_vec(data.dump(), 0), - immer::archive::rbts::relaxed_node_not_allowed_exception); + immer::persist::rbts::relaxed_node_not_allowed_exception); } } SECTION("Flex vector loads as well") @@ -1342,7 +1342,7 @@ TEST_CASE("Test more inner nodes") inners[1]["value"]["children"] = {3, 4, 5}; REQUIRE_THROWS_AS( load_flex_vec(data.dump(), 0), - immer::archive::rbts::relaxed_node_not_allowed_exception); + immer::persist::rbts::relaxed_node_not_allowed_exception); } } } @@ -1406,7 +1406,7 @@ TEST_CASE("Exception while loading children") REQUIRE(children == json_t::array({2, 3, 4, 5, 2, 3, 4})); children = {2, 3, 4, 902, 4}; REQUIRE_THROWS_AS(load_flex_vec(data.dump(), 0), - immer::archive::rbts::same_depth_children_exception); + immer::persist::rbts::same_depth_children_exception); } TEST_CASE("Test flex vector with a weird shape relaxed") @@ -1429,10 +1429,10 @@ TEST_CASE("Test flex vector with a weird shape relaxed") const auto loaded = load_flex_vec(data.dump(), 0); // { - // auto ar = immer::archive::rbts::make_save_archive_for(loaded); - // auto vector_id = immer::archive::node_id{}; + // auto ar = immer::persist::rbts::make_save_archive_for(loaded); + // auto vector_id = immer::persist::node_id{}; // std::tie(ar, vector_id) = - // immer::archive::rbts::save_to_archive(loaded, ar); + // immer::persist::rbts::save_to_archive(loaded, ar); // SPDLOG_INFO("{}", test::to_json(ar)); // } @@ -1464,10 +1464,10 @@ TEST_CASE("Test flex vector with a weird shape strict", "[.broken]") const auto loaded = load_flex_vec(data.dump(), 0); // { - // auto ar = immer::archive::rbts::make_save_archive_for(loaded); - // auto vector_id = immer::archive::node_id{}; + // auto ar = immer::persist::rbts::make_save_archive_for(loaded); + // auto vector_id = immer::persist::node_id{}; // std::tie(ar, vector_id) = - // immer::archive::rbts::save_to_archive(loaded, ar); + // immer::persist::rbts::save_to_archive(loaded, ar); // SPDLOG_INFO("{}", test::to_json(ar)); // } @@ -1493,9 +1493,9 @@ TEST_CASE("Flex vector converted from strict") const auto small_vec = gen(test::vector_one{}, 67); const auto small_flex_vec = test::flex_vector_one{small_vec}; - auto ar = immer::archive::rbts::make_save_archive_for(small_vec); - auto small_vec_id = immer::archive::container_id{}; - auto small_flex_vec_id = immer::archive::container_id{}; + auto ar = immer::persist::rbts::make_save_archive_for(small_vec); + auto small_vec_id = immer::persist::container_id{}; + auto small_flex_vec_id = immer::persist::container_id{}; SECTION("First save strict") { @@ -1526,8 +1526,8 @@ TEST_CASE("Can't load saved flex vector with relaxed nodes as strict") { const auto small_vec = gen(test::flex_vector_one{}, 67); const auto vec = small_vec + small_vec; - auto ar = immer::archive::rbts::make_save_archive_for(vec); - auto vec_id = immer::archive::container_id{}; + auto ar = immer::persist::rbts::make_save_archive_for(vec); + auto vec_id = immer::persist::container_id{}; std::tie(ar, vec_id) = save_to_archive(vec, ar); SECTION("Flex loads well") @@ -1542,7 +1542,7 @@ TEST_CASE("Can't load saved flex vector with relaxed nodes as strict") make_loader_for(test::vector_one{}, to_load_archive(ar)); REQUIRE_THROWS_AS( loader.load(vec_id), - immer::archive::rbts::relaxed_node_not_allowed_exception); + immer::persist::rbts::relaxed_node_not_allowed_exception); } } @@ -1557,10 +1557,10 @@ TEST_CASE("Test vector archive conversion") }; const auto vec2 = vec1.push_back(old_type{.data = 345}); - auto ar = immer::archive::rbts::make_save_archive_for(vec1); - auto vec1_id = immer::archive::container_id{}; + auto ar = immer::persist::rbts::make_save_archive_for(vec1); + auto vec1_id = immer::persist::container_id{}; std::tie(ar, vec1_id) = save_to_archive(vec1, ar); - auto vec2_id = immer::archive::container_id{}; + auto vec2_id = immer::persist::container_id{}; std::tie(ar, vec2_id) = save_to_archive(vec2, ar); // Confirm that vec1 and vec2 have structural sharing in the beginning. @@ -1638,8 +1638,8 @@ TEST_CASE("Test vector archive conversion") SECTION("Loaded vectors still share the structure") { - auto ar = immer::archive::rbts::make_save_archive_for(loaded_1); - auto id = immer::archive::container_id{}; + auto ar = immer::persist::rbts::make_save_archive_for(loaded_1); + auto id = immer::persist::container_id{}; std::tie(ar, id) = save_to_archive(loaded_1, ar); std::tie(ar, id) = save_to_archive(loaded_2, ar); @@ -1731,7 +1731,7 @@ TEST_CASE("Vector: converting loader can handle exceptions") using TransformF = std::decay_t; using Loader = - immer::archive::rbts::loader; using Loader = - immer::archive::rbts::loader -#include +#include #include -#include +#include #include #include "utils.hpp" @@ -22,11 +22,11 @@ const auto gen_map = [](auto map, int count) { TEST_CASE("Test hash strings") { auto str = std::string{}; - REQUIRE(immer::archive::xx_hash{}(str) == 3244421341483603138); + REQUIRE(immer::persist::xx_hash{}(str) == 3244421341483603138); REQUIRE(XXH3_64bits(str.c_str(), str.size()) == 3244421341483603138); str = "hello"; - REQUIRE(immer::archive::xx_hash{}(str) == + REQUIRE(immer::persist::xx_hash{}(str) == 10760762337991515389UL); REQUIRE(XXH3_64bits(str.c_str(), str.size()) == 10760762337991515389UL); } @@ -36,7 +36,7 @@ TEST_CASE("Test loading a big map saved on macOS with std::hash", "[.macos]") using Container = immer::map; const auto set = gen_map(Container{}, 200); - const auto [ar, set_id] = immer::archive::champ::save_to_archive(set, {}); + const auto [ar, set_id] = immer::persist::champ::save_to_archive(set, {}); const auto ar_str = test::to_json(ar); // REQUIRE(ar_str == ""); const auto expected_json = R"({ @@ -655,9 +655,9 @@ TEST_CASE("Test loading a big map saved on macOS with std::hash", "[.macos]") REQUIRE(expected == actual); const auto loaded_archive = test::from_json< - immer::archive::champ::container_archive_load>(ar_str); + immer::persist::champ::container_archive_load>(ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; const auto loaded = loader.load(set_id); REQUIRE(loaded == set); } @@ -665,10 +665,10 @@ TEST_CASE("Test loading a big map saved on macOS with std::hash", "[.macos]") TEST_CASE("Test loading a big map with xxHash") { using Container = immer:: - map>; + map>; const auto set = gen_map(Container{}, 200); - const auto [ar, set_id] = immer::archive::champ::save_to_archive(set, {}); + const auto [ar, set_id] = immer::persist::champ::save_to_archive(set, {}); const auto ar_str = test::to_json(ar); const auto expected_json = R"({ "value0": [ @@ -1323,9 +1323,9 @@ TEST_CASE("Test loading a big map with xxHash") REQUIRE(expected == actual); const auto loaded_archive = test::from_json< - immer::archive::champ::container_archive_load>(ar_str); + immer::persist::champ::container_archive_load>(ar_str); - auto loader = immer::archive::champ::container_loader{loaded_archive}; + auto loader = immer::persist::champ::container_loader{loaded_archive}; const auto loaded = loader.load(set_id); REQUIRE(loaded == set); } diff --git a/test/extra/archive/utils.hpp b/test/extra/persist/utils.hpp similarity index 87% rename from test/extra/archive/utils.hpp rename to test/extra/persist/utils.hpp index 863d68cb..591aa4da 100644 --- a/test/extra/archive/utils.hpp +++ b/test/extra/persist/utils.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include -#include +#include +#include +#include -#include +#include #include @@ -31,8 +31,8 @@ using example_vector = vector_one; using example_flex_vector = flex_vector_one; using example_archive_save = - decltype(immer::archive::rbts::make_save_archive_for(example_vector{})); -using example_loader = immer::archive::rbts:: + decltype(immer::persist::rbts::make_save_archive_for(example_vector{})); +using example_loader = immer::persist::rbts:: loader; inline auto gen(auto init, int count) @@ -146,17 +146,17 @@ constexpr auto convert_old_type = [](auto&& arg) { }; constexpr auto convert_old_type_map = boost::hana::overload( - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer:: - map>{}; + map>{}; }, convert_old_type); constexpr auto convert_old_type_table = boost::hana::overload( - [](immer::archive::target_container_type_request) { + [](immer::persist::target_container_type_request) { return immer::table>{}; + immer::persist::xx_hash>{}; }, convert_old_type); @@ -172,7 +172,7 @@ inline auto transform_vec(const auto& vec) inline auto transform_map(const auto& map) { auto result = immer:: - map>{}; + map>{}; for (const auto& [key, value] : map) { result = std::move(result).set(key, convert_old_type(value)); } @@ -183,7 +183,7 @@ inline auto transform_table(const auto& table) { auto result = immer::table>{}; + immer::persist::xx_hash>{}; for (const auto& item : table) { result = std::move(result).insert(convert_old_type(item)); } diff --git a/test/extra/archive/valgrind.supp b/test/extra/persist/valgrind.supp similarity index 100% rename from test/extra/archive/valgrind.supp rename to test/extra/persist/valgrind.supp