Skip to content

Instantly share code, notes, and snippets.

@justin
Last active August 29, 2015 13:56
Show Gist options
  • Save justin/8886407 to your computer and use it in GitHub Desktop.
Save justin/8886407 to your computer and use it in GitHub Desktop.
Sample tests for validating my NSRegularExpression adventures.
#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