Add RSDateParserTests to RSParser.

This commit is contained in:
Brent Simmons 2017-06-25 17:46:48 -07:00
parent 67279b6796
commit a53a0c4697
2 changed files with 104 additions and 2 deletions

View File

@ -68,6 +68,7 @@
849A03DA1F0081EA00122600 /* Subs.opml in Resources */ = {isa = PBXBuildFile; fileRef = 849A03CF1F0081EA00122600 /* Subs.opml */; };
849A03DE1F00837A00122600 /* FeedParserTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A03DD1F00837A00122600 /* FeedParserTypeTests.swift */; };
849A03E01F0088F600122600 /* OPMLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A03DF1F0088F600122600 /* OPMLTests.swift */; };
849A03E21F00902C00122600 /* RSDateParserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 849A03E11F00902C00122600 /* RSDateParserTests.m */; };
84D81BDC1EFA28E700652332 /* RSParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D81BDA1EFA28E700652332 /* RSParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
84D81BDE1EFA2B7D00652332 /* ParsedFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D81BDD1EFA2B7D00652332 /* ParsedFeed.swift */; };
84D81BE01EFA2BAE00652332 /* FeedType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D81BDF1EFA2BAE00652332 /* FeedType.swift */; };
@ -151,6 +152,7 @@
849A03CF1F0081EA00122600 /* Subs.opml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Subs.opml; sourceTree = "<group>"; };
849A03DD1F00837A00122600 /* FeedParserTypeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedParserTypeTests.swift; sourceTree = "<group>"; };
849A03DF1F0088F600122600 /* OPMLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OPMLTests.swift; sourceTree = "<group>"; };
849A03E11F00902C00122600 /* RSDateParserTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RSDateParserTests.m; sourceTree = "<group>"; };
84D81BD91EFA28E700652332 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
84D81BDA1EFA28E700652332 /* RSParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RSParser.h; sourceTree = "<group>"; };
84D81BDD1EFA2B7D00652332 /* ParsedFeed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ParsedFeed.swift; path = Feeds/ParsedFeed.swift; sourceTree = "<group>"; };
@ -354,6 +356,7 @@
children = (
849A03DD1F00837A00122600 /* FeedParserTypeTests.swift */,
849A03DF1F0088F600122600 /* OPMLTests.swift */,
849A03E11F00902C00122600 /* RSDateParserTests.m */,
849A03C41F0081EA00122600 /* Resources */,
84FF5F941EFA285800C15A01 /* Info.plist */,
);
@ -542,6 +545,7 @@
buildActionMask = 2147483647;
files = (
849A03E01F0088F600122600 /* OPMLTests.swift in Sources */,
849A03E21F00902C00122600 /* RSDateParserTests.m in Sources */,
849A03DE1F00837A00122600 /* FeedParserTypeTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -620,7 +624,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
@ -701,7 +704,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
@ -782,6 +784,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ranchero.RSParserTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@ -796,6 +799,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ranchero.RSParserTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};

View File

@ -0,0 +1,98 @@
//
// RSDateParserTests.m
// RSXML
//
// Created by Brent Simmons on 12/26/16.
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//
#import <XCTest/XCTest.h>
@import RSParser;
@interface RSDateParserTests : XCTestCase
@end
@implementation RSDateParserTests
static NSDate *dateWithValues(NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second) {
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.calendar = NSCalendar.currentCalendar;
dateComponents.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
[dateComponents setValue:year forComponent:NSCalendarUnitYear];
[dateComponents setValue:month forComponent:NSCalendarUnitMonth];
[dateComponents setValue:day forComponent:NSCalendarUnitDay];
[dateComponents setValue:hour forComponent:NSCalendarUnitHour];
[dateComponents setValue:minute forComponent:NSCalendarUnitMinute];
[dateComponents setValue:second forComponent:NSCalendarUnitSecond];
return dateComponents.date;
}
- (void)testDateWithString {
NSDate *expectedDateResult = dateWithValues(2010, 5, 28, 21, 3, 38);
XCTAssertNotNil(expectedDateResult);
NSDate *d = RSDateWithString(@"Fri, 28 May 2010 21:03:38 +0000");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"Fri, 28 May 2010 21:03:38 +00:00");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"Fri, 28 May 2010 21:03:38 -00:00");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"Fri, 28 May 2010 21:03:38 -0000");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"Fri, 28 May 2010 21:03:38 GMT");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"2010-05-28T21:03:38+00:00");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"2010-05-28T21:03:38+0000");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"2010-05-28T21:03:38-0000");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"2010-05-28T21:03:38-00:00");
XCTAssertEqualObjects(d, expectedDateResult);
d = RSDateWithString(@"2010-05-28T21:03:38Z");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 7, 13, 17, 6, 40);
d = RSDateWithString(@"2010-07-13T17:06:40+00:00");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 4, 30, 12, 0, 0);
d = RSDateWithString(@"30 Apr 2010 5:00 PDT");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 5, 21, 21, 22, 53);
d = RSDateWithString(@"21 May 2010 21:22:53 GMT");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 6, 9, 5, 0, 0);
d = RSDateWithString(@"Wed, 09 Jun 2010 00:00 EST");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 6, 23, 3, 43, 50);
d = RSDateWithString(@"Wed, 23 Jun 2010 03:43:50 Z");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 6, 22, 3, 57, 49);
d = RSDateWithString(@"2010-06-22T03:57:49+00:00");
XCTAssertEqualObjects(d, expectedDateResult);
expectedDateResult = dateWithValues(2010, 11, 17, 13, 40, 07);
d = RSDateWithString(@"2010-11-17T08:40:07-05:00");
XCTAssertEqualObjects(d, expectedDateResult);
}
@end