Last active
June 14, 2018 23:00
Revisions
-
ignazioc revised this gist
Jun 14, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import UIKit import XCTest class UserManagerTests: XCTestCase { func testConvertToHtml() { self.measure { let htmlString = String.init(repeating: "<p>I am normal</p><b>asdfasd</b><i>asdfasdfa</i>", count: 1000) _ = htmlString.convertHtml() @@ -21,4 +21,4 @@ extension String { } } UserManagerTests.defaultTestSuite.run() -
ignazioc created this gist
Jun 14, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ //: Playground - noun: a place where people can play import UIKit import XCTest class UserManagerTests: XCTestCase { func testLoggingIn() { self.measure { let htmlString = String.init(repeating: "<p>I am normal</p><b>asdfasd</b><i>asdfasdfa</i>", count: 1000) _ = htmlString.convertHtml() } } } extension String { func convertHtml() -> NSAttributedString { let modifiedFont = String(format:"<span style=\"font-family: '-apple-system', 'HelveticaNeue'; font-size: 17\">%@</span>", self) let data = modifiedFont.data(using: .utf8)! return try! NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) } } UserManagerTests.defaultTestSuite.run()