mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Consolidate tests to a single ParserTests target.
This commit is contained in:
78
Modules/Parser/Tests/ParserTests/EntityDecodingTests.swift
Normal file
78
Modules/Parser/Tests/ParserTests/EntityDecodingTests.swift
Normal file
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// EntityDecodingTests.swift
|
||||
// RSParserTests
|
||||
//
|
||||
// Created by Brent Simmons on 12/30/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import SAX
|
||||
|
||||
class EntityDecodingTests: XCTestCase {
|
||||
|
||||
func test39Decoding() {
|
||||
|
||||
// Bug found by Manton Reece — the ' entity was not getting decoded by NetNewsWire in JSON Feeds from micro.blog.
|
||||
|
||||
let s = "These are the times that try men's souls."
|
||||
let decoded = HTMLEntityDecoder.decodedString(s)
|
||||
|
||||
XCTAssertEqual(decoded, "These are the times that try men's souls.")
|
||||
}
|
||||
|
||||
func testEntityAtBeginning() {
|
||||
|
||||
let s = "'leading single quote"
|
||||
let decoded = HTMLEntityDecoder.decodedString(s)
|
||||
|
||||
XCTAssertEqual(decoded, "'leading single quote")
|
||||
}
|
||||
|
||||
func testEntityAtEnd() {
|
||||
|
||||
let s = "trailing single quote'"
|
||||
let decoded = HTMLEntityDecoder.decodedString(s)
|
||||
|
||||
XCTAssertEqual(decoded, "trailing single quote'")
|
||||
}
|
||||
|
||||
func testEntityInMiddle() {
|
||||
|
||||
let s = "entity ç in middle"
|
||||
let decoded = HTMLEntityDecoder.decodedString(s)
|
||||
|
||||
XCTAssertEqual(decoded, "entity ç in middle")
|
||||
}
|
||||
|
||||
func testMultipleEntitiesInARow() {
|
||||
|
||||
let s = "çèmult……iple 'æ"entities÷♥"
|
||||
let decoded = HTMLEntityDecoder.decodedString(s)
|
||||
|
||||
XCTAssertEqual(decoded, "çèmult……iple 'æ\"entities÷♥")
|
||||
}
|
||||
|
||||
func testOnlyEntity() {
|
||||
var s = "…"
|
||||
var decoded = HTMLEntityDecoder.decodedString(s)
|
||||
|
||||
XCTAssertEqual(decoded, "…")
|
||||
|
||||
s = "…"
|
||||
decoded = HTMLEntityDecoder.decodedString(s)
|
||||
XCTAssertEqual(decoded, "…")
|
||||
|
||||
s = "'"
|
||||
decoded = HTMLEntityDecoder.decodedString(s)
|
||||
XCTAssertEqual(decoded, "'")
|
||||
|
||||
s = "§"
|
||||
decoded = HTMLEntityDecoder.decodedString(s)
|
||||
XCTAssertEqual(decoded, "§")
|
||||
|
||||
s = "£"
|
||||
decoded = HTMLEntityDecoder.decodedString(s)
|
||||
XCTAssertEqual(decoded, "£")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user