Skip to content

Commit

Permalink
[TEST] layout::clear test
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Nov 28, 2023
1 parent 81c0cd2 commit ac75451
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions test/unit/hibf/layout/layout_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand All @@ -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);
Expand All @@ -106,3 +99,21 @@ TEST(layout_test, read_from)
EXPECT_EQ(layout.user_bins[1], (seqan::hibf::layout::layout::user_bin{std::vector<size_t>{1}, 0, 22, 4}));
EXPECT_EQ(layout.user_bins[2], (seqan::hibf::layout::layout::user_bin{std::vector<size_t>{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());
}

0 comments on commit ac75451

Please sign in to comment.