all repos — mgba @ a760c7bb4a85c8abea17ff9db466e96ebe20a8de

mGBA Game Boy Advance Emulator

src/gba/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 <mgba/core/core.h>
 9#include <mgba/gba/core.h>
10
11M_TEST_DEFINE(create) {
12	struct mCore* core = GBACoreCreate();
13	assert_non_null(core);
14	assert_true(core->init(core));
15	core->deinit(core);
16}
17
18M_TEST_DEFINE(platform) {
19	struct mCore* core = GBACoreCreate();
20	assert_non_null(core);
21	assert_true(core->platform(core) == mPLATFORM_GBA);
22	assert_true(core->init(core));
23	core->deinit(core);
24}
25
26M_TEST_DEFINE(reset) {
27	struct mCore* core = GBACoreCreate();
28	assert_non_null(core);
29	assert_true(core->init(core));
30	mCoreInitConfig(core, NULL);
31	core->reset(core);
32	mCoreConfigDeinit(&core->config);
33	core->deinit(core);
34}
35
36M_TEST_DEFINE(loadNullROM) {
37	struct mCore* core = GBACoreCreate();
38	assert_non_null(core);
39	assert_true(core->init(core));
40	assert_false(core->loadROM(core, NULL));
41	mCoreInitConfig(core, NULL);
42	core->reset(core);
43	mCoreConfigDeinit(&core->config);
44	core->deinit(core);
45}
46
47M_TEST_SUITE_DEFINE(GBACore,
48	cmocka_unit_test(create),
49	cmocka_unit_test(platform),
50	cmocka_unit_test(reset),
51	cmocka_unit_test(loadNullROM))