From 5fafaf27a5f066dc15d96c03ef154fd1d59eb891 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Feb 2016 13:29:19 +0100 Subject: test that seeking to a position earlier in the file works This tests the fix for #812994, #813000 Gbp-Dch: ignore --- test/libapt/fileutl_test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index 7d1368f7a..607c4a195 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -82,6 +82,18 @@ static void TestFileFd(mode_t const a_umask, mode_t const ExpectedFilePermission EXPECT_N_STR(expect, readback); EXPECT_EQ(test.size(), f.Tell()); } + // Non-zero backwards seek + { + APT_INIT_READBACK + char const * const expect = "is"; + EXPECT_EQ(test.size(), f.Tell()); + EXPECT_TRUE(f.Seek(5)); + EXPECT_TRUE(f.Read(readback, strlen(expect))); + EXPECT_FALSE(f.Failed()); + EXPECT_FALSE(f.Eof()); + EXPECT_N_STR(expect, readback); + EXPECT_EQ(7, f.Tell()); + } { APT_INIT_READBACK EXPECT_TRUE(f.Seek(0)); -- cgit v1.2.3