1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-17 15:07:10 +00:00
erc-c/tests/vm_bitfont.c

68 lines
1.4 KiB
C
Raw Normal View History

2017-12-27 07:02:56 +00:00
/*
* vm_bitfont.c
*/
#include <criterion/criterion.h>
#include "objstore.h"
2017-12-27 07:02:56 +00:00
#include "vm_bitfont.h"
static vm_bitfont *font;
static void
setup()
{
vm_screen *screen;
objstore_init();
2017-12-27 07:02:56 +00:00
screen = vm_screen_create();
font = vm_bitfont_create(screen,
objstore_apple2_sysfont(),
APPLE2_SYSFONT_SIZE,
7, 8, 0x7F);
2017-12-27 07:02:56 +00:00
}
static void
teardown()
{
vm_bitfont_free(font);
}
TestSuite(vm_bitfont, .init = setup, .fini = teardown);
/* Test(vm_bitfont, free) */
2017-12-27 07:02:56 +00:00
Test(vm_bitfont, create)
{
cr_assert_neq(font, NULL);
cr_assert_eq(font->width, 7);
cr_assert_eq(font->height, 8);
cr_assert_eq(font->cmask, 0x7F);
// This should be NULL because we have no screen
cr_assert_eq(font->texture, NULL);
}
Test(vm_bitfont, offset)
{
char ch = 'p';
vm_area area;
2017-12-27 07:02:56 +00:00
vm_bitfont_offset(font, ch, &area);
2017-12-27 07:02:56 +00:00
cr_assert_eq(area.xoff, (ch & 0x0f) * font->width);
cr_assert_eq(area.yoff, (ch >> 4) * font->height);
2017-12-27 07:02:56 +00:00
}
/*
* A note: I omitted a test for vm_bitfont_render(), as this function is
* a) reliant on vm_bitfont_offset for the right glyph to render, and b)
* is otherwise reliant on our graphics library to properly render the
* character. As we run our tests in a headless mode, we are unable to
* automate that specific kind of test.
*/
Test(vm_bitfont, render)
{
}