()
| 124 | |
| 125 | #[test] |
| 126 | fn test_lru_cache_eviction() { |
| 127 | let mut cache: LruCache<u32, String> = LruCache::new(2); |
| 128 | |
| 129 | cache.insert(1, "one".to_string()); |
| 130 | cache.insert(2, "two".to_string()); |
| 131 | cache.insert(3, "three".to_string()); // Should evict 1 |
| 132 | |
| 133 | assert_eq!(cache.get(&1), None); // Evicted |
| 134 | assert_eq!(cache.get(&2), Some(&"two".to_string())); |
| 135 | assert_eq!(cache.get(&3), Some(&"three".to_string())); |
| 136 | } |
| 137 | |
| 138 | #[test] |
| 139 | fn test_lru_cache_access_updates_order() { |