From 76de4234a1928e9dd9af23320880d069817b5000 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Tue, 17 Nov 2015 15:05:43 +0900 Subject: [PATCH] Add a test for the CRC checksum of Ogg pages. --- tests/test_ogg.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp index 210fca2f..90ae162d 100644 --- a/tests/test_ogg.cpp +++ b/tests/test_ogg.cpp @@ -21,6 +21,7 @@ class TestOGG : public CppUnit::TestFixture CPPUNIT_TEST(testDictInterface1); CPPUNIT_TEST(testDictInterface2); CPPUNIT_TEST(testAudioProperties); + CPPUNIT_TEST(testPageChecksum); CPPUNIT_TEST_SUITE_END(); public: @@ -134,6 +135,30 @@ public: CPPUNIT_ASSERT_EQUAL(112000, f.audioProperties()->bitrateNominal()); CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrateMinimum()); } + + void testPageChecksum() + { + ScopedFileCopy copy("empty", ".ogg"); + + { + Vorbis::File f(copy.fileName().c_str()); + f.tag()->setArtist("The Artist"); + f.save(); + + f.seek(0x50); + CPPUNIT_ASSERT_EQUAL((TagLib::uint)0x3d3bd92d, f.readBlock(4).toUInt(0, true)); + } + { + Vorbis::File f(copy.fileName().c_str()); + f.tag()->setArtist("The Artist 2"); + f.save(); + + f.seek(0x50); + CPPUNIT_ASSERT_EQUAL((TagLib::uint)0xd985291c, f.readBlock(4).toUInt(0, true)); + } + + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestOGG);