diff --git a/MiniEngine_Test.cpp b/MiniEngine_Test.cpp index 9e9db92..f95f1a5 100644 --- a/MiniEngine_Test.cpp +++ b/MiniEngine_Test.cpp @@ -31,11 +31,36 @@ std::string GetMD5(unsigned char* buffer,unsigned int bufferLen) return str; } -int CompareSurface(const Surface& surface1, const Surface& surface2, int allowableError) +/// Compare two surfaces. Currently, Surface::getRawPointer() does not has constant attribute. +int CompareSurface(Surface& surface1, Surface& surface2, int allowableError) { return SDLTest_CompareSurfaces(surface1.getRawPointer(),surface2.getRawPointer(),allowableError); } +//private +struct UniRandom::_impl +{ + SDLTest_RandomContext context; +}; + +UniRandom::UniRandom() +{ + _sp.reset(new _impl); + SDLTest_RandomInitTime(&(_sp.get()->context)); +} + +UniRandom::UniRandom(unsigned int A, unsigned int B) +{ + _sp.reset(new _impl); + SDLTest_RandomInit(&(_sp.get()->context),A,B); +} + +uint32_t UniRandom::get() +{ + return SDLTest_Random(&(_sp.get()->context)); +} + + }/// End of namespace MiniEngine::Test }/// End of namespace MiniEngine diff --git a/MiniEngine_Test.h b/MiniEngine_Test.h index 3d6389a..2b71089 100644 --- a/MiniEngine_Test.h +++ b/MiniEngine_Test.h @@ -12,6 +12,18 @@ std::string GetMD5(unsigned char* buffer,unsigned int bufferLen); void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff); int CompareSurface(const Surface& surface1,const Surface& surface2,int allowableError); +class UniRandom +{ +public: + /// Default Constructor is based on system current time. + UniRandom(); + UniRandom(unsigned int A,unsigned int B); + uint32_t get(); +private: + struct _impl; + std::shared_ptr<_impl> _sp; +}; + }/// End of namespace MiniEngine::Test }/// End of namespace MiniEngine