From ac75451e34bbf5d9344ad3a11f273db6afbd0bed Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Tue, 28 Nov 2023 11:46:24 +0100 Subject: [PATCH] [TEST] layout::clear test --- test/unit/hibf/layout/layout_test.cpp | 51 ++++++++++++++++----------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/test/unit/hibf/layout/layout_test.cpp b/test/unit/hibf/layout/layout_test.cpp index d1e1cc67..76278271 100644 --- a/test/unit/hibf/layout/layout_test.cpp +++ b/test/unit/hibf/layout/layout_test.cpp @@ -54,6 +54,17 @@ TEST(layout_test, printing_user_bins) EXPECT_EQ(ss.str(), expected); } +static std::string const layout_file{ + R"layout_file(#TOP_LEVEL_IBF fullest_technical_bin_idx:111 +#LOWER_LEVEL_IBF_0 fullest_technical_bin_idx:0 +#LOWER_LEVEL_IBF_2 fullest_technical_bin_idx:2 +#LOWER_LEVEL_IBF_1;2;3;4 fullest_technical_bin_idx:22 +#USER_BIN_IDX TECHNICAL_BIN_INDICES NUMBER_OF_TECHNICAL_BINS +7 0 1 +4 1;0 1;22 +5 1;2;3;4;22 1;1;1;1;21 +)layout_file"}; + TEST(layout_test, write_to) { std::stringstream ss{}; @@ -70,30 +81,12 @@ TEST(layout_test, write_to) layout.write_to(ss); - std::string expected = R"layout_file(#TOP_LEVEL_IBF fullest_technical_bin_idx:111 -#LOWER_LEVEL_IBF_0 fullest_technical_bin_idx:0 -#LOWER_LEVEL_IBF_2 fullest_technical_bin_idx:2 -#LOWER_LEVEL_IBF_1;2;3;4 fullest_technical_bin_idx:22 -#USER_BIN_IDX TECHNICAL_BIN_INDICES NUMBER_OF_TECHNICAL_BINS -7 0 1 -4 1;0 1;22 -5 1;2;3;4;22 1;1;1;1;21 -)layout_file"; - - EXPECT_EQ(ss.str(), expected); + EXPECT_EQ(ss.str(), layout_file); } TEST(layout_test, read_from) { - std::stringstream ss{R"layout_file(#TOP_LEVEL_IBF fullest_technical_bin_idx:111 -#LOWER_LEVEL_IBF_0 fullest_technical_bin_idx:0 -#LOWER_LEVEL_IBF_2 fullest_technical_bin_idx:2 -#LOWER_LEVEL_IBF_1;2;3;4 fullest_technical_bin_idx:22 -#USER_BIN_IDX TECHNICAL_BIN_INDICES NUMBER_OF_TECHNICAL_BINS -7 0 1 -4 1;0 1;22 -5 1;2;3;4;22 1;1;1;1;21 -)layout_file"}; + std::stringstream ss{layout_file}; seqan::hibf::layout::layout layout; layout.read_from(ss); @@ -106,3 +99,21 @@ TEST(layout_test, read_from) EXPECT_EQ(layout.user_bins[1], (seqan::hibf::layout::layout::user_bin{std::vector{1}, 0, 22, 4})); EXPECT_EQ(layout.user_bins[2], (seqan::hibf::layout::layout::user_bin{std::vector{1, 2, 3, 4}, 22, 21, 5})); } + +TEST(layout_test, clear) +{ + std::stringstream ss{layout_file}; + + seqan::hibf::layout::layout layout; + layout.read_from(ss); + + ASSERT_NE(layout.top_level_max_bin_id, 0); + ASSERT_FALSE(layout.max_bins.empty()); + ASSERT_FALSE(layout.user_bins.empty()); + + layout.clear(); + + EXPECT_EQ(layout.top_level_max_bin_id, 0); + EXPECT_TRUE(layout.max_bins.empty()); + EXPECT_TRUE(layout.user_bins.empty()); +}