/* * Copyright (c) 2008-2024 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "ObjFW.h" #define TEST(test, ...) \ { \ [self outputTesting: test inModule: module]; \ \ if (__VA_ARGS__) \ [self outputSuccess: test inModule: module]; \ else { \ [self outputFailure: test inModule: module]; \ _fails++; \ } \ } #define EXPECT_EXCEPTION(test, exception, code) \ { \ bool caught = false; \ \ [self outputTesting: test inModule: module]; \ \ @try { \ code; \ } @catch (exception *e) { \ caught = true; \ } \ \ if (caught) \ [self outputSuccess: test inModule: module]; \ else { \ [self outputFailure: test inModule: module]; \ _fails++; \ } \ } #define R(...) (__VA_ARGS__, 1) @class OFString; @interface TestsAppDelegate: OFObject { int _fails; } - (void)outputTesting: (OFString *)test inModule: (OFString *)module; - (void)outputSuccess: (OFString *)test inModule: (OFString *)module; - (void)outputFailure: (OFString *)test inModule: (OFString *)module; @end