Add SDLTest lib support

This commit is contained in:
Kirigaya Kazuto 2017-05-23 12:26:36 +08:00
parent 1b2ba7b2d8
commit 1e8a0d6155
2 changed files with 52 additions and 0 deletions

37
MiniEngine_Test.cpp Normal file
View File

@ -0,0 +1,37 @@
#include "MiniEngine_Test.h"
#include <SDL2/SDL_test.h>
#include <cstring>
namespace MiniEngine
{
namespace Test
{
void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff)
{
SDLTest_Md5Context ct;
SDLTest_Md5Init(&ct);
SDLTest_Md5Update(&ct,buffer,bufferLen);
SDLTest_Md5Final(&ct);
memcpy(outbuff,ct.digest,16);
}
std::string GetMD5(unsigned char* buffer,unsigned int bufferLen)
{
unsigned char buff[16];
char tmp[8];
GetMD5Raw(buffer,bufferLen,buff);
std::string str;
for(int i=0;i<16;i++)
{
sprintf(tmp,"%02x",buff[i]);
str.append(tmp);
}
return str;
}
}/// End of namespace MiniEngine::Test
}/// End of namespace MiniEngine

15
MiniEngine_Test.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include <string>
namespace MiniEngine
{
namespace Test
{
std::string GetMD5(unsigned char* buffer,unsigned int bufferLen);
void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff);
}/// End of namespace MiniEngine::Test
}/// End of namespace MiniEngine