static void test_compare_mem(void) { int a[5] = {1,2,3,4,5}; int b[5] = {1,2,3,4,5}; int c[5] = {1,2,3,4,10}; assert(compare_mem(a,b,(sizeof(int) * 5))); assert(!compare_mem(a,c,(sizeof(int) * 5))); }
static int screen_compare(lua_State *L) { Screen *screen; SDL_Surface *real; SDL_Surface *tmp; SDL_Surface *expected; int is_equal; int size; int bpp_real; int bpp_expected; screen = check_screen(L, 1); real = screen->screen; bpp_real = real->format->BytesPerPixel; tmp = IMG_Load(lua_tostring(L, 2)); /* convert to screen format */ expected = SDL_DisplayFormat(tmp); bpp_expected = expected->format->BytesPerPixel; SDL_FreeSurface(tmp); bpp_real = expected->format->BytesPerPixel; assert(expected); assert(bpp_real == bpp_expected); assert(real->w == expected->w); assert(real->h == expected->h); size = expected->w * expected->h * bpp_expected; is_equal = compare_mem(real->pixels, expected->pixels, size); SDL_FreeSurface(expected); lua_pushboolean(L, is_equal); return 1; }