def testHasEntryWithLoadAndSizeOne(self): c = LRUCache(1) c.load_entry('hello', 'world') self.assertTrue(c.has_entry('hello')) c.load_entry('yellow', 'duck') self.assertTrue(c.has_entry('yellow')) self.assertFalse(c.has_entry('hello')) c.load_entry('blue', 'sky') self.assertTrue(c.has_entry('blue')) self.assertFalse(c.has_entry('yellow')) self.assertFalse(c.has_entry('hello')) c.load_entry('brown', 'bear') self.assertTrue(c.has_entry('brown')) self.assertFalse(c.has_entry('blue')) self.assertFalse(c.has_entry('yellow')) self.assertFalse(c.has_entry('hello'))
def testEvictionWithoutLookup(self): c = LRUCache(3) c.load_entry('hello', 'world') c.load_entry('yellow', 'duck') c.load_entry('blue', 'sky') c.load_entry('brown', 'bear') self.assertFalse(c.has_entry('hello')) self.assertTrue(c.has_entry('yellow')) self.assertTrue(c.has_entry('blue')) self.assertTrue(c.has_entry('brown'))
def testHasEntryWithLoadAndSizeZero(self): c = LRUCache(0) c.load_entry('hello', 'world') self.assertFalse(c.has_entry('hello'))
def testHasEntryWithLoad(self): c = LRUCache(5) c.load_entry('hello', 'world') self.assertTrue(c.has_entry('hello'))