all repos — mgba @ bdfb1b72be8f2441c205856f614e6ce463cc7ced

mGBA Game Boy Advance Emulator

src/gb/test/core.c (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "util/test/suite.h"
 7
 8#include "core/core.h"
 9#include "gb/core.h"
10#include "gb/gb.h"
11#include "util/vfs.h"
12
13M_TEST_DEFINE(create) {
14	struct mCore* core = GBCoreCreate();
15	assert_non_null(core);
16	assert_true(core->init(core));
17	core->deinit(core);
18}
19
20M_TEST_DEFINE(platform) {
21	struct mCore* core = GBCoreCreate();
22	assert_non_null(core);
23	assert_int_equal(core->platform(core), PLATFORM_GB);
24	assert_true(core->init(core));
25	core->deinit(core);
26}
27
28M_TEST_DEFINE(reset) {
29	struct mCore* core = GBCoreCreate();
30	assert_non_null(core);
31	assert_true(core->init(core));
32	core->reset(core);
33	core->deinit(core);
34}
35
36M_TEST_DEFINE(loadNullROM) {
37	struct mCore* core = GBCoreCreate();
38	assert_non_null(core);
39	assert_true(core->init(core));
40	assert_false(core->loadROM(core, NULL));
41	core->reset(core);
42	core->deinit(core);
43}
44
45M_TEST_DEFINE(isROM) {
46	struct VFile* vf = VFileMemChunk(NULL, 2048);
47	GBSynthesizeROM(vf);
48	assert_true(GBIsROM(vf));
49	struct mCore* core = mCoreFindVF(vf);
50	assert_non_null(core);
51	assert_int_equal(core->platform(core), PLATFORM_GB);
52	assert_true(core->init(core));
53	core->deinit(core);
54}
55
56M_TEST_SUITE_DEFINE(GBCore,
57	cmocka_unit_test(create),
58	cmocka_unit_test(platform),
59	cmocka_unit_test(reset),
60	cmocka_unit_test(loadNullROM),
61	cmocka_unit_test(isROM))