From 2c607fd98406948165f7fbabff17365e8bf0acfe Mon Sep 17 00:00:00 2001 From: Christopher Luu Date: Wed, 27 Jan 2016 11:42:39 -0500 Subject: [PATCH] Add tests for removal of nonexistant keys --- CacheIsKingTests/CacheIsKingTests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CacheIsKingTests/CacheIsKingTests.swift b/CacheIsKingTests/CacheIsKingTests.swift index 89a6ba2..af7e20b 100644 --- a/CacheIsKingTests/CacheIsKingTests.swift +++ b/CacheIsKingTests/CacheIsKingTests.swift @@ -174,6 +174,22 @@ class CacheIsKingTests: XCTestCase { NSNotificationCenter.defaultCenter().postNotificationName(UIApplicationDidEnterBackgroundNotification, object: UIApplication.sharedApplication()) XCTAssert(cache.count == 0) + + cache.setItem(123, forKey: 123) + cache.setItem(234, forKey: 234) + cache.setItem(345, forKey: 345) + cache.setItem(456, forKey: 456) + + XCTAssert(cache.count == 4) + + // Make sure an unknown key doesn't have any weird side effects + cache[567] = nil + + XCTAssert(cache.count == 4) + + cache.removeItemForKey(999) + + XCTAssert(cache.count == 4) } func testCountLimit() {