23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
@implementation TestsAppDelegate (OFNumberTests)
- (void)numberTests
{
void *pool = objc_autoreleasePoolPush();
OFNumber *num;
TEST(@"+[numberWithIntMax:]",
(num = [OFNumber numberWithIntMax: 123456789]))
TEST(@"-[isEqual:]",
[num isEqual: [OFNumber numberWithUInt32: 123456789]])
TEST(@"-[hash]", num.hash == 0x82D8BC42)
TEST(@"-[charValue]", num.charValue == 21)
TEST(@"-[doubleValue]", num.doubleValue == 123456789.L)
objc_autoreleasePoolPop(pool);
}
@end
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
@implementation TestsAppDelegate (OFNumberTests)
- (void)numberTests
{
void *pool = objc_autoreleasePoolPush();
OFNumber *num;
TEST(@"+[numberWithLongLong:]",
(num = [OFNumber numberWithLongLong: 123456789]))
TEST(@"-[isEqual:]",
[num isEqual: [OFNumber numberWithLong: 123456789]])
TEST(@"-[hash]", num.hash == 0x82D8BC42)
TEST(@"-[charValue]", num.charValue == 21)
TEST(@"-[doubleValue]", num.doubleValue == 123456789.L)
TEST(@"signed char minimum & maximum unmodified",
(num = [OFNumber numberWithChar: SCHAR_MIN]) &&
num.charValue == SCHAR_MIN &&
(num = [OFNumber numberWithChar: SCHAR_MAX]) &&
num.charValue == SCHAR_MAX)
TEST(@"short minimum & maximum unmodified",
(num = [OFNumber numberWithShort: SHRT_MIN]) &&
num.shortValue == SHRT_MIN &&
(num = [OFNumber numberWithShort: SHRT_MAX]) &&
num.shortValue == SHRT_MAX)
TEST(@"int minimum & maximum unmodified",
(num = [OFNumber numberWithInt: INT_MIN]) &&
num.intValue == INT_MIN &&
(num = [OFNumber numberWithInt: INT_MAX]) &&
num.intValue == INT_MAX)
TEST(@"long minimum & maximum unmodified",
(num = [OFNumber numberWithLong: LONG_MIN]) &&
num.longValue == LONG_MIN &&
(num = [OFNumber numberWithLong: LONG_MAX]) &&
num.longValue == LONG_MAX)
TEST(@"long long minimum & maximum unmodified",
(num = [OFNumber numberWithLongLong: LLONG_MIN]) &&
num.longLongValue == LLONG_MIN &&
(num = [OFNumber numberWithLongLong: LLONG_MAX]) &&
num.longLongValue == LLONG_MAX)
TEST(@"unsigned char maximum unmodified",
(num = [OFNumber numberWithUnsignedChar: UCHAR_MAX]) &&
num.unsignedCharValue == UCHAR_MAX)
TEST(@"unsigned short maximum unmodified",
(num = [OFNumber numberWithUnsignedShort: USHRT_MAX]) &&
num.unsignedShortValue == USHRT_MAX)
TEST(@"unsigned int maximum unmodified",
(num = [OFNumber numberWithUnsignedInt: UINT_MAX]) &&
num.unsignedIntValue == UINT_MAX)
TEST(@"unsigned long maximum unmodified",
(num = [OFNumber numberWithUnsignedLong: ULONG_MAX]) &&
num.unsignedLongValue == ULONG_MAX)
TEST(@"unsigned long long maximum unmodified",
(num = [OFNumber numberWithUnsignedLongLong: ULLONG_MAX]) &&
num.unsignedLongLongValue == ULLONG_MAX)
objc_autoreleasePoolPop(pool);
}
@end
|