1
0
mirror of https://github.com/pevans/erc-c.git synced 2025-02-25 14:29:13 +00:00
erc-c/tests/vm_screen.c
Peter Evans c7b830bb4a Switch references from SDL_Rect to vm_area
We still use SDL_Rect internally, but we want to abstract the use of it
in our API. The only thing the rest of the app should care about is the
vm_area struct.
2017-12-27 16:31:02 -06:00

59 lines
1.3 KiB
C

/*
* vm_screen.c
*
* Generally speaking the tests here are very incomplete; this is partly
* because a lot of the code in vm_screen depends on a third-party
* graphics library, but I think we can do a better job of decoupling
* some concepts (like screen areas) from the graphics library, such
* that we can make the code that uses those testable.
*/
#include <criterion/criterion.h>
#include "vm_screen.h"
static vm_screen *screen;
static void
setup()
{
screen = vm_screen_create();
}
static void
teardown()
{
vm_screen_free(screen);
}
TestSuite(vm_screen, .init = setup, .fini = teardown);
Test(vm_screen, create) {
cr_assert_neq(screen, NULL);
cr_assert_eq(screen->window, NULL);
cr_assert_eq(screen->render, NULL);
cr_assert_eq(screen->area.xoff, 0);
cr_assert_eq(screen->area.yoff, 0);
cr_assert_eq(screen->area.width, 0);
cr_assert_eq(screen->area.height, 0);
cr_assert_eq(screen->xcoords, 0);
cr_assert_eq(screen->ycoords, 0);
}
Test(vm_screen, xcoords)
{
screen->xcoords = 123;
cr_assert_eq(screen->xcoords, 123);
screen->xcoords = 234;
cr_assert_eq(screen->xcoords, 234);
}
Test(vm_screen, ycoords)
{
screen->ycoords = 123;
cr_assert_eq(screen->ycoords, 123);
screen->ycoords = 234;
cr_assert_eq(screen->ycoords, 234);
}