add GapBuffer::copy_to()

This commit is contained in:
josh committed 2017-01-09 22:05:43 -05:00
1 parent 5de13644de
commit b9313ad606
2 files changed
+47

No files matched your search

+13
View File
@@ -86,3 +86,16 @@ TEST(GapBufferTest, allocates_more_memory_and_copies_buffer_contents_when_needed
s += "EFGH";
EXPECT_EQ(s, gp.get_string());
}
TEST(GapBufferTest, allows_copying_data_range_from_one_gap_buffer_to_another)
{
GapBuffer gp1, gp2;
gp1.insert(0u, (const uint8_t *)"ABCDEFGH", 8u);
gp1.copy_to(0u, 4u, gp2, 0u);
EXPECT_EQ("ABCD", gp2.get_string());
gp1.insert(0u, (const uint8_t *)"IJKL", 4u);
gp1.copy_to(8u, 2u, gp2, 0u);
EXPECT_EQ("EFABCD", gp2.get_string());
gp1.copy_to(2u, 4u, gp2, 3u);
EXPECT_EQ("EFAKLABBCD", gp2.get_string());
}