mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-16 11:30:54 +01:00
81 lines
2.1 KiB
Objective-C
Executable File
81 lines
2.1 KiB
Objective-C
Executable File
//
|
||
// RSEntityTests.m
|
||
// RSXML
|
||
//
|
||
// Created by Brent Simmons on 12/26/16.
|
||
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
||
//
|
||
|
||
#import <XCTest/XCTest.h>
|
||
@import RSXML;
|
||
|
||
@interface RSEntityTests : XCTestCase
|
||
|
||
@end
|
||
|
||
@implementation RSEntityTests
|
||
|
||
|
||
- (void)testInnerAmpersand {
|
||
|
||
NSString *expectedResult = @"A&P";
|
||
|
||
NSString *result = [@"A&P" rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, expectedResult);
|
||
|
||
result = [@"A&P" rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, expectedResult);
|
||
|
||
result = [@"A&P" rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, expectedResult);
|
||
|
||
}
|
||
|
||
- (void)testSingleEntity {
|
||
|
||
NSString *result = [@"∞" rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, @"∞");
|
||
|
||
result = [@"&" rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, @"&");
|
||
|
||
result = [@"’" rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, @"’");
|
||
}
|
||
|
||
- (void)testNotEntities {
|
||
|
||
NSString *s = @"&&\t\nFoo & Bar &0; Baz & 1238 4948 More things &foobar;&";
|
||
NSString *result = [s rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, s);
|
||
}
|
||
|
||
- (void)testURLs {
|
||
|
||
NSString *urlString = @"http://www.nytimes.com/2015/09/05/us/at-west-point-annual-pillow-fight-becomes-weaponized.html?mwrsm=Email&_r=1&pagewanted=all";
|
||
NSString *expectedResult = @"http://www.nytimes.com/2015/09/05/us/at-west-point-annual-pillow-fight-becomes-weaponized.html?mwrsm=Email&_r=1&pagewanted=all";
|
||
|
||
NSString *result = [urlString rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, expectedResult);
|
||
}
|
||
|
||
- (void)testEntityPlusWhitespace {
|
||
|
||
NSString *s = @"∞ Permalink";
|
||
NSString *expectedResult = @"∞ Permalink";
|
||
|
||
NSString *result = [s rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, expectedResult);
|
||
}
|
||
|
||
- (void)testNonBreakingSpace {
|
||
|
||
NSString *s = @"   -- just some spaces";
|
||
NSString *expectedResult = [NSString stringWithFormat:@"%C%C -- just some spaces", 160, 160];
|
||
|
||
NSString *result = [s rs_stringByDecodingHTMLEntities];
|
||
XCTAssertEqualObjects(result, expectedResult);
|
||
}
|
||
|
||
@end
|