A WIP iOS app for Mastodon and Pleroma.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CharacterCounterTests.swift 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // CharacterCounterTests.swift
  3. // PachydermTests
  4. //
  5. // Created by Shadowfacts on 9/29/18.
  6. // Copyright © 2018 Shadowfacts. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import Pachyderm
  10. class CharacterCounterTests: XCTestCase {
  11. override func setUp() {
  12. }
  13. override func tearDown() {
  14. }
  15. func testCountEmpty() {
  16. XCTAssertEqual(CharacterCounter.count(text: ""), 0)
  17. }
  18. func testCountPlainText() {
  19. XCTAssertEqual(CharacterCounter.count(text: "This is an example message"), 26)
  20. XCTAssertEqual(CharacterCounter.count(text: "This is an example message with an Emoji: 😄"), 43)
  21. XCTAssertEqual(CharacterCounter.count(text: "😄😄😄😄😄😄😄"), 7)
  22. }
  23. func testCountLinks() {
  24. XCTAssertEqual(CharacterCounter.count(text: "This is an example with a link: https://example.com"), 55)
  25. XCTAssertEqual(CharacterCounter.count(text: "This is an example with a link 😄: https://example.com"), 57)
  26. XCTAssertEqual(CharacterCounter.count(text: "😄😄😄😄😄😄😄: https://example.com"), 32)
  27. XCTAssertEqual(CharacterCounter.count(text: "This is an example with a link: https://a.much.longer.example.com/link?foo=bar#baz"), 55)
  28. }
  29. func testCountLocalMentions() {
  30. XCTAssertEqual(CharacterCounter.count(text: "hello @example"), 14)
  31. XCTAssertEqual(CharacterCounter.count(text: "@some_really_long_name"), 22)
  32. }
  33. func testCountRemoteMentions() {
  34. XCTAssertEqual(CharacterCounter.count(text: "hello @example@some.remote.social"), 14)
  35. XCTAssertEqual(CharacterCounter.count(text: "hello @some_really_long_name@some-long.remote-instance.social"), 28)
  36. }
  37. }