Last active
August 29, 2015 13:56
-
-
Save justin/8886407 to your computer and use it in GitHub Desktop.
Sample tests for validating my NSRegularExpression adventures.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <XCTest/XCTest.h> | |
#import "RSFoundationExtras.h" | |
@interface RSFoundationExtrasTests : XCTestCase | |
@end | |
@implementation RSFoundationExtrasTests | |
- (void)testExtractingLinksFromAPost | |
{ | |
NSString *samplePost = @"This is a post with http://carpeaqua.com/ https://log.carpeaqua.com http://daringfireball.net"; | |
XCTAssertEqual([[samplePost rs_links] count], (unsigned long)3); | |
} | |
- (void)testExtractingLinksFromAPostWithEmbeddedRegEx | |
{ | |
NSString *regExPost = @"Hi there.\n\n^((\\S.*)(\\:)$)((?s).*?)(?!(^.+\\:))\n\nHere's my a test post"; | |
XCTAssertEqual([[regExPost rs_links] count], (unsigned long)0); | |
NSString *secondRegex = @"(.+\n)*(?=\\s*$) http://carpeaqua.com"; | |
XCTAssertEqual([[secondRegex rs_links] count], (unsigned long)1); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment