From b489a6e786752fe5b29b4e2fdba75837668cc00a Mon Sep 17 00:00:00 2001 From: Michael Steindorfer Date: Sun, 9 May 2021 23:20:27 +0200 Subject: [PATCH] [Capsule] Add special case iterator test --- Tests/CapsuleTests/CapsuleSmokeTests.swift | 34 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Tests/CapsuleTests/CapsuleSmokeTests.swift b/Tests/CapsuleTests/CapsuleSmokeTests.swift index 54db507e..d7f6a36a 100644 --- a/Tests/CapsuleTests/CapsuleSmokeTests.swift +++ b/Tests/CapsuleTests/CapsuleSmokeTests.swift @@ -135,13 +135,16 @@ final class CapsuleSmokeTests: CollectionTestCase { var map3: HashMap = map2 for index in 0..(_ map: HashMap) -> Int { + var size = 0 + + for _ in map { + size += 1 + } + + return size + } + + func testIteratorEnumeratesAll() { + let map1: HashMap = [ + CollidableInt(11, 1) : "a", + CollidableInt(12, 1) : "a", + CollidableInt(32769) : "b" + ] + + var map2: HashMap = [:] + for (key, value) in map1 { + map2[key] = value + } + + expectEqual(map1, map2) + } } fileprivate final class CollidableInt : CustomStringConvertible, Equatable, Hashable {