44 lines
1.6 KiB
C
44 lines
1.6 KiB
C
// =========================================
|
|
// | SilverMUD Tests - tests.h |
|
|
// | Copyright (C) 2023, Barra Ó Catháin |
|
|
// | See end of file for copyright notice. |
|
|
// =========================================
|
|
#ifndef SILVERMUD_TESTS
|
|
#define SILVERMUD_TESTS
|
|
|
|
#define SETUP_TESTS \
|
|
size_t TEST_SUCCESSES = 0, TEST_FAILURES = 0, TEST_COUNT;
|
|
|
|
#define TEST(STRING, CONDITION) \
|
|
printf("Test %zu: ", ++TEST_COUNT); \
|
|
printf(STRING); \
|
|
if (CONDITION) { printf("... SUCCESS!\n"); TEST_SUCCESSES++; } \
|
|
else { printf("... FAILED.\n"); TEST_FAILURES++; }
|
|
|
|
#define FINISH_TESTING \
|
|
printf("=====\n\nSuccesses: %zu | Failures: %zu\n", TEST_SUCCESSES, TEST_FAILURES); \
|
|
if (TEST_FAILURES == 0) \
|
|
{ \
|
|
printf("All good! We're done here.\n"); \
|
|
exit(EXIT_SUCCESS); \
|
|
} \
|
|
exit(EXIT_FAILURE);
|
|
|
|
#endif
|
|
// =============================================
|
|
// | End of tests.h, copyright notice follows. |
|
|
// =============================================
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|