CollectionTests.swift 666 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // CollectionTests.swift
  3. // LoopKitTests
  4. //
  5. // Created by Pete Schwamb on 9/2/20.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import LoopKit
  10. class CollectionTests: XCTestCase {
  11. func testChunkedWithEmptyArray() {
  12. let result = [].chunked(into: 5)
  13. XCTAssertTrue(result.isEmpty)
  14. }
  15. func testChunkedWithArrayEvenMultipleOfChunkSize() {
  16. let result = [1,2,3,4].chunked(into: 2)
  17. XCTAssertEqual([[1,2], [3,4]], result)
  18. }
  19. func testArrayChunkedWithModuloRemainder() {
  20. let result = [1,2,3].chunked(into: 2)
  21. XCTAssertEqual([[1,2], [3]], result)
  22. }
  23. }