SwiftyMarkdownPerformanceTests.swift 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // SwiftyMarkdownAttributedStringTests.swift
  3. // SwiftyMarkdownTests
  4. //
  5. // Created by Simon Fairbairn on 17/12/2019.
  6. // Copyright © 2019 Voyage Travel Apps. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import SwiftyMarkdown
  10. class SwiftyMarkdownPerformanceTests: XCTestCase {
  11. func testThatFilesAreProcessedQuickly() {
  12. let url = self.resourceURL(for: "test.md")
  13. measure {
  14. guard let md = SwiftyMarkdown(url: url) else {
  15. XCTFail("Failed to load file")
  16. return
  17. }
  18. _ = md.attributedString()
  19. }
  20. }
  21. func testThatStringsAreProcessedQuickly() {
  22. let string = "SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use."
  23. let md = SwiftyMarkdown(string: string)
  24. measure {
  25. _ = md.attributedString(from: string)
  26. }
  27. }
  28. func testThatVeryLongStringsAreProcessedQuickly() {
  29. let string = "SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use. SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use. SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use. SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use. SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use. SwiftyMarkdown converts Markdown files and strings into `NSAttributedString`s using sensible defaults and a *Swift*-style syntax. It uses **dynamic type** to set the font size correctly with [whatever](https://www.neverendingvoyage.com/) font you'd like to use."
  30. let md = SwiftyMarkdown(string: string)
  31. measure {
  32. _ = md.attributedString(from: string)
  33. }
  34. }
  35. }