1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-26 10:29:34 +00:00

Add objstore_clear(), tests for objstore

This commit is contained in:
Peter Evans 2018-01-07 16:30:33 -06:00
parent 1c36c4ea4d
commit ba47de0e4b
3 changed files with 30 additions and 1 deletions

View File

@ -13,8 +13,9 @@ typedef struct {
vm_8bit apple2_sysfont[APPLE2_SYSFONT_SIZE];
} objstore;
extern int objstore_init();
extern bool objstore_ready();
extern int objstore_init();
extern void objstore_clear();
#define OBJSTORE_DECL(x) \
const vm_8bit *objstore_##x()

View File

@ -51,6 +51,16 @@ objstore_init()
return OK;
}
/*
* This will empty out the store, which is not very _practically_
* useful, but is a bit useful when testing.
*/
void
objstore_clear()
{
memset(&store, 0, sizeof(store));
}
/*
* Return true if the object store is ready to be used.
*/

View File

@ -5,5 +5,23 @@
Test(objstore, init)
{
objstore_clear();
cr_assert_eq(objstore_init(), OK);
cr_assert_eq(objstore_ready(), true);
}
Test(objstore, ready)
{
objstore_clear();
cr_assert_eq(objstore_ready(), false);
objstore_init();
cr_assert_eq(objstore_ready(), true);
}
Test(objstore, clear)
{
objstore_init();
cr_assert_eq(objstore_ready(), true);
objstore_clear();
cr_assert_eq(objstore_ready(), false);
}