mirror of
https://github.com/qvacua/vimr.git
synced 2024-09-11 17:15:34 +03:00
Add simple tests for FifoCache
This commit is contained in:
parent
00fc1acb9e
commit
a59a40e871
33
Commons/Tests/CommonsTests/FifoCacheTest.swift
Normal file
33
Commons/Tests/CommonsTests/FifoCacheTest.swift
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Tae Won Ha - http://taewon.de - @hataewon
|
||||
* See LICENSE
|
||||
*/
|
||||
|
||||
import XCTest
|
||||
import Nimble
|
||||
|
||||
@testable import Commons
|
||||
|
||||
class FifoCacheTest: XCTestCase {
|
||||
|
||||
var fifo: FifoCache<Int, Int>!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
self.fifo = FifoCache(count: 10, queueQos: .default)
|
||||
}
|
||||
|
||||
func testSimpleGet() {
|
||||
for i in (0...5) { self.fifo.set(i, forKey: i) }
|
||||
|
||||
for i in (0...5) { expect(self.fifo.valueForKey(i)).to(equal(i)) }
|
||||
for i in (6..<10) { expect(self.fifo.valueForKey(i)).to(beNil()) }
|
||||
}
|
||||
|
||||
func testGet() {
|
||||
for i in (0..<(10 * 3)) { self.fifo.set(i, forKey: i) }
|
||||
for i in (20..<30) { expect(self.fifo.valueForKey(i)).to(equal(i)) }
|
||||
expect(self.fifo.valueForKey(19)).to(beNil())
|
||||
expect(self.fifo.valueForKey(30)).to(beNil())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user