VoIPCallIdTests.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. import XCTest
  21. @testable import Threema
  22. class VoIPCallIdTests: XCTestCase {
  23. override func setUp() {
  24. super.setUp()
  25. // necessary for ValidationLogger
  26. AppGroup.setGroupId("group.ch.threema") //THREEMA_GROUP_IDENTIFIER @"group.ch.threema"
  27. }
  28. override func tearDown() {
  29. super.tearDown()
  30. }
  31. func testNegativeCallId() -> Void {
  32. let callId = VoIPCallId(callId: -1 as? UInt32)
  33. XCTAssertEqual(0, callId.callId)
  34. }
  35. func testToBigCallId() -> Void {
  36. let callId = VoIPCallId(callId: 99999999999 as? UInt32)
  37. XCTAssertEqual(0, callId.callId)
  38. }
  39. func testShortCallId() -> Void {
  40. let callId = VoIPCallId(callId: 3)
  41. XCTAssertEqual(3, callId.callId)
  42. }
  43. func testBigCallId() -> Void {
  44. let callId = VoIPCallId(callId: 2594350554)
  45. XCTAssertEqual(2594350554, callId.callId)
  46. }
  47. func testRandomCallId() -> Void {
  48. let random = UInt32.random(in: 0 ... UInt32.max)
  49. let callId = VoIPCallId(callId: random)
  50. XCTAssertEqual(random, callId.callId)
  51. }
  52. }