Index: new_tests/Makefile ================================================================== --- new_tests/Makefile +++ new_tests/Makefile @@ -1,11 +1,12 @@ include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} -SRCS = OFNumberTests.m \ +SRCS = OFColorTests.m \ + OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ ${USE_SRCS_PLUGINS} SRCS_PLUGINS = OFPluginTests.m ADDED new_tests/OFColorTests.m Index: new_tests/OFColorTests.m ================================================================== --- new_tests/OFColorTests.m +++ new_tests/OFColorTests.m @@ -0,0 +1,60 @@ +/* + * 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. + */ + +#include "config.h" + +#import "ObjFW.h" +#import "ObjFWTest.h" + +@interface OFColorTests: OTTestCase +{ + OFColor *_color; +} +@end + +@implementation OFColorTests +- (void)setUp +{ + _color = [[OFColor alloc] initWithRed: 63.f / 255 + green: 127.f / 255 + blue: 1 + alpha: 1]; +} + +- (void)dealloc +{ + [_color release]; + + [super dealloc]; +} + +#ifdef OF_OBJFW_RUNTIME +- (void)testReturnsTaggedPointer +{ + OTAssertTrue(object_isTaggedPointer(_color)); +} +#endif + +- (void)testGetRedGreenBlueAlpha +{ + float red, green, blue, alpha; + + [_color getRed: &red green: &green blue: &blue alpha: &alpha]; + OTAssertEqual(red, 63.f / 255); + OTAssertEqual(green, 127.f / 255); + OTAssertEqual(blue, 1); + OTAssertEqual(alpha, 1); +} +@end Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -18,11 +18,10 @@ STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = ForwardingTests.m \ OFArrayTests.m \ ${OF_BLOCK_TESTS_M} \ OFCharacterSetTests.m \ - OFColorTests.m \ OFDataTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ DELETED tests/OFColorTests.m Index: tests/OFColorTests.m ================================================================== --- tests/OFColorTests.m +++ tests/OFColorTests.m @@ -1,47 +0,0 @@ -/* - * 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. - */ - -#include "config.h" - -#import "TestsAppDelegate.h" - -static OFString *const module = @"OFColor"; - -@implementation TestsAppDelegate (OFColorTests) -- (void)colorTests -{ - void *pool = objc_autoreleasePoolPush(); - OFColor *color; - float red, green, blue, alpha; - - TEST(@"+[colorWithRed:green:blue:alpha:]", - (color = [OFColor colorWithRed: 63.f / 255 - green: 127.f / 255 - blue: 1 - alpha: 1])) - -#ifdef OF_OBJFW_RUNTIME - TEST(@"+[colorWithRed:green:blue:alpha:] returns tagged pointer", - object_isTaggedPointer(color)) -#endif - - TEST(@"-[getRed:green:blue:alpha:]", - R([color getRed: &red green: &green blue: &blue alpha: &alpha]) && - red == 63.f / 255 && green == 127.f / 255 && blue == 1 && - alpha == 1) - - objc_autoreleasePoolPop(pool); -} -@end