Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 77 lines (54 sloc) 2.217 kB
3a62ada @Midar Add OFDate.
authored
1 /*
f818004 @Midar Change license.
authored
2 * Copyright (c) 2008, 2009, 2010, 2011
3a62ada @Midar Add OFDate.
authored
3 * Jonathan Schleifer <js@webkeks.org>
4 *
5 * All rights reserved.
6 *
7 * This file is part of ObjFW. It may be distributed under the terms of the
f818004 @Midar Change license.
authored
8 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
3a62ada @Midar Add OFDate.
authored
9 * the packaging of this file.
f818004 @Midar Change license.
authored
10 *
11 * Alternatively, it may be distributed under the terms of the GNU General
12 * Public License, either version 2 or 3, which can be found in the file
13 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14 * file.
3a62ada @Midar Add OFDate.
authored
15 */
16
17 #include "config.h"
18
19 #import "OFDate.h"
20 #import "OFString.h"
21 #import "OFAutoreleasePool.h"
22
23 #import "TestsAppDelegate.h"
24
25 static OFString *module = @"OFDate";
26
27 @implementation TestsAppDelegate (OFDateTests)
28 - (void)dateTests
29 {
30 OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
31 OFDate *d1, *d2;
32
33 TEST(@"+[dateWithTimeIntervalSince1970:]",
34 (d1 = [OFDate dateWithTimeIntervalSince1970: 0]))
35
6655140 @Midar Fix two unimportant typos.
authored
36 TEST(@"+[dateWithTimeIntervalSince1970:microseconds:]",
40e21d7 @Midar Style improvements in OFDate.
authored
37 (d2 = [d1 dateByAddingTimeInterval: 3600 * 25 + 5
38 withMicroseconds: 1]))
3a62ada @Midar Add OFDate.
authored
39
40 TEST(@"-[description]",
60b9010 @Midar Add +[OFFile modificationDateOfFile:] and change -[OFDate description].
authored
41 [[d1 description] isEqual: @"1970-01-01T00:00:00Z"] &&
82c3fe9 @Midar Don't include microseconds in -[OFDate description].
authored
42 [[d2 description] isEqual: @"1970-01-02T01:00:05Z"])
3a62ada @Midar Add OFDate.
authored
43
44 TEST(@"-[isEqual:]",
45 [d1 isEqual: [OFDate dateWithTimeIntervalSince1970: 0]] &&
46 ![d1 isEqual: [OFDate dateWithTimeIntervalSince1970: 0
47 microseconds: 1]])
48
49 TEST(@"-[compare:]", [d1 compare: d2] == OF_ORDERED_ASCENDING)
50
40e21d7 @Midar Style improvements in OFDate.
authored
51 TEST(@"-[second]", [d1 second] == 0 && [d2 second] == 5)
46afa0a @Midar Add methods to access parts of a date, in GMT/UTC.
authored
52
32563b2 @Midar Add methods for local time to OFDate.
authored
53 TEST(@"-[microsecond]",
54 [d1 microsecond] == 0 && [d2 microsecond] == 1)
46afa0a @Midar Add methods to access parts of a date, in GMT/UTC.
authored
55
32563b2 @Midar Add methods for local time to OFDate.
authored
56 TEST(@"-[minute]", [d1 minute] == 0 && [d2 minute] == 0)
46afa0a @Midar Add methods to access parts of a date, in GMT/UTC.
authored
57
32563b2 @Midar Add methods for local time to OFDate.
authored
58 TEST(@"-[hour]", [d1 hour] == 0 && [d2 hour] == 1)
46afa0a @Midar Add methods to access parts of a date, in GMT/UTC.
authored
59
60 TEST(@"-[dayOfMonth]", [d1 dayOfMonth] == 1 && [d2 dayOfMonth] == 2)
61
62 TEST(@"-[monthOfYear]", [d1 monthOfYear] == 1 && [d2 monthOfYear] == 1)
63
64 TEST(@"-[year]", [d1 year] == 1970 && [d2 year] == 1970)
65
66 TEST(@"-[dayOfWeek]", [d1 dayOfWeek] == 4 && [d2 dayOfWeek] == 5)
67
68 TEST(@"-[dayOfYear]", [d1 dayOfYear] == 1 && [d2 dayOfYear] == 2)
69
48c73ef @Midar Add -[earlierDate:] and -[laterDate:] to OFDate.
authored
70 TEST(@"-[earlierDate:]", [[d1 earlierDate: d2] isEqual: d1])
71
72 TEST(@"-[laterDate:]", [[d1 laterDate: d2] isEqual: d2])
73
3a62ada @Midar Add OFDate.
authored
74 [pool drain];
75 }
76 @end
Something went wrong with that request. Please try again.