Today's lesson in not using Apple's private methods: somewhere between old/886f95f00431 and #9620 Apple changed their document icon setup process. Use the new methods and fix #9620.
(transplanted from 5cf365ce9352d25978ffd6073d3bc07573aba518)
/*
* Adium is the legal property of its developers, whose names are listed in the copyright file included
* with this source distribution.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "TestDateAdditions.h"
#import <AIUtilities/AIDateAdditions.h>
//2009-03-08T03:00:00.5 PDT - half a second after the start of Daylight Saving Time.
//We're testing converting intervals. If we use a time zone that supports DST, the DST changes screw us up. We need an invariant time zone, and UTC works well for this purpose.
STAssertEquals(weeks,(NSInteger)1,@"Expected the difference between now and 7 days ago, which is %f seconds, to be 1 week; result was %iw, %id, %ih, %im, %fs",[nowtimeIntervalSinceDate:then],weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 7 days ago to be 1 week, 0 days; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 7 days ago to be 1 week, 0 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 7 days ago to be 1 week, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 7 days ago to be 1 week, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
//Test eight days ago. [Insert obligatory Beatles reference]
STAssertEquals(weeks,(NSInteger)1,@"Expected the difference between now and 8 days ago to be 1 week, 1 day; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)1,@"Expected the difference between now and 8 days ago to be 1 week, 1 day; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 8 days ago to be 1 week, 1 day, 0 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 8 days ago to be 1 week, 1 day, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 8 days ago to be 1 week, 1 day, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
//Test six days (almost, but not quite, one week) ago. [Insert obligatory DJ Shadow reference]
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 6 days ago to be 0 weeks, 6 days; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)6,@"Expected the difference between now and 6 days ago to be 6 days; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 6 days ago to be 6 days, 0 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 6 days ago to be 6 days, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 6 days ago to be 6 days, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 1 day ago to be 0 weeks, 1 day; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)1,@"Expected the difference between now and 1 day ago to be 1 day; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 1 day ago to be 1 day, 0 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 1 day ago to be 1 day, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 1 day ago to be 1 day, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 1 day ago to be 0 weeks, 1 day; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)1,@"Expected the difference between now and 1 day ago to be 1 day; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 1 day ago to be 1 day, 0 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 1 day ago to be 1 day, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 1 day ago to be 1 day, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
//Test 23 hours (almost, but not quite, one day) ago.
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 23 hours ago to be 0 weeks, 23 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 23 hours ago to be 0 days, 23 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)23,@"Expected the difference between now and 23 hours ago to be 23 hours; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 23 hours ago to be 23 hours, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 23 hours ago to be 23 hours, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 1 hour ago to be 0 weeks, 1 hour; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 1 hour ago to be 0 days, 1 hour; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)1,@"Expected the difference between now and 1 hour ago to be 1 hour; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 1 hour ago to be 1 hour, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 1 hour ago to be 1 hour, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 1 hour ago to be 0 weeks, 1 hour; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 1 hour ago to be 0 days, 1 hour; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)1,@"Expected the difference between now and 1 hour ago to be 1 hour; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 1 hour ago to be 1 hour, 0 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 1 hour ago to be 1 hour, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
//Test 59 minutes (almost, but not quite, one hour) ago.
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 59 minutes ago to be 0 weeks, 59 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 59 minutes ago to be 0 days, 59 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 59 minutes ago to be 0 hours, 59 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)59,@"Expected the difference between now and 59 minutes ago to be 59 minutes; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 59 minutes ago to be 59 minutes, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 1 minute ago to be 0 weeks, 1 minute; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 1 minute ago to be 0 days, 1 minute; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 1 minute ago to be 0 hours, 1 minute; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)1,@"Expected the difference between now and 1 minute ago to be 1 minute; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,0.0,@"Expected the difference between now and 1 minute ago to be 1 minute, 0 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
//Test 59 seconds (almost, but not quite, one minute) ago.
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 59 seconds ago to be 0 weeks, 59 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 59 seconds ago to be 0 days, 59 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 59 seconds ago to be 0 hours, 59 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 59 seconds ago to be 0 minutes, 59 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,59.0,@"Expected the difference between now and 59 seconds ago to be 59 seconds; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(weeks,(NSInteger)0,@"Expected the difference between now and 1 second ago to be 0 weeks, 1 second; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(days,(NSInteger)0,@"Expected the difference between now and 1 second ago to be 0 days, 1 second; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(hours,(NSInteger)0,@"Expected the difference between now and 1 second ago to be 0 hours, 1 second; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(minutes,(NSInteger)0,@"Expected the difference between now and 1 second ago to be 0 minutes, 1 second; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);
STAssertEquals(seconds,1.0,@"Expected the difference between now and 1 second ago to be 1 second; result was %iw, %id, %ih, %im, %fs",weeks,days,hours,minutes,seconds);