From: Tsuda Kageyu Date: Thu, 27 Oct 2016 06:15:22 +0000 (+0900) Subject: Add a test for File::truncate(). X-Git-Tag: v1.12-beta-1~140 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d2b3547254f52d18a65e62fc1133e5de25016601;p=taglib Add a test for File::truncate(). --- diff --git a/tests/test_file.cpp b/tests/test_file.cpp index f00a3115..9aae07fe 100644 --- a/tests/test_file.cpp +++ b/tests/test_file.cpp @@ -45,6 +45,7 @@ class TestFile : public CppUnit::TestFixture CPPUNIT_TEST(testFindInSmallFile); CPPUNIT_TEST(testRFindInSmallFile); CPPUNIT_TEST(testSeek); + CPPUNIT_TEST(testTruncate); CPPUNIT_TEST_SUITE_END(); public: @@ -129,6 +130,24 @@ public: CPPUNIT_ASSERT_EQUAL((long)4428, f.tell()); } + void testTruncate() + { + ScopedFileCopy copy("empty", ".ogg"); + std::string name = copy.fileName(); + + { + PlainFile f(name.c_str()); + CPPUNIT_ASSERT_EQUAL(4328L, f.length()); + + f.truncate(2000); + CPPUNIT_ASSERT_EQUAL(2000L, f.length()); + } + { + PlainFile f(name.c_str()); + CPPUNIT_ASSERT_EQUAL(2000L, f.length()); + } + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestFile);