MiniEngine/MiniEngine_Test.cpp
kiritow d8e2bb9e2b Add Surface compare function.
Build Notice!:
I got a link error while compiling the full project. The link error is
"undefined reference to SDL_GetRGBA" and "undefined reference to
SDL_snprintf"...
Currently there is one way to solve it : Link SDL2test.lib first (Before
SDL2 and SDL2main)
2017-05-24 18:17:29 +08:00

42 lines
925 B
C++

#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;
}
int CompareSurface(const Surface& surface1, const Surface& surface2, int allowableError)
{
return SDLTest_CompareSurfaces(surface1.getRawPointer(),surface2.getRawPointer(),allowableError);
}
}/// End of namespace MiniEngine::Test
}/// End of namespace MiniEngine