This commit is contained in:
Nabil Chatbi 2016-12-28 02:02:39 +01:00
parent 1d7e552d4a
commit 85e28d807b
19 changed files with 430 additions and 342 deletions

View File

@ -12,4 +12,22 @@ import XCTest
XCTMain([ XCTMain([
testCase(CssTest.allTests), testCase(CssTest.allTests),
testCase(ElementsTest.allTests)]) testCase(ElementsTest.allTests),
testCase(QueryParserTest.allTests),
testCase(SelectorTest.allTests),
testCase(AttributeParseTest.allTests),
testCase(CharacterReaderTest.allTests),
testCase(HtmlParserTest.allTests),
testCase(ParseSettingsTest.allTests),
testCase(TagTest.allTests),
testCase(TokenQueueTest.allTests),
testCase(XmlTreeBuilderTest.allTests),
testCase(FormElementTest.allTests),
testCase(EntitiesTest.allTests),
testCase(DocumentTypeTest.allTests),
testCase(TextNodeTest.allTests),
testCase(DocumentTest.allTests),
testCase(AttributesTest.allTests),
testCase(NodeTest.allTests),
testCase(AttributeTest.allTests)
])

View File

@ -14,16 +14,6 @@ import SwiftSoup
class AttributeParseTest: XCTestCase { class AttributeParseTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testparsesRoughAttributeString()throws { func testparsesRoughAttributeString()throws {
let html: String = "<a id=\"123\" class=\"baz = 'bar'\" style = 'border: 2px'qux zim foo = 12 mux=18 />" let html: String = "<a id=\"123\" class=\"baz = 'bar'\" style = 'border: 2px'qux zim foo = 12 mux=18 />"
// should be: <id=123>, <class=baz = 'bar'>, <qux=>, <zim=>, <foo=12>, <mux.=18> // should be: <id=123>, <class=baz = 'bar'>, <qux=>, <zim=>, <foo=12>, <mux.=18>
@ -106,11 +96,17 @@ class AttributeParseTest: XCTestCase {
XCTAssertEqual("<img onerror=\"doMyJob\" />", try doc.html()) XCTAssertEqual("<img onerror=\"doMyJob\" />", try doc.html())
} }
func testPerformanceExample() { static var allTests = {
// This is an example of a performance test case. return [
self.measure { ("testparsesRoughAttributeString" , testparsesRoughAttributeString),
// Put the code you want to measure the time of here. ("testhandlesNewLinesAndReturns" , testhandlesNewLinesAndReturns),
} ("testparsesEmptyString" , testparsesEmptyString),
} ("testcanStartWithEq" , testcanStartWithEq),
("teststrictAttributeUnescapes" , teststrictAttributeUnescapes),
("testmoreAttributeUnescapes" , testmoreAttributeUnescapes),
("testparsesBooleanAttributes" , testparsesBooleanAttributes),
("testdropsSlashFromAttributeName" , testdropsSlashFromAttributeName),
]
}()
} }

View File

@ -10,16 +10,6 @@ import XCTest
@testable import SwiftSoup @testable import SwiftSoup
class AttributeTest: XCTestCase { class AttributeTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testHtml() func testHtml()
{ {
let attr = try! Attribute(key: "key", value: "value &") let attr = try! Attribute(key: "key", value: "value &")
@ -34,12 +24,11 @@ class AttributeTest: XCTestCase {
XCTAssertEqual(attr.html(), attr.toString()) XCTAssertEqual(attr.html(), attr.toString())
} }
static var allTests = {
func testPerformanceExample() { return [
// This is an example of a performance test case. ("testHtml" , testHtml),
self.measure { ("testWithSupplementaryCharacterInAttributeKeyAndValue" , testWithSupplementaryCharacterInAttributeKeyAndValue)
// Put the code you want to measure the time of here. ]
} }()
}
} }

View File

@ -11,16 +11,6 @@ import SwiftSoup
class AttributesTest: XCTestCase { class AttributesTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testHtml() { func testHtml() {
let a: Attributes = Attributes() let a: Attributes = Attributes()
do{ do{
@ -90,11 +80,11 @@ class AttributesTest: XCTestCase {
XCTAssertNil(iterator.next()) XCTAssertNil(iterator.next())
} }
func testPerformanceExample() { static var allTests = {
// This is an example of a performance test case. return [
self.measure { ("testHtml" , testHtml),
// Put the code you want to measure the time of here. ("testIterator" , testIterator),
} ("testIteratorEmpty" , testIteratorEmpty)
} ]
}()
} }

View File

@ -11,23 +11,6 @@ import SwiftSoup
class CharacterReaderTest: XCTestCase { class CharacterReaderTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
func testConsume() { func testConsume() {
let r = CharacterReader("one") let r = CharacterReader("one")
XCTAssertEqual(0, r.getPos()) XCTAssertEqual(0, r.getPos())
@ -259,5 +242,29 @@ class CharacterReaderTest: XCTestCase {
XCTAssertTrue(r.rangeEquals(18, 5, "CHOKE")) XCTAssertTrue(r.rangeEquals(18, 5, "CHOKE"))
XCTAssertFalse(r.rangeEquals(18, 5, "CHIKE")) XCTAssertFalse(r.rangeEquals(18, 5, "CHIKE"))
} }
static var allTests = {
return [
("testConsume" , testConsume),
("testUnconsume" , testUnconsume),
("testMark" , testMark),
("testConsumeToEnd" , testConsumeToEnd),
("testNextIndexOfChar" , testNextIndexOfChar),
("testNextIndexOfString" , testNextIndexOfString),
("testNextIndexOfUnmatched" , testNextIndexOfUnmatched),
("testConsumeToChar" , testConsumeToChar),
("testConsumeToString" , testConsumeToString),
("testAdvance" , testAdvance),
("testConsumeToAny" , testConsumeToAny),
("testConsumeLetterSequence" , testConsumeLetterSequence),
("testConsumeLetterThenDigitSequence" , testConsumeLetterThenDigitSequence),
("testMatches" , testMatches),
("testMatchesIgnoreCase" , testMatchesIgnoreCase),
("testContainsIgnoreCase" , testContainsIgnoreCase),
("testMatchesAny" , testMatchesAny),
("testCachesStrings" , testCachesStrings),
("testRangeEquals" , testRangeEquals)
]
}()
} }

View File

@ -13,24 +13,7 @@ class DocumentTest: XCTestCase {
private static let charsetUtf8 = String.Encoding.utf8 private static let charsetUtf8 = String.Encoding.utf8
private static let charsetIso8859 = String.Encoding.iso2022JP //"ISO-8859-1" private static let charsetIso8859 = String.Encoding.iso2022JP //"ISO-8859-1"
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
func testSetTextPreservesDocumentStructure() { func testSetTextPreservesDocumentStructure() {
do{ do{
let doc: Document = try SwiftSoup.parse("<p>Hello</p>") let doc: Document = try SwiftSoup.parse("<p>Hello</p>")
@ -438,4 +421,35 @@ class DocumentTest: XCTestCase {
// output.contains("&#xa0;") || output.contains("&nbsp;")); // output.contains("&#xa0;") || output.contains("&nbsp;"));
// } // }
static var allTests = {
return [
("testSetTextPreservesDocumentStructure" , testSetTextPreservesDocumentStructure),
("testTitles" , testTitles),
("testOutputEncoding" , testOutputEncoding),
("testXhtmlReferences" , testXhtmlReferences),
("testNormalisesStructure" , testNormalisesStructure),
("testClone" , testClone),
("testClonesDeclarations" , testClonesDeclarations),
("testHtmlAndXmlSyntax" , testHtmlAndXmlSyntax),
("testHtmlParseDefaultsToHtmlOutputSyntax" , testHtmlParseDefaultsToHtmlOutputSyntax),
("testHtmlAppendable" , testHtmlAppendable),
("testDocumentsWithSameContentAreEqual" , testDocumentsWithSameContentAreEqual),
("testDocumentsWithSameContentAreVerifialbe" , testDocumentsWithSameContentAreVerifialbe),
("testMetaCharsetUpdateUtf8" , testMetaCharsetUpdateUtf8),
("testMetaCharsetUpdateIsoLatin2" , testMetaCharsetUpdateIsoLatin2),
("testMetaCharsetUpdateNoCharset" , testMetaCharsetUpdateNoCharset),
("testMetaCharsetUpdateDisabled" , testMetaCharsetUpdateDisabled),
("testMetaCharsetUpdateDisabledNoChanges" , testMetaCharsetUpdateDisabledNoChanges),
("testMetaCharsetUpdateEnabledAfterCharsetChange" , testMetaCharsetUpdateEnabledAfterCharsetChange),
("testMetaCharsetUpdateCleanup" , testMetaCharsetUpdateCleanup),
("testMetaCharsetUpdateXmlUtf8" , testMetaCharsetUpdateXmlUtf8),
("testMetaCharsetUpdateXmlIso2022JP" , testMetaCharsetUpdateXmlIso2022JP),
("testMetaCharsetUpdateXmlNoCharset" , testMetaCharsetUpdateXmlNoCharset),
("testMetaCharsetUpdateXmlDisabled" , testMetaCharsetUpdateXmlDisabled),
("testMetaCharsetUpdateXmlDisabledNoChanges" , testMetaCharsetUpdateXmlDisabledNoChanges),
("testMetaCharsetUpdatedDisabledPerDefault" , testMetaCharsetUpdatedDisabledPerDefault),
("createXmlDocument" , createXmlDocument)
]
}()
} }

View File

@ -10,16 +10,6 @@ import XCTest
import SwiftSoup import SwiftSoup
class DocumentTypeTest: XCTestCase { class DocumentTypeTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testConstructorValidationOkWithBlankName() { func testConstructorValidationOkWithBlankName() {
let fail: DocumentType? = DocumentType("","", "", "") let fail: DocumentType? = DocumentType("","", "", "")
@ -51,11 +41,12 @@ class DocumentTypeTest: XCTestCase {
XCTAssertEqual("<!DOCTYPE notHtml PUBLIC \"--public\" \"--system\">", try! combo.outerHtml()) XCTAssertEqual("<!DOCTYPE notHtml PUBLIC \"--public\" \"--system\">", try! combo.outerHtml())
} }
func testPerformanceExample() { static var allTests = {
// This is an example of a performance test case. return [
self.measure { ("testConstructorValidationOkWithBlankName" , testConstructorValidationOkWithBlankName),
// Put the code you want to measure the time of here. ("testConstructorValidationThrowsExceptionOnNulls" , testConstructorValidationThrowsExceptionOnNulls),
} ("testConstructorValidationOkWithBlankPublicAndSystemIds" , testConstructorValidationOkWithBlankPublicAndSystemIds),
} ("testOuterHtmlGeneration" , testOuterHtmlGeneration),
]
}()
} }

View File

@ -12,21 +12,6 @@ class ElementTest: XCTestCase {
private let reference = "<div id=div1><p>Hello</p><p>Another <b>element</b></p><div id=div2><img src=foo.png></div></div>" private let reference = "<div id=div1><p>Hello</p><p>Another <b>element</b></p><div id=div2><img src=foo.png></div></div>"
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testGetElementsByTagName() { func testGetElementsByTagName() {
let doc: Document = try! SwiftSoup.parse(reference) let doc: Document = try! SwiftSoup.parse(reference)
let divs = try! doc.getElementsByTag("div") let divs = try! doc.getElementsByTag("div")
@ -945,12 +930,77 @@ class ElementTest: XCTestCase {
XCTAssertEqual("html > body > fb|comments", try els.get(0).cssSelector()) XCTAssertEqual("html > body > fb|comments", try els.get(0).cssSelector())
} }
static var allTests = {
func testPerformanceExample() { return [
// This is an example of a performance test case. ("testGetElementsByTagName" , testGetElementsByTagName),
self.measure { ("testGetNamespacedElementsByTag" , testGetNamespacedElementsByTag),
// Put the code you want to measure the time of here. ("testGetElementById" , testGetElementById),
} ("testGetText" , testGetText),
} ("testGetChildText" , testGetChildText),
("testNormalisesText" , testNormalisesText),
("testKeepsPreText" , testKeepsPreText),
("testKeepsPreTextInCode" , testKeepsPreTextInCode),
("testBrHasSpace" , testBrHasSpace),
("testGetSiblings" , testGetSiblings),
("testGetSiblingsWithDuplicateContent" , testGetSiblingsWithDuplicateContent),
("testGetParents" , testGetParents),
("testElementSiblingIndex" , testElementSiblingIndex),
("testElementSiblingIndexSameContent" , testElementSiblingIndexSameContent),
("testGetElementsWithClass" , testGetElementsWithClass),
("testGetElementsWithAttribute" , testGetElementsWithAttribute),
("testGetElementsWithAttributeDash" , testGetElementsWithAttributeDash),
("testGetElementsWithAttributeValue" , testGetElementsWithAttributeValue),
("testClassDomMethods" , testClassDomMethods),
("testHasClassDomMethods" , testHasClassDomMethods),
("testClassUpdates" , testClassUpdates),
("testOuterHtml" , testOuterHtml),
("testInnerHtml" , testInnerHtml),
("testFormatHtml" , testFormatHtml),
("testFormatOutline" , testFormatOutline),
("testSetIndent" , testSetIndent),
("testNotPretty" , testNotPretty),
("testEmptyElementFormatHtml" , testEmptyElementFormatHtml),
("testNoIndentOnScriptAndStyle" , testNoIndentOnScriptAndStyle),
("testContainerOutput" , testContainerOutput),
("testSetText" , testSetText),
("testAddNewElement" , testAddNewElement),
("testAddBooleanAttribute" , testAddBooleanAttribute),
("testAppendRowToTable" , testAppendRowToTable),
("testPrependRowToTable" , testPrependRowToTable),
("testPrependElement" , testPrependElement),
("testAddNewText" , testAddNewText),
("testPrependText" , testPrependText),
("testAddNewHtml" , testAddNewHtml),
("testPrependNewHtml" , testPrependNewHtml),
("testSetHtml" , testSetHtml),
("testSetHtmlTitle" , testSetHtmlTitle),
("testWrap" , testWrap),
("testBefore" , testBefore),
("testAfter" , testAfter),
("testWrapWithRemainder" , testWrapWithRemainder),
("testHasText" , testHasText),
("testDataset" , testDataset),
("testpParentlessToString" , testpParentlessToString),
("testClone" , testClone),
("testClonesClassnames" , testClonesClassnames),
("testTagNameSet" , testTagNameSet),
("testHtmlContainsOuter" , testHtmlContainsOuter),
("testGetTextNodes" , testGetTextNodes),
("testManipulateTextNodes" , testManipulateTextNodes),
("testGetDataNodes" , testGetDataNodes),
("testElementIsNotASiblingOfItself" , testElementIsNotASiblingOfItself),
("testChildThrowsIndexOutOfBoundsOnMissing" , testChildThrowsIndexOutOfBoundsOnMissing),
("testMoveByAppend" , testMoveByAppend),
("testInsertChildrenArgumentValidation" , testInsertChildrenArgumentValidation),
("testInsertChildrenAtPosition" , testInsertChildrenAtPosition),
("testInsertChildrenAsCopy" , testInsertChildrenAsCopy),
("testCssPath" , testCssPath),
("testClassNames" , testClassNames),
("testHashAndEqualsAndValue" , testHashAndEqualsAndValue),
("testRelativeUrls" , testRelativeUrls),
("testAppendMustCorrectlyMoveChildrenInsideOneParentElement" , testAppendMustCorrectlyMoveChildrenInsideOneParentElement),
("testHashcodeIsStableWithContentChanges" , testHashcodeIsStableWithContentChanges),
("testNamespacedElements" , testNamespacedElements)
]
}()
} }

View File

@ -12,16 +12,6 @@ import SwiftSoup
class EntitiesTest: XCTestCase { class EntitiesTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testEscape()throws { func testEscape()throws {
let text = "Hello &<> Å å π 新 there ¾ © »" let text = "Hello &<> Å å π 新 there ¾ © »"
@ -150,6 +140,22 @@ class EntitiesTest: XCTestCase {
XCTAssertEqual("<a title=\"&lt;p>One&lt;/p>\">One</a>",try element.outerHtml()) XCTAssertEqual("<a title=\"&lt;p>One&lt;/p>\">One</a>",try element.outerHtml())
} }
static var allTests = {
return [
("testEscape" , testEscape),
("testXhtml" , testXhtml),
("testGetByName" , testGetByName),
("testEscapeSupplementaryCharacter" , testEscapeSupplementaryCharacter),
("testNotMissingMultis" , testNotMissingMultis),
("testnotMissingSupplementals" , testnotMissingSupplementals),
("testUnescape" , testUnescape),
("testStrictUnescape" , testStrictUnescape),
("testCaseSensitive" , testCaseSensitive),
("testQuoteReplacements" , testQuoteReplacements),
("testLetterDigitEntities" , testLetterDigitEntities),
("testNoSpuriousDecodes" , testNoSpuriousDecodes),
("testUscapesGtInXmlAttributesButNotInHtml" , testUscapesGtInXmlAttributesButNotInHtml)
]
}()
} }

View File

@ -11,17 +11,6 @@ import SwiftSoup
class FormElementTest: XCTestCase { class FormElementTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testHasAssociatedControls()throws { func testHasAssociatedControls()throws {
//"button", "fieldset", "input", "keygen", "object", "output", "select", "textarea" //"button", "fieldset", "input", "keygen", "object", "output", "select", "textarea"
let html = "<form id=1><button id=1><fieldset id=2 /><input id=3><keygen id=4><object id=5><output id=6>" + let html = "<form id=1><button id=1><fieldset id=2 /><input id=3><keygen id=4><object id=5><output id=6>" +
@ -161,13 +150,11 @@ class FormElementTest: XCTestCase {
// assertEquals("login", data.get(2).key()); // assertEquals("login", data.get(2).key());
// } // }
static var allTests = {
return [
func testPerformanceExample() { ("testHasAssociatedControls" , testHasAssociatedControls),
// This is an example of a performance test case. ("testFormsAddedAfterParseAreFormElements" , testFormsAddedAfterParseAreFormElements),
self.measure { ("testControlsAddedAfterParseAreLinkedWithForms" , testControlsAddedAfterParseAreLinkedWithForms)
// Put the code you want to measure the time of here. ]
} }()
}
} }

View File

@ -14,16 +14,6 @@ import SwiftSoup
class HtmlParserTest: XCTestCase { class HtmlParserTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testParsesSimpleDocument()throws { func testParsesSimpleDocument()throws {
let html: String = "<html><head><title>First!</title></head><body><p>First post! <img src=\"foo.png\" /></p></body></html>" let html: String = "<html><head><title>First!</title></head><body><p>First post! <img src=\"foo.png\" /></p></body></html>"
let doc: Document = try SwiftSoup.parse(html) let doc: Document = try SwiftSoup.parse(html)
@ -595,14 +585,76 @@ class HtmlParserTest: XCTestCase {
XCTAssertEqual(try doc.select("table").size(), 1) // only one table XCTAssertEqual(try doc.select("table").size(), 1) // only one table
} }
static var allTests = {
return [
("testParsesSimpleDocument" , testParsesSimpleDocument),
func testPerformanceExample() { ("testParsesRoughAttributes" , testParsesRoughAttributes),
// This is an example of a performance test case. ("testParsesQuiteRoughAttributes" , testParsesQuiteRoughAttributes),
self.measure { ("testParsesComments" , testParsesComments),
// Put the code you want to measure the time of here. ("testParsesUnterminatedComments" , testParsesUnterminatedComments),
} ("testDropsUnterminatedTag" , testDropsUnterminatedTag),
} ("testDropsUnterminatedAttribute" , testDropsUnterminatedAttribute),
("testParsesUnterminatedTextarea" , testParsesUnterminatedTextarea),
("testParsesUnterminatedOption" , testParsesUnterminatedOption),
("testSpaceAfterTag" , testSpaceAfterTag),
("testCreatesDocumentStructure" , testCreatesDocumentStructure),
("testCreatesStructureFromBodySnippet" , testCreatesStructureFromBodySnippet),
("testHandlesEscapedData" , testHandlesEscapedData),
("testHandlesDataOnlyTags" , testHandlesDataOnlyTags),
("testHandlesTextAfterData" , testHandlesTextAfterData),
("testHandlesTextArea" , testHandlesTextArea),
("testPreservesSpaceInTextArea" , testPreservesSpaceInTextArea),
("testPreservesSpaceInScript" , testPreservesSpaceInScript),
("testDoesNotCreateImplicitLists" , testDoesNotCreateImplicitLists),
("testDiscardsNakedTds" , testDiscardsNakedTds),
("testHandlesNestedImplicitTable" , testHandlesNestedImplicitTable),
("testHandlesWhatWgExpensesTableExample" , testHandlesWhatWgExpensesTableExample),
("testHandlesTbodyTable" , testHandlesTbodyTable),
("testHandlesImplicitCaptionClose" , testHandlesImplicitCaptionClose),
("testNoTableDirectInTable" , testNoTableDirectInTable),
("testIgnoresDupeEndTrTag" , testIgnoresDupeEndTrTag),
("testHandlesBaseTags" , testHandlesBaseTags),
("testHandlesProtocolRelativeUrl" , testHandlesProtocolRelativeUrl),
("testHandlesCdata" , testHandlesCdata),
("testHandlesUnclosedCdataAtEOF" , testHandlesUnclosedCdataAtEOF),
("testHandlesInvalidStartTags" , testHandlesInvalidStartTags),
("testHandlesUnknownTags" , testHandlesUnknownTags),
("testHandlesUnknownInlineTags" , testHandlesUnknownInlineTags),
("testParsesBodyFragment" , testParsesBodyFragment),
("testHandlesUnknownNamespaceTags" , testHandlesUnknownNamespaceTags),
("testHandlesKnownEmptyBlocks" , testHandlesKnownEmptyBlocks),
("testHandlesSolidusAtAttributeEnd" , testHandlesSolidusAtAttributeEnd),
("testHandlesMultiClosingBody" , testHandlesMultiClosingBody),
("testHandlesUnclosedDefinitionLists" , testHandlesUnclosedDefinitionLists),
("testHandlesBlocksInDefinitions" , testHandlesBlocksInDefinitions),
("testHandlesFrames" , testHandlesFrames),
("testIgnoresContentAfterFrameset" , testIgnoresContentAfterFrameset),
("testHandlesJavadocFont" , testHandlesJavadocFont),
("testHandlesBaseWithoutHref" , testHandlesBaseWithoutHref),
("testNormalisesDocument" , testNormalisesDocument),
("testNormalisesEmptyDocument" , testNormalisesEmptyDocument),
("testNormalisesHeadlessBody" , testNormalisesHeadlessBody),
("testNormalisedBodyAfterContent" , testNormalisedBodyAfterContent),
("testfindsCharsetInMalformedMeta" , testfindsCharsetInMalformedMeta),
("testHgroup" , testHgroup),
("testRelaxedTags" , testRelaxedTags),
("testHeaderContents" , testHeaderContents),
("testSpanContents" , testSpanContents),
("testNoImagesInNoScriptInHead" , testNoImagesInNoScriptInHead),
("testAFlowContents" , testAFlowContents),
("testFontFlowContents" , testFontFlowContents),
("testhandlesMisnestedTagsBI" , testhandlesMisnestedTagsBI),
("testhandlesMisnestedTagsBP" , testhandlesMisnestedTagsBP),
("testhandlesUnexpectedMarkupInTables" , testhandlesUnexpectedMarkupInTables),
("testHandlesUnclosedFormattingElements" , testHandlesUnclosedFormattingElements),
("testhandlesUnclosedAnchors" , testhandlesUnclosedAnchors),
("testreconstructFormattingElements" , testreconstructFormattingElements),
("testreconstructFormattingElementsInTable" , testreconstructFormattingElementsInTable),
("testcommentBeforeHtml" , testcommentBeforeHtml),
("testemptyTdTag" , testemptyTdTag),
("testhandlesSolidusInA" , testhandlesSolidusInA),
("testhandlesSpanInTbody" , testhandlesSpanInTbody)
]
}()
} }

View File

@ -10,21 +10,6 @@ import XCTest
import SwiftSoup import SwiftSoup
class NodeTest: XCTestCase { class NodeTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testHandlesBaseUri() { func testHandlesBaseUri() {
do{ do{
@ -386,12 +371,30 @@ class NodeTest: XCTestCase {
} }
} }
static var allTests = {
func testPerformanceExample() { return [
// This is an example of a performance test case. ("testHandlesBaseUri" , testHandlesBaseUri),
self.measure { ("testSetBaseUriIsRecursive" , testSetBaseUriIsRecursive),
// Put the code you want to measure the time of here. ("testHandlesAbsPrefix" , testHandlesAbsPrefix),
} ("testHandlesAbsOnImage" , testHandlesAbsOnImage),
} ("testHandlesAbsPrefixOnHasAttr" , testHandlesAbsPrefixOnHasAttr),
("testLiteralAbsPrefix" , testLiteralAbsPrefix),
("testHandleAbsOnLocalhostFileUris" , testHandleAbsOnLocalhostFileUris),
("testHandlesAbsOnProtocolessAbsoluteUris" , testHandlesAbsOnProtocolessAbsoluteUris),
("testAbsHandlesRelativeQuery" , testAbsHandlesRelativeQuery),
("testAbsHandlesDotFromIndex" , testAbsHandlesDotFromIndex),
("testRemove" , testRemove),
("testReplace" , testReplace),
("testOwnerDocument" , testOwnerDocument),
("testBefore" , testBefore),
("testAfter" , testAfter),
("testUnwrap" , testUnwrap),
("testUnwrapNoChildren" , testUnwrapNoChildren),
("testTraverse" , testTraverse),
("testOrphanNodeReturnsNullForSiblingElements" , testOrphanNodeReturnsNullForSiblingElements),
("testNodeIsNotASiblingOfItself" , testNodeIsNotASiblingOfItself),
("testChildNodesCopy" , testChildNodesCopy),
("testSupportsClone" , testSupportsClone)
]
}()
} }

View File

@ -10,29 +10,7 @@ import XCTest
import SwiftSoup import SwiftSoup
class ParseSettingsTest: XCTestCase { class ParseSettingsTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
func testCaseSupport() { func testCaseSupport() {
let bothOn = ParseSettings(true, true) let bothOn = ParseSettings(true, true)
let bothOff = ParseSettings(false, false) let bothOff = ParseSettings(false, false)
@ -50,7 +28,11 @@ class ParseSettingsTest: XCTestCase {
XCTAssertEqual("foo", attrOn.normalizeTag("FOO")) XCTAssertEqual("foo", attrOn.normalizeTag("FOO"))
XCTAssertEqual("FOO", attrOn.normalizeAttribute("FOO")) XCTAssertEqual("FOO", attrOn.normalizeAttribute("FOO"))
} }
static var allTests = {
return [
("testCaseSupport" , testCaseSupport)
]
}()
} }

View File

@ -10,23 +10,6 @@ import XCTest
import SwiftSoup import SwiftSoup
class QueryParserTest: XCTestCase { class QueryParserTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
func testOrGetsCorrectPrecedence()throws { func testOrGetsCorrectPrecedence()throws {
// tests that a selector "a b, c d, e f" evals to (a AND b) OR (c AND d) OR (e AND f)" // tests that a selector "a b, c d, e f" evals to (a AND b) OR (c AND d) OR (e AND f)"
@ -59,4 +42,11 @@ class QueryParserTest: XCTestCase {
XCTAssertEqual(2, andRight.evaluators.count) XCTAssertEqual(2, andRight.evaluators.count)
} }
static var allTests = {
return [
("testOrGetsCorrectPrecedence" , testOrGetsCorrectPrecedence),
("testParsesMultiCorrectly" , testParsesMultiCorrectly)
]
}()
} }

View File

@ -11,23 +11,6 @@ import SwiftSoup
class SelectorTest: XCTestCase { class SelectorTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
func testByTag()throws { func testByTag()throws {
// should be case insensitive // should be case insensitive
let els: Elements = try SwiftSoup.parse("<div id=1><div id=2><p>Hello</p></div></div><DIV id=3>").select("DIV") let els: Elements = try SwiftSoup.parse("<div id=1><div id=2><p>Hello</p></div></div><DIV id=3>").select("DIV")
@ -708,5 +691,61 @@ class SelectorTest: XCTestCase {
XCTAssertEqual("Two", try doc.select("div[data=\"[Another)]]\"").first()?.text()) XCTAssertEqual("Two", try doc.select("div[data=\"[Another)]]\"").first()?.text())
} }
static var allTests = {
return [
("testByTag" , testByTag),
("testById" , testById),
("testByClass" , testByClass),
("testByAttribute" , testByAttribute),
("testNamespacedTag" , testNamespacedTag),
("testWildcardNamespacedTag" , testWildcardNamespacedTag),
("testByAttributeStarting" , testByAttributeStarting),
("testByAttributeRegex" , testByAttributeRegex),
("testByAttributeRegexCharacterClass" , testByAttributeRegexCharacterClass),
("testByAttributeRegexCombined" , testByAttributeRegexCombined),
("testCombinedWithContains" , testCombinedWithContains),
("testAllElements" , testAllElements),
("testAllWithClass" , testAllWithClass),
("testGroupOr" , testGroupOr),
("testGroupOrAttribute" , testGroupOrAttribute),
("testDescendant" , testDescendant),
("testAnd" , testAnd),
("testDeeperDescendant" , testDeeperDescendant),
("testParentChildElement" , testParentChildElement),
("testParentWithClassChild" , testParentWithClassChild),
("testParentChildStar" , testParentChildStar),
("testMultiChildDescent" , testMultiChildDescent),
("testCaseInsensitive" , testCaseInsensitive),
("testAdjacentSiblings" , testAdjacentSiblings),
("testAdjacentSiblingsWithId" , testAdjacentSiblingsWithId),
("testNotAdjacent" , testNotAdjacent),
("testMixCombinator" , testMixCombinator),
("testMixCombinatorGroup" , testMixCombinatorGroup),
("testGeneralSiblings" , testGeneralSiblings),
("testCharactersInIdAndClass" , testCharactersInIdAndClass),
("testSupportsLeadingCombinator" , testSupportsLeadingCombinator),
("testPseudoLessThan" , testPseudoLessThan),
("testPseudoGreaterThan" , testPseudoGreaterThan),
("testPseudoEquals" , testPseudoEquals),
("testPseudoBetween" , testPseudoBetween),
("testPseudoCombined" , testPseudoCombined),
("testPseudoHas" , testPseudoHas),
("testNestedHas" , testNestedHas),
("testPseudoContains" , testPseudoContains),
("testPsuedoContainsWithParentheses" , testPsuedoContainsWithParentheses),
("testContainsOwn" , testContainsOwn),
("testMatches" , testMatches),
("testMatchesOwn" , testMatchesOwn),
("testRelaxedTags" , testRelaxedTags),
("testNotParas" , testNotParas),
("testNotAll" , testNotAll),
("testNotClass" , testNotClass),
("testHandlesCommasInSelector" , testHandlesCommasInSelector),
("testSelectSupplementaryCharacter" , testSelectSupplementaryCharacter),
("testSelectClassWithSpace" , testSelectClassWithSpace),
("testSelectSameElements" , testSelectSameElements),
("testAttributeWithBrackets" , testAttributeWithBrackets)
]
}()
} }

View File

@ -11,16 +11,6 @@ import SwiftSoup
class TagTest: XCTestCase { class TagTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testIsCaseSensitive()throws { func testIsCaseSensitive()throws {
let p1: Tag = try Tag.valueOf("P") let p1: Tag = try Tag.valueOf("P")
let p2: Tag = try Tag.valueOf("p") let p2: Tag = try Tag.valueOf("p")
@ -75,20 +65,22 @@ class TagTest: XCTestCase {
XCTAssertTrue(foo.isInline()) XCTAssertTrue(foo.isInline())
XCTAssertTrue(foo.formatAsBlock()) XCTAssertTrue(foo.formatAsBlock())
} }
// func testValueOfChecksNotNull() {
// XCTAssertThrowsError(try Tag.valueOf(nil))
// }
func testValueOfChecksNotEmpty() { func testValueOfChecksNotEmpty() {
XCTAssertThrowsError(try Tag.valueOf(" ")) XCTAssertThrowsError(try Tag.valueOf(" "))
} }
func testPerformanceExample() { static var allTests = {
// This is an example of a performance test case. return [
self.measure { ("testIsCaseSensitive" , testIsCaseSensitive),
// Put the code you want to measure the time of here. ("testCanBeInsensitive" , testCanBeInsensitive),
} ("testTrims" , testTrims),
} ("testEquality" , testEquality),
("testDivSemantics" , testDivSemantics),
("testPSemantics" , testPSemantics),
("testImgSemantics" , testImgSemantics),
("testDefaultSemantics" , testDefaultSemantics),
("testValueOfChecksNotEmpty" , testValueOfChecksNotEmpty),
]
}()
} }

View File

@ -10,16 +10,6 @@ import XCTest
@testable import SwiftSoup @testable import SwiftSoup
class TextNodeTest: XCTestCase { class TextNodeTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testBlank() { func testBlank() {
let one = TextNode("", "") let one = TextNode("", "")
@ -83,12 +73,14 @@ class TextNodeTest: XCTestCase {
XCTAssertEqual(String(Character(UnicodeScalar(135361)!)), try t.outerHtml().trim()) XCTAssertEqual(String(Character(UnicodeScalar(135361)!)), try t.outerHtml().trim())
} }
func testPerformanceExample() { static var allTests = {
// This is an example of a performance test case. return [
self.measure { ("testBlank" , testBlank),
// Put the code you want to measure the time of here. ("testTextBean" , testTextBean),
} ("testSplitText" , testSplitText),
} ("testSplitAnEmbolden" , testSplitAnEmbolden),
("testWithSupplementaryCharacter" , testWithSupplementaryCharacter)
]
}()
} }

View File

@ -10,29 +10,7 @@ import XCTest
import SwiftSoup import SwiftSoup
class TokenQueueTest: XCTestCase { class TokenQueueTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
func testChompBalanced() { func testChompBalanced() {
let tq = TokenQueue(":contains(one (two) three) four") let tq = TokenQueue(":contains(one (two) three) four")
let pre = tq.consumeTo("(") let pre = tq.consumeTo("(")
@ -84,5 +62,16 @@ class TokenQueueTest: XCTestCase {
tq.addFirst("Three") tq.addFirst("Three")
XCTAssertEqual("Three Two", tq.remainder()) XCTAssertEqual("Three Two", tq.remainder())
} }
static var allTests = {
return [
("testChompBalanced" , testChompBalanced),
("testChompEscapedBalanced" , testChompEscapedBalanced),
("testChompBalancedMatchesAsMuchAsPossible" , testChompBalancedMatchesAsMuchAsPossible),
("testUnescape" , testUnescape),
("testChompToIgnoreCase" , testChompToIgnoreCase),
("testAddFirst" , testAddFirst)
]
}()
} }

View File

@ -11,16 +11,6 @@ import SwiftSoup
class XmlTreeBuilderTest: XCTestCase { class XmlTreeBuilderTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testSimpleXmlParse()throws { func testSimpleXmlParse()throws {
let xml = "<doc id=2 href='/bar'>Foo <br /><link>One</link><link>Two</link></doc>" let xml = "<doc id=2 href='/bar'>Foo <br /><link>One</link><link>Two</link></doc>"
let tb: XmlTreeBuilder = XmlTreeBuilder() let tb: XmlTreeBuilder = XmlTreeBuilder()
@ -138,7 +128,7 @@ class XmlTreeBuilderTest: XCTestCase {
try XCTAssertEqual("<?xml version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", decl.outerHtml()) try XCTAssertEqual("<?xml version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", decl.outerHtml())
} }
func caseSensitiveDeclaration()throws { func testCaseSensitiveDeclaration()throws {
let xml = "<?XML version='1' encoding='UTF-8' something='else'?>" let xml = "<?XML version='1' encoding='UTF-8' something='else'?>"
let doc = try SwiftSoup.parse(xml, "", Parser.xmlParser()) let doc = try SwiftSoup.parse(xml, "", Parser.xmlParser())
try XCTAssertEqual("<?XML version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", doc.outerHtml()) try XCTAssertEqual("<?XML version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", doc.outerHtml())
@ -167,13 +157,24 @@ class XmlTreeBuilderTest: XCTestCase {
try XCTAssertEqual("<test id=\"1\">Check</test>", TextUtil.stripNewlines(doc.html())) try XCTAssertEqual("<test id=\"1\">Check</test>", TextUtil.stripNewlines(doc.html()))
} }
static var allTests = {
return [
func testPerformanceExample() { ("testSimpleXmlParse" , testSimpleXmlParse),
// This is an example of a performance test case. ("testPopToClose" , testPopToClose),
self.measure { ("testCommentAndDocType" , testCommentAndDocType),
// Put the code you want to measure the time of here. ("testSupplyParserToJsoupClass" , testSupplyParserToJsoupClass),
} ("testDoesNotForceSelfClosingKnownTags" , testDoesNotForceSelfClosingKnownTags),
}
("testHandlesXmlDeclarationAsDeclaration" , testHandlesXmlDeclarationAsDeclaration),
("testXmlFragment" , testXmlFragment),
("testXmlParseDefaultsToHtmlOutputSyntax" , testXmlParseDefaultsToHtmlOutputSyntax),
("testDoesHandleEOFInTag" , testDoesHandleEOFInTag),
("testParseDeclarationAttributes" , testParseDeclarationAttributes),
("testCaseSensitiveDeclaration" , testCaseSensitiveDeclaration),
("testCreatesValidProlog" , testCreatesValidProlog),
("preservesCaseByDefault" , preservesCaseByDefault),
("canNormalizeCase" , canNormalizeCase)
]
}()
} }