adium-1.4 3307:026d0b0ec4fb: Changed encoding metadata in projec...

commits at adium.im commits at adium.im
Sun Dec 19 06:21:46 UTC 2010


details:	http://hg.adium.im/adium-1.4/rev/026d0b0ec4fb
revision:	3307:026d0b0ec4fb
author:		Peter Hosey <hg at boredzo.org>
date:		Sat Dec 18 21:53:31 2010 -0800

Changed encoding metadata in project file of AIChatLog.m. Since it contains UTF-8 sequences, this means it now displays correctly in Xcode.
Subject: adium-1.4 3308:de5dde2df90b: Move the scandate function (this version of it, at least) into a separate pair of files and make a test case for it*. Currently, all 7 tests fail.

details:	http://hg.adium.im/adium-1.4/rev/de5dde2df90b
revision:	3308:de5dde2df90b
author:		Peter Hosey <hg at boredzo.org>
date:		Sat Dec 18 22:17:28 2010 -0800

Move the scandate function (this version of it, at least) into a separate pair of files and make a test case for it*. Currently, all 7 tests fail.

*Based on https://twitter.com/edr1084/status/16306394684727296 .
Subject: adium-1.4 3309:58a99313cd1b: Corrected this comment.

details:	http://hg.adium.im/adium-1.4/rev/58a99313cd1b
revision:	3309:58a99313cd1b
author:		Peter Hosey <hg at boredzo.org>
date:		Sat Dec 18 22:18:28 2010 -0800

Corrected this comment.
Subject: adium-1.4 3310:81824cc5c596: Documented what scandate is looking for in the input string.

details:	http://hg.adium.im/adium-1.4/rev/81824cc5c596
revision:	3310:81824cc5c596
author:		Peter Hosey <hg at boredzo.org>
date:		Sat Dec 18 22:19:05 2010 -0800

Documented what scandate is looking for in the input string.
Subject: adium-1.4 3311:0ee6ce1cf4d5: Fixed detection of the date by looking for the last open parenthesis, not the first. Down to one failure.

details:	http://hg.adium.im/adium-1.4/rev/0ee6ce1cf4d5
revision:	3311:0ee6ce1cf4d5
author:		Peter Hosey <hg at boredzo.org>
date:		Sat Dec 18 22:20:38 2010 -0800

Fixed detection of the date by looking for the last open parenthesis, not the first. Down to one failure.
Subject: adium-1.4 3312:e20de4ece246: Fixed a wrong value in the test case - this should be negative five hours, not positive five hours. All tests now pass.

details:	http://hg.adium.im/adium-1.4/rev/e20de4ece246
revision:	3312:e20de4ece246
author:		Peter Hosey <hg at boredzo.org>
date:		Sat Dec 18 22:21:40 2010 -0800

Fixed a wrong value in the test case - this should be negative five hours, not positive five hours. All tests now pass.

diffs (464 lines):

diff -r f5afcca2ed53 -r e20de4ece246 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Fri Dec 17 09:48:46 2010 -0600
+++ b/Adium.xcodeproj/project.pbxproj	Sat Dec 18 22:21:40 2010 -0800
@@ -226,6 +226,9 @@
 		318EA69C0D7A659900EDB105 /* TestColorAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 318EA69B0D7A659900EDB105 /* TestColorAdditions.m */; };
 		319B29800CE8EC6F00C65398 /* TestDateAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 319B297F0CE8EC6E00C65398 /* TestDateAdditions.m */; };
 		31A764B90DA572B8000AC729 /* AutoHyperlinks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3496A8EA07CE6CA30055BBAB /* AutoHyperlinks.framework */; };
+		31DDDA7012BDD5CE0048F6C0 /* scandate.m in Sources */ = {isa = PBXBuildFile; fileRef = 31DDDA6F12BDD5CE0048F6C0 /* scandate.m */; };
+		31DDDA7112BDD5CE0048F6C0 /* scandate.m in Sources */ = {isa = PBXBuildFile; fileRef = 31DDDA6F12BDD5CE0048F6C0 /* scandate.m */; };
+		31DDDA7A12BDD6E90048F6C0 /* TestScandate.m in Sources */ = {isa = PBXBuildFile; fileRef = 31DDDA7912BDD6E90048F6C0 /* TestScandate.m */; };
 		31E0CD810C5EEF5200271DB1 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31E0CD800C5EEF5200271DB1 /* CoreAudio.framework */; };
 		31FA804C0D4A8EB200ABE634 /* Adium.sdef in Resources */ = {isa = PBXBuildFile; fileRef = 0CAC6A130C0C657A0090AE95 /* Adium.sdef */; };
 		3402D5A5080DBC91004E50B4 /* SortConfiguration.nib in Resources */ = {isa = PBXBuildFile; fileRef = 347E791D07CAA52300350507 /* SortConfiguration.nib */; };
@@ -2070,6 +2073,10 @@
 		318EA69B0D7A659900EDB105 /* TestColorAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestColorAdditions.m; path = UnitTests/TestColorAdditions.m; sourceTree = "<group>"; };
 		319B29420CE8D28300C65398 /* TestDateAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestDateAdditions.h; path = UnitTests/TestDateAdditions.h; sourceTree = "<group>"; };
 		319B297F0CE8EC6E00C65398 /* TestDateAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestDateAdditions.m; path = UnitTests/TestDateAdditions.m; sourceTree = "<group>"; };
+		31DDDA6E12BDD5CE0048F6C0 /* scandate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scandate.h; path = Source/scandate.h; sourceTree = "<group>"; };
+		31DDDA6F12BDD5CE0048F6C0 /* scandate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = scandate.m; path = Source/scandate.m; sourceTree = "<group>"; };
+		31DDDA7812BDD6E90048F6C0 /* TestScandate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestScandate.h; path = UnitTests/TestScandate.h; sourceTree = "<group>"; };
+		31DDDA7912BDD6E90048F6C0 /* TestScandate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestScandate.m; path = UnitTests/TestScandate.m; sourceTree = "<group>"; };
 		31E0CD800C5EEF5200271DB1 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = "<absolute>"; };
 		31E84DF10C7F387800674BCA /* AIUnitTestUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIUnitTestUtilities.h; path = UnitTests/AIUnitTestUtilities.h; sourceTree = "<group>"; };
 		31FA7F0F0D4A75D000ABE634 /* TestRichTextCoercion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestRichTextCoercion.h; path = UnitTests/TestRichTextCoercion.h; sourceTree = "<group>"; };
@@ -2722,7 +2729,7 @@
 		34555C5F0DB6BCE500649CD4 /* AIContactObserverManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIContactObserverManager.m; path = "Frameworks/Adium Framework/Source/AIContactObserverManager.m"; sourceTree = "<group>"; };
 		3456231A0A3771D800E7FC97 /* ESRankingCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ESRankingCell.m; path = Source/ESRankingCell.m; sourceTree = "<group>"; };
 		3456231B0A3771D800E7FC97 /* ESRankingCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ESRankingCell.h; path = Source/ESRankingCell.h; sourceTree = "<group>"; };
-		3456231E0A3771E100E7FC97 /* AIChatLog.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = AIChatLog.m; path = Source/AIChatLog.m; sourceTree = "<group>"; };
+		3456231E0A3771E100E7FC97 /* AIChatLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIChatLog.m; path = Source/AIChatLog.m; sourceTree = "<group>"; };
 		3456231F0A3771E100E7FC97 /* AIChatLog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AIChatLog.h; path = Source/AIChatLog.h; sourceTree = "<group>"; };
 		345623240A3771F300E7FC97 /* AILogToGroup.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = AILogToGroup.m; path = Source/AILogToGroup.m; sourceTree = "<group>"; };
 		345623250A3771F400E7FC97 /* AILogToGroup.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AILogToGroup.h; path = Source/AILogToGroup.h; sourceTree = "<group>"; };
@@ -5211,6 +5218,8 @@
 				29B97323FDCFA39411CA2CEA /* Linked Frameworks */,
 				63C7E0280FAF9B7D00B310AC /* xcconfigs */,
 				19C28FACFE9D520D11CA2CBB /* Products */,
+				31DDDA7812BDD6E90048F6C0 /* TestScandate.h */,
+				31DDDA7912BDD6E90048F6C0 /* TestScandate.m */,
 			);
 			name = CocAIMe2;
 			sourceTree = "<group>";
@@ -7348,6 +7357,8 @@
 				349B359E0A5F2231008BE092 /* Views and Cells */,
 				3456231F0A3771E100E7FC97 /* AIChatLog.h */,
 				3456231E0A3771E100E7FC97 /* AIChatLog.m */,
+				31DDDA6E12BDD5CE0048F6C0 /* scandate.h */,
+				31DDDA6F12BDD5CE0048F6C0 /* scandate.m */,
 				345623250A3771F400E7FC97 /* AILogToGroup.h */,
 				345623240A3771F300E7FC97 /* AILogToGroup.m */,
 				345623270A3771F400E7FC97 /* AILogFromGroup.h */,
@@ -10204,6 +10215,8 @@
 				318EA69C0D7A659900EDB105 /* TestColorAdditions.m in Sources */,
 				634BCD1F0DDC1542005AF1C2 /* TestMutableStringAdditions.m in Sources */,
 				3107D5250F63134F0051DDD5 /* TestAttributedStringAdditions.m in Sources */,
+				31DDDA7112BDD5CE0048F6C0 /* scandate.m in Sources */,
+				31DDDA7A12BDD6E90048F6C0 /* TestScandate.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -10688,6 +10701,7 @@
 				11D915720FFC100700B39713 /* AIGenericMultipartImageUploader.m in Sources */,
 				11000D041098863B0096A1E2 /* AIDefaultFontRemovalPlugin.m in Sources */,
 				34906190127F78F200FC313F /* AITemporaryIRCAccountWindowController.m in Sources */,
+				31DDDA7012BDD5CE0048F6C0 /* scandate.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff -r f5afcca2ed53 -r e20de4ece246 Source/AIChatLog.m
--- a/Source/AIChatLog.m	Fri Dec 17 09:48:46 2010 -0600
+++ b/Source/AIChatLog.m	Sat Dec 18 22:21:40 2010 -0800
@@ -21,6 +21,7 @@
 #import "AICalendarDate.h"
 
 #import <AIUtilities/NSCalendarDate+ISO8601Parsing.h>
+#import "scandate.h"
 
 @implementation AIChatLog
 
@@ -306,134 +307,6 @@
 
 #pragma mark Date utilities
 
-//Scan an Adium date string, supahfast C style
-static BOOL scandate(const char *sample,
-					 unsigned long *outyear, unsigned long *outmonth,  unsigned long *outdate,
-					 BOOL *outHasTime, unsigned long *outhour, unsigned long *outminute, unsigned long *outsecond,
-					 long *outtimezone)
-{
-	BOOL success = YES;
-	unsigned long component;
-
-    //Read a date, followed by a '('.
-	//First, find the '('.
-	while (*sample != '(') {
-    	if (!*sample) {
-    		success = NO;
-    		goto fail;
-		} else {
-			++sample;
-		}
-    }
-	
-	//current character is a '(' now, so skip over it.
-    ++sample; //start with the next character
-	
-    /*get the year*/ {
-		while (*sample && (*sample < '0' || *sample > '9')) ++sample;
-		if (!*sample) {
-			success = NO;
-			goto fail;
-		}
-		component = strtoul(sample, (char **)&sample, 10);
-		if (outyear) *outyear = component;
-    }
-    
-    /*get the month*/ {
-		while (*sample && (*sample < '0' || *sample > '9')) ++sample;
-		if (!*sample) {
-			success = NO;
-			goto fail;
-		}
-		component = strtoul(sample, (char **)&sample, 10);
-		if (outmonth) *outmonth = component;
-    }
-    
-    /*get the date*/ {
-		while (*sample && (*sample < '0' || *sample > '9')) ++sample;
-		if (!*sample) {
-			success = NO;
-			goto fail;
-		}
-		component = strtoul(sample, (char **)&sample, 10);
-		if (outdate) *outdate = component;
-    }
-
-    if (*sample == 'T') {
-		++sample; //start with the next character
-		if (outHasTime) *outHasTime = YES;
-		
-		/*get the hour*/ {
-			while (*sample && (*sample < '0' || *sample > '9')) ++sample;
-			if (!*sample) {
-				success = NO;
-				goto fail;
-			}
-			component = strtoul(sample, (char **)&sample, 10);
-			if (outhour) *outhour = component;
-		}
-
-		/*get the minute*/ {
-			while (*sample && (*sample < '0' || *sample > '9')) ++sample;
-			if (!*sample) {
-				success = NO;
-				goto fail;
-			}
-			component = strtoul(sample, (char **)&sample, 10);
-			if (outminute) *outminute = component;
-		}
-
-		/*get the second*/ {
-			while (*sample && (*sample < '0' || *sample > '9')) ++sample;
-			if (!*sample) {
-				success = NO;
-				goto fail;
-			}
-			component = strtoul(sample, (char **)&sample, 10);
-			if (outsecond) *outsecond = component;
-		}
-
-		/*get the time zone*/ {
-			while (*sample && ((*sample < '0' || *sample > '9') && *sample != '-' && *sample != '+')) ++sample;
-			if (!*sample) {
-				success = NO;
-				goto fail;
-			}
-			long timezone_sign = 1;
-			if(*sample == '+') {
-				++sample;
-			} else if(*sample == '-') {
-				timezone_sign = -1;
-				++sample;
-			} else if (*sample) {
-				//There's something here, but it's not a time zone. Bail.
-				success = NO;
-				goto fail;
-			}
-			long timezone_hr = 0;
-			if (*sample >= '0' || *sample <= '9') {
-				timezone_hr += *(sample++) - '0';
-			}
-			if (*sample >= '0' || *sample <= '9') {
-				timezone_hr *= 10;
-				timezone_hr += *(sample++) - '0';
-			}
-			long timezone_min = 0;
-			if (*sample >= '0' || *sample <= '9') {
-				timezone_min += *(sample++) - '0';
-			}
-			if (*sample >= '0' || *sample <= '9') {
-				timezone_min *= 10;
-				timezone_min += *(sample++) - '0';
-			}
-			if (outtimezone) *outtimezone = (timezone_hr * 60 + timezone_min) * timezone_sign;
-		}
-	}
-	
-fail:
-	return success;
-}
-
 //Given an Adium log file name, return an NSCalendarDate with year, month, and day specified
 static NSCalendarDate *dateFromFileName(NSString *fileName)
 {
diff -r f5afcca2ed53 -r e20de4ece246 Source/scandate.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/scandate.h	Sat Dec 18 22:21:40 2010 -0800
@@ -0,0 +1,28 @@
+/* 
+ * 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.
+ */
+
+/*Input: A string in UTF-8 encoding containing an ISO 8601 date within a parenthesis.
+ *Output:
+ *- Year, month, and date
+ *- Whether time was found
+ *- The hour, minute, and second of that time
+ *- The time zone offset as a single number of minutes
+ *- (Return value) Whether a date was found.
+ */
+BOOL scandate(const char *sample,
+              unsigned long *outyear, unsigned long *outmonth,  unsigned long *outdate,
+              BOOL *outHasTime, unsigned long *outhour, unsigned long *outminute, unsigned long *outsecond,
+              long *outtimezone);
diff -r f5afcca2ed53 -r e20de4ece246 Source/scandate.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/scandate.m	Sat Dec 18 22:21:40 2010 -0800
@@ -0,0 +1,149 @@
+/* 
+ * 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 "scandate.h"
+
+BOOL scandate(const char *sample,
+					 unsigned long *outyear, unsigned long *outmonth,  unsigned long *outdate,
+					 BOOL *outHasTime, unsigned long *outhour, unsigned long *outminute, unsigned long *outsecond,
+					 long *outtimezone)
+{
+	BOOL success = YES;
+	unsigned long component;
+
+	const char *lastOpenParenthesis = NULL;
+
+    //Read a '(', followed by a date.
+	//First, find the '('.
+	while (*sample != '\0') {
+		if (*sample == '(')
+			lastOpenParenthesis = sample;
+		++sample;
+    }
+
+	if (!lastOpenParenthesis) {
+		success = NO;
+		goto fail;
+	}
+	sample = lastOpenParenthesis;
+
+	//current character is a '(' now, so skip over it.
+    ++sample; //start with the next character
+	
+    /*get the year*/ {
+		while (*sample && (*sample < '0' || *sample > '9')) ++sample;
+		if (!*sample) {
+			success = NO;
+			goto fail;
+		}
+		component = strtoul(sample, (char **)&sample, 10);
+		if (outyear) *outyear = component;
+    }
+    
+    /*get the month*/ {
+		while (*sample && (*sample < '0' || *sample > '9')) ++sample;
+		if (!*sample) {
+			success = NO;
+			goto fail;
+		}
+		component = strtoul(sample, (char **)&sample, 10);
+		if (outmonth) *outmonth = component;
+    }
+    
+    /*get the date*/ {
+		while (*sample && (*sample < '0' || *sample > '9')) ++sample;
+		if (!*sample) {
+			success = NO;
+			goto fail;
+		}
+		component = strtoul(sample, (char **)&sample, 10);
+		if (outdate) *outdate = component;
+    }
+
+    if (*sample == 'T') {
+		++sample; //start with the next character
+		if (outHasTime) *outHasTime = YES;
+		
+		/*get the hour*/ {
+			while (*sample && (*sample < '0' || *sample > '9')) ++sample;
+			if (!*sample) {
+				success = NO;
+				goto fail;
+			}
+			component = strtoul(sample, (char **)&sample, 10);
+			if (outhour) *outhour = component;
+		}
+
+		/*get the minute*/ {
+			while (*sample && (*sample < '0' || *sample > '9')) ++sample;
+			if (!*sample) {
+				success = NO;
+				goto fail;
+			}
+			component = strtoul(sample, (char **)&sample, 10);
+			if (outminute) *outminute = component;
+		}
+
+		/*get the second*/ {
+			while (*sample && (*sample < '0' || *sample > '9')) ++sample;
+			if (!*sample) {
+				success = NO;
+				goto fail;
+			}
+			component = strtoul(sample, (char **)&sample, 10);
+			if (outsecond) *outsecond = component;
+		}
+
+		/*get the time zone*/ {
+			while (*sample && ((*sample < '0' || *sample > '9') && *sample != '-' && *sample != '+')) ++sample;
+			if (!*sample) {
+				success = NO;
+				goto fail;
+			}
+			long timezone_sign = 1;
+			if(*sample == '+') {
+				++sample;
+			} else if(*sample == '-') {
+				timezone_sign = -1;
+				++sample;
+			} else if (*sample) {
+				//There's something here, but it's not a time zone. Bail.
+				success = NO;
+				goto fail;
+			}
+			long timezone_hr = 0;
+			if (*sample >= '0' || *sample <= '9') {
+				timezone_hr += *(sample++) - '0';
+			}
+			if (*sample >= '0' || *sample <= '9') {
+				timezone_hr *= 10;
+				timezone_hr += *(sample++) - '0';
+			}
+			long timezone_min = 0;
+			if (*sample >= '0' || *sample <= '9') {
+				timezone_min += *(sample++) - '0';
+			}
+			if (*sample >= '0' || *sample <= '9') {
+				timezone_min *= 10;
+				timezone_min += *(sample++) - '0';
+			}
+			if (outtimezone) *outtimezone = (timezone_hr * 60 + timezone_min) * timezone_sign;
+		}
+	}
+	
+fail:
+	return success;
+}
diff -r f5afcca2ed53 -r e20de4ece246 UnitTests/TestScandate.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/TestScandate.h	Sat Dec 18 22:21:40 2010 -0800
@@ -0,0 +1,17 @@
+//
+//  TestScandate.h
+//  Adium
+//
+//  Created by Peter Hosey on 2010-12-18.
+//  Copyright 2010 Peter Hosey. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import <SenTestingKit/SenTestingKit.h>
+
+ at interface TestScandate : SenTestCase
+{}
+
+- (void) testEricRichiesTwitterTimelineLogFilename;
+
+ at end
diff -r f5afcca2ed53 -r e20de4ece246 UnitTests/TestScandate.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/TestScandate.m	Sat Dec 18 22:21:40 2010 -0800
@@ -0,0 +1,40 @@
+//
+//  TestScandate.m
+//  Adium
+//
+//  Created by Peter Hosey on 2010-12-18.
+//  Copyright 2010 Peter Hosey. All rights reserved.
+//
+
+#import "TestScandate.h"
+
+#import "scandate.h"
+
+ at implementation TestScandate
+
+- (void) testEricRichiesTwitterTimelineLogFilename {
+	static const char EricRichiesTwitterTimelineLogFilename[] = "timeline (edr1084) (2010-12-18T17.42.58-0500).chatlog";
+	unsigned long correctYear = 2010, correctMonth = 12, correctDayOfMonth = 18;
+	BOOL correctDidFindTime = YES;
+	unsigned long correctHour = 17, correctMinute = 42, correctSecond = 58;
+	long correctTimeZoneOffsetInMinutes = -(5 * 60);
+	BOOL correctDidFindDate = YES;
+
+	unsigned long foundYear, foundMonth, foundDayOfMonth;
+	BOOL didFindTime;
+	unsigned long foundHour, foundMinute, foundSecond;
+	long foundTimeZoneOffsetInMinutes;
+
+	BOOL didFindDate = scandate(EricRichiesTwitterTimelineLogFilename, &foundYear, &foundMonth, &foundDayOfMonth, &didFindTime, &foundHour, &foundMinute, &foundSecond, &foundTimeZoneOffsetInMinutes);
+	STAssertEquals(didFindDate, correctDidFindDate, @"No date found in this string! '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundYear, correctYear, @"Wrong year found in '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundMonth, correctMonth, @"Wrong month found in '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundDayOfMonth, correctDayOfMonth, @"Wrong day-of-month found in '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(didFindTime, correctDidFindTime, @"No time found in this string! '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundHour, correctHour, @"Wrong hour found in '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundMinute, correctMinute, @"Wrong minute found in '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundSecond, correctSecond, @"Wrong second found in '%s'", EricRichiesTwitterTimelineLogFilename);
+	STAssertEquals(foundTimeZoneOffsetInMinutes, correctTimeZoneOffsetInMinutes, @"Wrong time zone offset found in '%s'", EricRichiesTwitterTimelineLogFilename);
+}
+
+ at end




More information about the commits mailing list