all repos — mgba @ 287ab91739e5780834066f497db9b78755436912

mGBA Game Boy Advance Emulator

src/util/test/suite.h (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#ifndef SUITE_H
 7#define SUITE_H
 8#include "util/common.h"
 9
10#include <setjmp.h>
11#include <cmocka.h>
12
13#define M_TEST_DEFINE(NAME) static void NAME (void **state ATTRIBUTE_UNUSED)
14
15#define M_TEST_SUITE(NAME) _testSuite_ ## NAME
16#define M_TEST_SUITE_RUN(NAME) printf("\nRunning suite %s\n", # NAME), M_TEST_SUITE(NAME)()
17#define M_TEST_SUITE_DEFINE(NAME, ...) \
18	int M_TEST_SUITE(NAME) (void) { \
19		const static struct CMUnitTest tests[] = { \
20			__VA_ARGS__ \
21		}; \
22		return cmocka_run_group_tests_name(# NAME, tests, NULL, NULL); \
23	}
24
25#define M_TEST_SUITE_DECLARE(NAME) extern int M_TEST_SUITE(NAME) (void)
26
27#endif