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 <mgba/core/core.h>
9#include <mgba/gb/core.h>
10#include <mgba/internal/gb/gb.h>
11#include <mgba-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 mCoreInitConfig(core, NULL);
33 core->reset(core);
34 core->deinit(core);
35}
36
37M_TEST_DEFINE(loadNullROM) {
38 struct mCore* core = GBCoreCreate();
39 assert_non_null(core);
40 assert_true(core->init(core));
41 mCoreInitConfig(core, NULL);
42 assert_false(core->loadROM(core, NULL));
43 core->reset(core);
44 core->deinit(core);
45}
46
47M_TEST_DEFINE(isROM) {
48 struct VFile* vf = VFileMemChunk(NULL, 2048);
49 GBSynthesizeROM(vf);
50 assert_true(GBIsROM(vf));
51 struct mCore* core = mCoreFindVF(vf);
52 assert_non_null(core);
53 assert_int_equal(core->platform(core), PLATFORM_GB);
54 assert_true(core->init(core));
55 core->deinit(core);
56}
57
58M_TEST_SUITE_DEFINE(GBCore,
59 cmocka_unit_test(create),
60 cmocka_unit_test(platform),
61 cmocka_unit_test(reset),
62 cmocka_unit_test(loadNullROM),
63 cmocka_unit_test(isROM))