mirror of
https://github.com/pevans/erc-c.git
synced 2024-10-15 00:23:42 +00:00
62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
|
/*
|
||
|
* vm_bitfont.c
|
||
|
*/
|
||
|
|
||
|
#include <criterion/criterion.h>
|
||
|
|
||
|
#include "vm_bitfont.h"
|
||
|
|
||
|
static vm_bitfont *font;
|
||
|
|
||
|
static void
|
||
|
setup()
|
||
|
{
|
||
|
vm_screen *screen;
|
||
|
|
||
|
screen = vm_screen_create();
|
||
|
font = vm_bitfont_create(screen, "apple2-system", 7, 8, 0x7F);
|
||
|
}
|
||
|
|
||
|
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';
|
||
|
int x = 0;
|
||
|
int y = 0;
|
||
|
|
||
|
vm_bitfont_offset(font, ch, &x, &y);
|
||
|
|
||
|
cr_assert_eq(x, (ch & 0x0f) * font->width);
|
||
|
cr_assert_eq(y, (ch >> 4) * font->height);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* 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)
|
||
|
{
|
||
|
}
|