Add CRC32 calculating support.

mingw-dev-test
Kirigaya Kazuto 2017-06-06 19:05:52 +08:00
parent e183a09f34
commit c0677b055b
2 changed files with 42 additions and 1 deletions

View File

@ -31,6 +31,41 @@ std::string GetMD5(unsigned char* buffer,unsigned int bufferLen)
return str;
}
/// Notice: SDLTest_crc32Calc is an undefined symbol. So we must use these 3 functions.
int GetCRC32(unsigned char* buffer,unsigned int bufferLen,uint32_t& out_CRCResult)
{
uint32_t result;
SDLTest_Crc32Context ct;
SDLTest_Crc32Init(&ct);
int ret=-2;
do
{
if (SDLTest_Crc32CalcStart(&ct,&result))
{
ret=-1;
break;
}
if (SDLTest_Crc32CalcBuffer(&ct, buffer, bufferLen, &result))
{
ret=-1;
break;
}
if (SDLTest_Crc32CalcEnd(&ct, &result))
{
ret=-1;
break;
}
ret=0;
out_CRCResult=result;
break;
}while(0);
SDLTest_Crc32Done(&ct);
return ret;
}
/// Compare two surfaces. Currently, Surface::getRawPointer() does not has constant attribute.
int CompareSurface(Surface& surface1, Surface& surface2, int allowableError)
{
@ -60,7 +95,6 @@ uint32_t UniRandom::get()
return SDLTest_Random(&(_sp.get()->context));
}
}/// End of namespace MiniEngine::Test
}/// End of namespace MiniEngine

View File

@ -10,6 +10,9 @@ namespace Test
std::string GetMD5(unsigned char* buffer,unsigned int bufferLen);
void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff);
int GetCRC32(unsigned char* buffer,unsigned int bufferLen,uint32_t& out_CRCResult);
int CompareSurface(const Surface& surface1,const Surface& surface2,int allowableError);
class UniRandom
@ -24,6 +27,10 @@ private:
std::shared_ptr<_impl> _sp;
};
/// Not Implied : SDLTest_RandomAsciiString,SDLTest_RandomAsciiStringOfSize cause link error.
std::string GetRandomString();
std::string GetRandomString(size_t length);
}/// End of namespace MiniEngine::Test
}/// End of namespace MiniEngine