From 7ad28ceb674c08cf9ba38a240345b2100339d01a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 4 Sep 2017 15:57:03 -0400 Subject: [PATCH] update BufferLineWalker unit tests for full coverage --- test/src/test_BufferLineWalker.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/src/test_BufferLineWalker.cc b/test/src/test_BufferLineWalker.cc index c14248a..28118da 100644 --- a/test/src/test_BufferLineWalker.cc +++ b/test/src/test_BufferLineWalker.cc @@ -33,6 +33,11 @@ TEST(BufferLineWalkerTest, iterats_once_for_empty_line) iter_count++; } EXPECT_EQ(1, iter_count); + EXPECT_FALSE(blw.is_valid()); + EXPECT_FALSE(blw.is_eol()); + blw++; + EXPECT_FALSE(blw.is_valid()); + EXPECT_FALSE(blw.is_eol()); } TEST(BufferLineWalkerTest, walks_correctly_with_tabs_and_no_line_wrapping) @@ -63,22 +68,22 @@ TEST(BufferLineWalkerTest, walks_correctly_with_tabs_and_no_line_wrapping) TEST(BufferLineWalkerTest, walks_correctly_with_tabs_and_line_wrapping) { - static const char data[] = "\t1\t12\t123\t1234\t!"; + static const char data[] = "\t1\t12\t123\t1234\t\t!"; std::shared_ptr b = std::make_shared((const uint8_t *)data, strlen(data)); std::shared_ptr start_of_line = b->add_iterator(); BufferLineWalker blw(b, start_of_line, 5, cld); - static int expected_screen_columns[] = { - 0, 4, 0, 3, 4, 0, 2, 3, 4, 0, 1, 2, 3, 4, 0, 4, 0 - }; static int expected_row_offsets[] = { - 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5 + 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5 + }; + static int expected_screen_columns[] = { + 0, 4, 0, 3, 4, 0, 2, 3, 4, 0, 1, 2, 3, 4, 0, 4, 3, 4 }; static int expected_virtual_columns[] = { - 0, 4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 25 + 0, 4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 28, 29 }; static int expected_character_widths[] = { - 4, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 0 + 4, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 1, 0 }; int iter_count = 0; for (; blw.is_valid(); blw++)