diff --git a/include/hibf/cereal/path.hpp b/include/hibf/cereal/path.hpp index d3472ce7..be64d69e 100644 --- a/include/hibf/cereal/path.hpp +++ b/include/hibf/cereal/path.hpp @@ -10,6 +10,7 @@ #include #include // for CEREAL_LOAD_FUNCTION_NAME, CEREAL_SAVE_FUNCTION_NAME +#include namespace cereal { diff --git a/include/hibf/config.hpp b/include/hibf/config.hpp index 4bb39470..84ab26e6 100644 --- a/include/hibf/config.hpp +++ b/include/hibf/config.hpp @@ -312,6 +312,23 @@ struct config */ void validate_and_set_defaults(); + //!\brief Two configs are equal if all options, except seqan::hibf::config::input_fn, are equal. + constexpr bool operator==(config const & other) const + { + // clang-format off + return number_of_user_bins == other.number_of_user_bins && + maximum_fpr == other.maximum_fpr && + relaxed_fpr == other.relaxed_fpr && + threads == other.threads && + sketch_bits == other.sketch_bits && + tmax == other.tmax && + alpha == other.alpha && + max_rearrangement_ratio == other.max_rearrangement_ratio && + disable_estimate_union == other.disable_estimate_union && + disable_rearrangement == other.disable_rearrangement; + // clang-format on + } + private: friend class cereal::access; diff --git a/test/unit/hibf/CMakeLists.txt b/test/unit/hibf/CMakeLists.txt index ae843de0..f0f65446 100644 --- a/test/unit/hibf/CMakeLists.txt +++ b/test/unit/hibf/CMakeLists.txt @@ -8,5 +8,6 @@ hibf_test (bit_vector_test.cpp) hibf_test (config_test.cpp) hibf_test (hierarchical_interleaved_bloom_filter_test.cpp) hibf_test (interleaved_bloom_filter_test.cpp) +hibf_test (path_test.cpp) hibf_test (print_test.cpp) hibf_test (timer_test.cpp) diff --git a/test/unit/hibf/config_test.cpp b/test/unit/hibf/config_test.cpp index 5bf035d9..89f99644 100644 --- a/test/unit/hibf/config_test.cpp +++ b/test/unit/hibf/config_test.cpp @@ -12,6 +12,7 @@ #include // for string_view #include // for config, insert_iterator +#include TEST(config_test, write_to) { @@ -319,3 +320,18 @@ TEST(config_test, validate_and_set_defaults) EXPECT_EQ((testing::internal::GetCapturedStderr()), ""); } } + +TEST(config_test, serialisation) +{ + seqan::hibf::config config{.number_of_user_bins = 123456789, + .number_of_hash_functions = 4, + .maximum_fpr = 0.0001, + .threads = 31, + .sketch_bits = 8, + .tmax = 128, + .alpha = 1.0, + .max_rearrangement_ratio = 0.333, + .disable_estimate_union = true, + .disable_rearrangement = false}; + seqan::hibf::test::test_serialisation(std::move(config)); +} diff --git a/test/unit/hibf/path_test.cpp b/test/unit/hibf/path_test.cpp new file mode 100644 index 00000000..d2921e24 --- /dev/null +++ b/test/unit/hibf/path_test.cpp @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +// SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +// SPDX-License-Identifier: BSD-3-Clause + +#include + +#include +#include + +TEST(path_test, serialisation) +{ + std::filesystem::path path{"/some/random/path.txt"}; + seqan::hibf::test::test_serialisation(std::move(path)); +}