]> granicus.if.org Git - taglib/commitdiff
Add a test for the CRC checksum of Ogg pages.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 17 Nov 2015 06:05:43 +0000 (15:05 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 17 Nov 2015 06:05:43 +0000 (15:05 +0900)
tests/test_ogg.cpp

index 210fca2f0999df9112ab066eefce4dacb9ed3105..90ae162d54ee8a7a09eb17a751422ccf557371e4 100644 (file)
@@ -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);