11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
-
-
+
+
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
-
|
* 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"
#import "ObjFW.h"
#import "ObjFWTest.h"
static OFString *const module = @"OFColor";
@implementation TestsAppDelegate (OFColorTests)
- (void)colorTests
@interface OFColorTests: OTTestCase
{
void *pool = objc_autoreleasePoolPush();
OFColor *color;
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]))
}
@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
TEST(@"+[colorWithRed:green:blue:alpha:] returns tagged pointer",
object_isTaggedPointer(color))
- (void)testReturnsTaggedPointer
{
OTAssertTrue(object_isTaggedPointer(_color));
}
#endif
- (void)testGetRedGreenBlueAlpha
{
float red, green, blue, alpha;
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)
[_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);
objc_autoreleasePoolPop(pool);
}
@end
|