-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1162 from beribas/fix_crashing_vcardtemp_types
Fix crashes in XMPPvCardTempEmail and XMPPvCardTempTel initialize
- Loading branch information
Showing
7 changed files
with
142 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// XMPPvCardTempTests.swift | ||
// XMPPFrameworkSwiftTests | ||
// | ||
// Created by Oleg Langer on 07.04.20. | ||
// | ||
|
||
import XCTest | ||
|
||
class XMPPvCardTempTests: XCTestCase { | ||
var xmlString: String! | ||
var sut: XMPPvCardTemp! | ||
|
||
override func setUp() { | ||
xmlString = """ | ||
<vCard xmlns="vcard-temp"> | ||
<NICKNAME>DESKTOP</NICKNAME> | ||
<EMAIL> | ||
<INTERNET/> | ||
<USERID>[email protected]</USERID> | ||
</EMAIL> | ||
<TEL> | ||
<WORK/> | ||
<VOICE/> | ||
<NUMBER>303-308-3282</NUMBER> | ||
</TEL> | ||
</vCard> | ||
""" | ||
let element = try! XMLElement(xmlString: xmlString) | ||
sut = XMPPvCardTemp.vCardTemp(from: element) | ||
} | ||
|
||
func testCreateFromXMLString() { | ||
XCTAssertNotNil(sut) | ||
} | ||
|
||
func testGetEmailAddress() { | ||
XCTAssertEqual(sut.emailAddresses.count, 1) | ||
let email = sut.emailAddresses.first | ||
XCTAssertNotNil(email) | ||
XCTAssertEqual(email?.userid, "[email protected]") | ||
XCTAssertEqual(email?.isInternet, true) | ||
} | ||
|
||
func testRemoveEmailAddress() { | ||
let email = sut.emailAddresses.first! | ||
sut.removeEmailAddress(email) | ||
|
||
XCTAssertEqual(sut.emailAddresses.count, 0) | ||
} | ||
|
||
func testAddEmailAddress() { | ||
// Remove all first | ||
sut.clearEmailAddresses() | ||
|
||
let element = XMLElement(name: "EMAIL") | ||
let newMail = XMPPvCardTempEmail.vCardEmail(from: element) | ||
newMail.isWork = true | ||
newMail.userid = "[email protected]" | ||
sut.addEmailAddress(newMail) | ||
|
||
XCTAssertEqual(sut.emailAddresses.first, newMail) | ||
} | ||
|
||
func testGetTelecomAddress() { | ||
XCTAssertEqual(sut.telecomsAddresses.count, 1) | ||
let tel = sut.telecomsAddresses.first! | ||
XCTAssertTrue(tel.isWork) | ||
XCTAssertTrue(tel.isVoice) | ||
XCTAssertEqual(tel.number, "303-308-3282") | ||
} | ||
|
||
func testRemoveTelecomAddresses() { | ||
let tel = sut.telecomsAddresses.first! | ||
sut.removeTelecomsAddress(tel) | ||
XCTAssertEqual(sut.telecomsAddresses.count, 0) | ||
} | ||
|
||
func testAddTelecomAddress() { | ||
sut.clearTelecomsAddresses() | ||
|
||
let element = XMLElement(name: "TEL") | ||
let newTel = XMPPvCardTempTel.vCardTel(from: element) | ||
newTel.isCell = true | ||
newTel.number = "101" | ||
sut.addTelecomsAddress(newTel) | ||
|
||
XCTAssertEqual(sut.telecomsAddresses.count, 1) | ||
XCTAssertEqual(sut.telecomsAddresses.first!, newTel) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters