()
| 58 | |
| 59 | #[test] |
| 60 | fn test_lru_cache_eviction() { |
| 61 | let mut cache: LruCache<u32, String> = LruCache::new(2); |
| 62 | |
| 63 | cache.insert(1, "one".to_string()); |
| 64 | cache.insert(2, "two".to_string()); |
| 65 | cache.insert(3, "three".to_string()); // Should evict 1 |
| 66 | |
| 67 | assert_eq!(cache.get(&1), None); // Evicted |
| 68 | assert_eq!(cache.get(&2), Some(&"two".to_string())); |
| 69 | assert_eq!(cache.get(&3), Some(&"three".to_string())); |
| 70 | } |
| 71 | |
| 72 | #[test] |
| 73 | fn test_lru_cache_access_updates_order() { |