From c84f194c8b836e1be0518f79a1a7753b6b8c45f1 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Mon, 18 Dec 2017 14:46:40 -0600 Subject: [PATCH] Get our test suite working with SDL Had to remove a couple of screen tests for now; it needs a big re-think now that we're using SDL. Namely, how do we test SDL? --- tests/CMakeLists.txt | 11 ++++++----- tests/vm_screen.c | 41 ++++++++++++++--------------------------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1508f20..f9ceb27 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,14 +11,15 @@ if(CMAKE_C_FLAGS MATCHES "--analyze") endif() if(APPLE) - set(opengl_library /System/Library/Frameworks/OpenGL.framework) + set(sdl_library /Library/Frameworks/SDL2.framework) + set(sdl_headers /Library/Frameworks/SDL2.framework/Headers) endif() -if(NOT opengl_library) - message(FATAL_ERROR "This CMake file is not yet educated as to where OpenGL resides on your platform. Sorry!") +if(NOT sdl_library) + message(FATAL_ERROR "This CMake file is not yet educated as to where SDL2 resides on your platform. Sorry!") endif() -include_directories(../include /usr/local/include) +include_directories(../include /usr/local/include ${sdl_headers}) link_directories(/usr/local/lib) @@ -39,4 +40,4 @@ add_executable(erc-test ${sources} ${test_sources}) target_link_libraries(erc-test criterion) # Graphics -target_link_libraries(erc-test) +target_link_libraries(erc-test ${sdl_library}) diff --git a/tests/vm_screen.c b/tests/vm_screen.c index 29e07d0..682e624 100644 --- a/tests/vm_screen.c +++ b/tests/vm_screen.c @@ -4,36 +4,23 @@ Test(vm_screen, create) { vm_screen *screen; + int x = 320; + int y = 240; + int scale = 2; - screen = vm_screen_create(); + screen = vm_screen_create(x, y, scale); cr_assert_neq(screen, NULL); - cr_assert_eq(screen->color_red, 0); - cr_assert_eq(screen->color_blue, 0); - cr_assert_eq(screen->color_green, 0); - cr_assert_eq(screen->color_alpha, 0); + cr_assert_eq(screen->xcoords, x); + cr_assert_eq(screen->ycoords, y); + cr_assert_eq(screen->scale, scale); + + cr_assert_eq(screen->window, NULL); + cr_assert_eq(screen->render, NULL); + cr_assert_eq(screen->rect.x, 0); + cr_assert_eq(screen->rect.y, 0); + cr_assert_eq(screen->rect.w, 0); + cr_assert_eq(screen->rect.h, 0); vm_screen_free(screen); } - -Test(vm_screen, set_color) { - vm_screen *screen; - int red = 0xDE; - int green = 0xAD; - int blue = 0xBE; - int alpha = 0xEF; - - screen = vm_screen_create(); - vm_screen_set_color(screen, red, green, blue, alpha); - - cr_assert_eq(screen->color_red, red); - cr_assert_eq(screen->color_green, green); - cr_assert_eq(screen->color_blue, blue); - cr_assert_eq(screen->color_alpha, alpha); - - vm_screen_free(screen); -} - -Test(vm_screen, draw_rect) { - // Nothing to do here... -}