attaswift / BTree

@@ -476,4 +476,22 @@
Loading
476 476
477 477
        assertEqualElements(l1 + l2, 0 ..< 20)
478 478
    }
479 +
480 +
    #if swift(>=4.2)
481 +
    func testCanBeCodedDecoded() {
482 +
        let list: List<Int> = [0, 1, 2, 3, 4]
483 +
        let encoder = PropertyListEncoder()
484 +
        guard let data = try? encoder.encode(list) else {
485 +
            XCTFail("failed encode")
486 +
            return
487 +
        }
488 +
        let decoder = PropertyListDecoder()
489 +
        guard let decodedList = try? decoder.decode(List<Int>.self, from: data) else {
490 +
            XCTFail("failed decode")
491 +
            return
492 +
        }
493 +
        assertEqualElements(IteratorSequence(decodedList.makeIterator()),
494 +
                            IteratorSequence(list.makeIterator()))
495 +
    }
496 +
    #endif
479 497
}

@@ -694,4 +694,23 @@
Loading
694 694
        a.shift(startingAt: 15, by: -5)
695 695
        assertEqualElements(a, [0, 3, 5, 7, 8])
696 696
    }
697 +
698 +
    #if swift(>=4.2)
699 +
    func testCanBeCodedDecoded() {
700 +
        let c = 1_000
701 +
        let set = SortedSet((0 ..< c).reversed())
702 +
        let encoder = PropertyListEncoder()
703 +
        guard let data = try? encoder.encode(set) else {
704 +
            XCTFail("failed encode")
705 +
            return
706 +
        }
707 +
        let decoder = PropertyListDecoder()
708 +
        guard let decodedSet = try? decoder.decode(SortedSet<Int>.self, from: data) else {
709 +
            XCTFail("failed decode")
710 +
            return
711 +
        }
712 +
        assertEqualElements(IteratorSequence(decodedSet.makeIterator()),
713 +
                            IteratorSequence(set.makeIterator()))
714 +
    }
715 +
    #endif
697 716
}

@@ -982,4 +982,23 @@
Loading
982 982
983 983
        assertEqualElements(copy, [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18])
984 984
    }
985 +
986 +
    #if swift(>=4.2)
987 +
    func testCanBeCodedDecoded() {
988 +
        let c = 100
989 +
        let bag = SortedBag((0 ..< c).map { 2 * $0 }.repeatEach(3))
990 +
        let encoder = PropertyListEncoder()
991 +
        guard let data = try? encoder.encode(bag) else {
992 +
            XCTFail("failed encode")
993 +
            return
994 +
        }
995 +
        let decoder = PropertyListDecoder()
996 +
        guard let decodedBag = try? decoder.decode(SortedBag<Int>.self, from: data) else {
997 +
            XCTFail("failed decode")
998 +
            return
999 +
        }
1000 +
        assertEqualElements(IteratorSequence(decodedBag.makeIterator()),
1001 +
                            IteratorSequence(bag.makeIterator()))
1002 +
    }
1003 +
    #endif
985 1004
}

@@ -492,4 +492,22 @@
Loading
492 492
        node.assertValid()
493 493
        assertEqualElements(node, (0..<100).map { (0, $0) })
494 494
    }
495 +
496 +
    #if swift(>=4.2)
497 +
    func testCanBeCodedDecoded() {
498 +
        let node = maximalNode(depth: 1, order: 5)
499 +
        let encoder = PropertyListEncoder()
500 +
        guard let data = try? encoder.encode(node) else {
501 +
            XCTFail("failed encode")
502 +
            return
503 +
        }
504 +
        let decoder = PropertyListDecoder()
505 +
        guard let decodedNode = try? decoder.decode(Node.self, from: data) else {
506 +
            XCTFail("failed decode")
507 +
            return
508 +
        }
509 +
        assertEqualElements(IteratorSequence(decodedNode.makeIterator()),
510 +
                            IteratorSequence(node.makeIterator()))
511 +
    }
512 +
    #endif
495 513
}

@@ -440,4 +440,22 @@
Loading
440 440
        assertEqualElements(m.excluding([0, 5, 10, 15]), ([1 ..< 5, 6 ..< 10, 11 ..< 15, 16 ..< 20] as [CountableRange<Int>]).joined().map { (k) -> (Int, String) in (k, String(k)) })
441 441
        assertEqualElements(m.excluding(-10 ..< 30), [])
442 442
    }
443 +
444 +
    #if swift(>=4.2)
445 +
    func testCanBeCodedDecoded() {
446 +
        let map = Map<Int, String>(sortedElements: (0..<100).map { ($0, String($0)) })
447 +
        let encoder = PropertyListEncoder()
448 +
        guard let data = try? encoder.encode(map) else {
449 +
            XCTFail("failed encode")
450 +
            return
451 +
        }
452 +
        let decoder = PropertyListDecoder()
453 +
        guard let decodedMap = try? decoder.decode(Map<Int, String>.self, from: data) else {
454 +
            XCTFail("failed decode")
455 +
            return
456 +
        }
457 +
        assertEqualElements(IteratorSequence(decodedMap.makeIterator()),
458 +
                            IteratorSequence(map.makeIterator()))
459 +
    }
460 +
    #endif
443 461
}

@@ -1236,4 +1236,22 @@
Loading
1236 1236
        tree.assertValid()
1237 1237
        assertEqualElements(tree, [(0, "0*"), (1, "1*"), (2, "2*"), (3, "3*"), (4, "4*")])
1238 1238
    }
1239 +
1240 +
    #if swift(>=4.2)
1241 +
    func testCanBeCodedDecoded() {
1242 +
        let tree = Tree(minimalTree(depth: 2, order: 5))
1243 +
        let encoder = PropertyListEncoder()
1244 +
        guard let data = try? encoder.encode(tree) else {
1245 +
            XCTFail("failed encode")
1246 +
            return
1247 +
        }
1248 +
        let decoder = PropertyListDecoder()
1249 +
        guard let decodedTree = try? decoder.decode(Tree.self, from: data) else {
1250 +
            XCTFail("failed decode")
1251 +
            return
1252 +
        }
1253 +
        assertEqualElements(IteratorSequence(decodedTree.makeIterator()),
1254 +
                            IteratorSequence(tree.makeIterator()))
1255 +
    }
1256 +
    #endif
1239 1257
}
Files Coverage
Tests/BTreeTests 98.56%
Project Totals (18 files) 98.56%
301.1
default=
TRAVIS_OS_NAME=osx
1
ignore:
2
  - "/Tests/*"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading