2017-12-27 07:02:56 +00:00
|
|
|
/*
|
|
|
|
* vm_bitfont.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <criterion/criterion.h>
|
|
|
|
|
2018-01-04 03:50:30 +00:00
|
|
|
#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;
|
|
|
|
|
2018-01-04 03:50:30 +00:00
|
|
|
objstore_init();
|
|
|
|
|
2017-12-27 07:02:56 +00:00
|
|
|
screen = vm_screen_create();
|
2018-01-04 03:50:30 +00:00
|
|
|
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, 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';
|
2017-12-27 22:47:26 +00:00
|
|
|
vm_area area;
|
2017-12-27 07:02:56 +00:00
|
|
|
|
2017-12-27 22:47:26 +00:00
|
|
|
vm_bitfont_offset(font, ch, &area);
|
2017-12-27 07:02:56 +00:00
|
|
|
|
2017-12-27 22:47:26 +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)
|
|
|
|
{
|
|
|
|
}
|