mirror of https://github.com/mgba-emu/mgba.git
Test: More basic tests
This commit is contained in:
parent
e54772fead
commit
a30599e239
|
@ -0,0 +1,47 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
#include "core/core.h"
|
||||
#include "gb/core.h"
|
||||
|
||||
M_TEST_DEFINE(create) {
|
||||
struct mCore* core = GBCoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->init(core));
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(platform) {
|
||||
struct mCore* core = GBCoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->platform(core) == PLATFORM_GB);
|
||||
assert_true(core->init(core));
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(reset) {
|
||||
struct mCore* core = GBCoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->init(core));
|
||||
core->reset(core);
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(loadNullROM) {
|
||||
struct mCore* core = GBCoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->init(core));
|
||||
assert_false(core->loadROM(core, NULL));
|
||||
core->reset(core);
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_SUITE_DEFINE(GBCore,
|
||||
cmocka_unit_test(create),
|
||||
cmocka_unit_test(platform),
|
||||
cmocka_unit_test(reset),
|
||||
cmocka_unit_test(loadNullROM))
|
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
M_TEST_SUITE_DECLARE(GBCore);
|
||||
|
||||
int TestRunGB(void) {
|
||||
int failures = 0;
|
||||
failures += M_TEST_SUITE_RUN(GBCore);
|
||||
return failures;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef TEST_GB_H
|
||||
#define TEST_GB_H
|
||||
#include "util/common.h"
|
||||
|
||||
int TestRunGB(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,47 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
#include "core/core.h"
|
||||
#include "gba/core.h"
|
||||
|
||||
M_TEST_DEFINE(create) {
|
||||
struct mCore* core = GBACoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->init(core));
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(platform) {
|
||||
struct mCore* core = GBACoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->platform(core) == PLATFORM_GBA);
|
||||
assert_true(core->init(core));
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(reset) {
|
||||
struct mCore* core = GBACoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->init(core));
|
||||
core->reset(core);
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(loadNullROM) {
|
||||
struct mCore* core = GBACoreCreate();
|
||||
assert_non_null(core);
|
||||
assert_true(core->init(core));
|
||||
assert_false(core->loadROM(core, NULL));
|
||||
core->reset(core);
|
||||
core->deinit(core);
|
||||
}
|
||||
|
||||
M_TEST_SUITE_DEFINE(GBACore,
|
||||
cmocka_unit_test(create),
|
||||
cmocka_unit_test(platform),
|
||||
cmocka_unit_test(reset),
|
||||
cmocka_unit_test(loadNullROM))
|
|
@ -0,0 +1,14 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
M_TEST_SUITE_DECLARE(GBACore);
|
||||
|
||||
int TestRunGBA(void) {
|
||||
int failures = 0;
|
||||
failures += M_TEST_SUITE_RUN(GBACore);
|
||||
return failures;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef TEST_GBA_H
|
||||
#define TEST_GBA_H
|
||||
#include "util/common.h"
|
||||
|
||||
int TestRunGBA(void);
|
||||
|
||||
#endif
|
|
@ -7,9 +7,21 @@
|
|||
|
||||
#include "util/test/util.h"
|
||||
#include "core/test/core.h"
|
||||
#ifdef M_CORE_GBA
|
||||
#include "gba/test/gba.h"
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
#include "gb/test/gb.h"
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
int failures = TestRunUtil();
|
||||
failures += TestRunCore();
|
||||
#ifdef M_CORE_GBA
|
||||
failures += TestRunGBA();
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
failures += TestRunGB();
|
||||
#endif
|
||||
return failures != 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define M_TEST_DEFINE(NAME) static void NAME (void **state ATTRIBUTE_UNUSED)
|
||||
|
||||
#define M_TEST_SUITE(NAME) _testSuite_ ## NAME
|
||||
#define M_TEST_SUITE_RUN(NAME) M_TEST_SUITE(NAME)()
|
||||
#define M_TEST_SUITE_RUN(NAME) printf("\nRunning suite %s\n", # NAME), M_TEST_SUITE(NAME)()
|
||||
#define M_TEST_SUITE_DEFINE(NAME, ...) \
|
||||
int M_TEST_SUITE(NAME) (void) { \
|
||||
const static struct CMUnitTest tests[] = { \
|
||||
|
@ -24,4 +24,4 @@
|
|||
|
||||
#define M_TEST_SUITE_DECLARE(NAME) extern int M_TEST_SUITE(NAME) (void)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue