void CRC32Test::testGetValue() { // test methods of java.util.zip.crc32.getValue() CRC32 crc; CPPUNIT_ASSERT_EQUAL_MESSAGE( "getValue() should return a zero as a result of constructing a CRC32 instance", 0LL, crc.getValue() ); crc.reset(); crc.update( Integer::MAX_VALUE ); // Ran JDK and discovered that the value of the CRC should be // 4278190080 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(max) failed to update the checksum to the correct value ", 4278190080LL, crc.getValue() ); crc.reset(); std::vector<unsigned char> byteEmpty( 10000, 0 ); crc.update( byteEmpty ); // Ran JDK and discovered that the value of the CRC should be // 1295764014 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(byte[]) failed to update the checksum to the correct value ", 1295764014LL, crc.getValue() ); crc.reset(); crc.update( 1 ); // Ran JDK and discovered that the value of the CRC should be // 2768625435 // CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(int) failed to update the checksum to the correct // value ",2768625435L, crc.getValue()); crc.reset(); CPPUNIT_ASSERT_EQUAL_MESSAGE( "reset failed to reset the checksum value to zero", 0LL, crc.getValue()); }
void CRC32Test::testUpdateI() { CRC32 crc; crc.update( 1 ); // Ran JDK and discovered that the value of the CRC should be // 2768625435 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(1) failed to update the checksum to the correct value ", 2768625435LL, crc.getValue() ); crc.reset(); crc.update( Integer::MAX_VALUE ); // Ran JDK and discovered that the value of the CRC should be // 4278190080 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(max) failed to update the checksum to the correct value ", 4278190080LL, crc.getValue() ); crc.reset(); crc.update( Integer::MIN_VALUE ); // Ran JDK and discovered that the value of the CRC should be // 3523407757 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(min) failed to update the checksum to the correct value ", 3523407757LL, crc.getValue() ); }
void CRC32Test::testReset() { CRC32 crc; crc.update( 1 ); // Ran JDK and discovered that the value of the CRC should be // 2768625435 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(int) failed to update the checksum to the correct value ", 2768625435LL, crc.getValue() ); crc.reset(); CPPUNIT_ASSERT_EQUAL_MESSAGE( "reset failed to reset the checksum value to zero", 0LL, crc.getValue() ); }
virtual void close(CRC32 &fileCRC) { CriticalBlock block(statsCs); xmlParser.clear(); inputIOstream.clear(); if (checkFileCrc) { fileCRC.reset(~crcStream->queryCrc()); // MORE should prob. change stream to use CRC32 crcStream.clear(); } mergeStats(fileStats, iFileIO); iFileIO.clear(); }
virtual void close(CRC32 &fileCRC) { xmlParser.clear(); inputIOstream.clear(); if (checkFileCrc) { fileCRC.reset(~crcStream->queryCrc()); // MORE should prob. change stream to use CRC32 crcStream.clear(); } Owned<IFileIO> partFileIO; { CriticalBlock block(statsCs); partFileIO.setown(iFileIO.getClear()); } mergeStats(fileStats, partFileIO); }
void CRC32Test::testUpdateArray() { unsigned char byteArray[] = { 1, 2 }; CRC32 crc; crc.update( byteArray, 2, 0, 2 ); // Ran JDK and discovered that the value of the CRC should be // 3066839698 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(unsigned char[]) failed to update the checksum to the correct value ", 3066839698LL, crc.getValue() ); crc.reset(); std::vector<unsigned char> byteEmpty( 10000, 0 ); crc.update( byteEmpty ); // Ran JDK and discovered that the value of the CRC should be // 1295764014 CPPUNIT_ASSERT_EQUAL_MESSAGE( "update(unsigned char[]) failed to update the checksum to the correct value ", 1295764014LL, crc.getValue() ); }