Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: twitter/twitter-text-objc
base: e4e17bf9a0
...
head fork: twitter/twitter-text-objc
compare: 2026773e94
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Nov 07, 2012
@psychs psychs Upgraded to the latest conformance suite aa9b578
@psychs psychs Change default short URL length.
Fix warnings.

Tests will fail until conformance tests would be updated.
2026773
View
8 lib/TwitterText.h
@@ -23,10 +23,10 @@
+ (NSArray*)mentionsOrListsInText:(NSString*)text;
+ (TwitterTextEntity*)repliedScreenNameInText:(NSString*)text;
-+ (int)tweetLength:(NSString*)text;
-+ (int)tweetLength:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLength:(int)httpsURLLength;
++ (NSInteger)tweetLength:(NSString*)text;
++ (NSInteger)tweetLength:(NSString*)text httpURLLength:(NSInteger)httpURLLength httpsURLLength:(NSInteger)httpsURLLength;
-+ (int)remainingCharacterCount:(NSString*)text;
-+ (int)remainingCharacterCount:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLength:(int)httpsURLLength;
++ (NSInteger)remainingCharacterCount:(NSString*)text;
++ (NSInteger)remainingCharacterCount:(NSString*)text httpURLLength:(NSInteger)httpURLLength httpsURLLength:(NSInteger)httpsURLLength;
@end
View
20 lib/TwitterText.m
@@ -282,9 +282,9 @@
@")" \
@")"
-static const int MaxTweetLength = 140;
-static const int HTTPShortURLLength = 20;
-static const int HTTPSShortURLLength = 21;
+static const NSInteger MaxTweetLength = 140;
+static const NSInteger HTTPShortURLLength = 21;
+static const NSInteger HTTPSShortURLLength = 22;
static NSRegularExpression *validURLRegexp;
static NSCharacterSet *invalidURLWithoutProtocolPrecedingCharSet;
@@ -673,12 +673,12 @@ + (TwitterTextEntity*)repliedScreenNameInText:(NSString*)text
return [TwitterTextEntity entityWithType:TwitterTextEntityScreenName range:replyRange];
}
-+ (int)tweetLength:(NSString*)text
++ (NSInteger)tweetLength:(NSString*)text
{
return [self tweetLength:text httpURLLength:HTTPShortURLLength httpsURLLength:HTTPSShortURLLength];
}
-+ (int)tweetLength:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLength:(int)httpsURLLength
++ (NSInteger)tweetLength:(NSString*)text httpURLLength:(NSInteger)httpURLLength httpsURLLength:(NSInteger)httpsURLLength
{
text = [text precomposedStringWithCanonicalMapping];
@@ -694,7 +694,7 @@ + (int)tweetLength:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLeng
int urlLengthOffset = 0;
NSArray *urlEntities = [self URLsInText:text];
- for (int i=urlEntities.count-1; i>=0; i--) {
+ for (NSInteger i=urlEntities.count-1; i>=0; i--) {
TwitterTextEntity *entity = [urlEntities objectAtIndex:i];
NSRange urlRange = entity.range;
NSString *url = [string substringWithRange:urlRange];
@@ -706,8 +706,8 @@ + (int)tweetLength:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLeng
[string deleteCharactersInRange:urlRange];
}
- int len = string.length;
- int charCount = len + urlLengthOffset;
+ NSInteger len = string.length;
+ NSInteger charCount = len + urlLengthOffset;
if (len > 0) {
// Adjust count for non-BMP characters
@@ -731,12 +731,12 @@ + (int)tweetLength:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLeng
return charCount;
}
-+ (int)remainingCharacterCount:(NSString*)text
++ (NSInteger)remainingCharacterCount:(NSString*)text
{
return [self remainingCharacterCount:text httpURLLength:HTTPShortURLLength httpsURLLength:HTTPSShortURLLength];
}
-+ (int)remainingCharacterCount:(NSString*)text httpURLLength:(int)httpURLLength httpsURLLength:(int)httpsURLLength
++ (NSInteger)remainingCharacterCount:(NSString*)text httpURLLength:(NSInteger)httpURLLength httpsURLLength:(NSInteger)httpsURLLength
{
return MaxTweetLength - [self tweetLength:text httpURLLength:httpURLLength httpsURLLength:httpsURLLength];
}
2  test/twitter-text-conformance
@@ -1 +1 @@
-Subproject commit a405a8dd934e7e499a4b6542cde13ab78e5c18a6
+Subproject commit 3d48ff0522a37b676ed0f9768be2ff861510da53
View
40 testproject/TwitterTextTests.m
@@ -64,8 +64,8 @@ - (void)testExtract
NSArray *results = [TwitterText mentionsOrListsInText:text];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSString *expectedText = [expected objectAtIndex:i];
TwitterTextEntity *entity = [results objectAtIndex:i];
@@ -91,8 +91,8 @@ - (void)testExtract
NSArray *results = [TwitterText mentionsOrListsInText:text];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSDictionary *expectedDic = [expected objectAtIndex:i];
NSString *expectedText = [expectedDic objectForKey:@"screen_name"];
NSArray *indices = [expectedDic objectForKey:@"indices"];
@@ -125,8 +125,8 @@ - (void)testExtract
NSArray *results = [TwitterText mentionsOrListsInText:text];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSDictionary *expectedDic = [expected objectAtIndex:i];
NSString *expectedText = [expectedDic objectForKey:@"screen_name"];
NSString *expectedListSlug = [expectedDic objectForKey:@"list_slug"];
@@ -186,8 +186,8 @@ - (void)testExtract
NSArray *results = [TwitterText URLsInText:text];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSString *expectedText = [expected objectAtIndex:i];
TwitterTextEntity *entity = [results objectAtIndex:i];
@@ -211,8 +211,8 @@ - (void)testExtract
NSArray *results = [TwitterText URLsInText:text];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSDictionary *expectedDic = [expected objectAtIndex:i];
NSString *expectedUrl = [expectedDic objectForKey:@"url"];
NSArray *expectedIndices = [expectedDic objectForKey:@"indices"];
@@ -242,8 +242,8 @@ - (void)testExtract
NSArray *results = [TwitterText hashtagsInText:text checkingURLOverlap:YES];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSString *expectedText = [expected objectAtIndex:i];
TwitterTextEntity *entity = [results objectAtIndex:i];
@@ -269,8 +269,8 @@ - (void)testExtract
NSArray *results = [TwitterText hashtagsInText:text checkingURLOverlap:YES];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSDictionary *expectedDic = [expected objectAtIndex:i];
NSString *expectedHashtag = [expectedDic objectForKey:@"hashtag"];
NSArray *expectedIndices = [expectedDic objectForKey:@"indices"];
@@ -303,8 +303,8 @@ - (void)testExtract
NSArray *results = [TwitterText cashtagsInText:text checkingURLOverlap:YES];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSString *expectedText = [expected objectAtIndex:i];
TwitterTextEntity *entity = [results objectAtIndex:i];
@@ -330,8 +330,8 @@ - (void)testExtract
NSArray *results = [TwitterText cashtagsInText:text checkingURLOverlap:YES];
if (results.count == expected.count) {
- int count = results.count;
- for (int i=0; i<count; i++) {
+ NSInteger count = results.count;
+ for (NSInteger i=0; i<count; i++) {
NSDictionary *expectedDic = [expected objectAtIndex:i];
NSString *expectedCashtag = [expectedDic objectForKey:@"cashtag"];
NSArray *expectedIndices = [expectedDic objectForKey:@"indices"];
@@ -376,8 +376,8 @@ - (void)testValidate
for (NSDictionary *testCase in lengths) {
NSString *text = [testCase objectForKey:@"text"];
- int expected = [[testCase objectForKey:@"expected"] intValue];
- int len = [TwitterText tweetLength:text];
+ NSInteger expected = [[testCase objectForKey:@"expected"] intValue];
+ NSInteger len = [TwitterText tweetLength:text];
STAssertTrue(len == expected, @"Length should be %d (%d)", expected, len);
}
}

No commit comments for this range

Something went wrong with that request. Please try again.