| 115 | |
| 116 | #[test] |
| 117 | fn insert_and_drain() { |
| 118 | let mut cache = FlashblockCache::new(10); |
| 119 | |
| 120 | assert!(cache.insert(make_flashblock(11, 1))); |
| 121 | assert!(cache.insert(make_flashblock(11, 0))); |
| 122 | assert_eq!(cache.len(), 1); |
| 123 | assert_eq!(cache.total_flashblocks(), 2); |
| 124 | |
| 125 | let drained = cache.drain(11); |
| 126 | assert_eq!(drained.len(), 2); |
| 127 | // Should be sorted by index |
| 128 | assert_eq!(drained[0].index, 0); |
| 129 | assert_eq!(drained[1].index, 1); |
| 130 | assert!(cache.is_empty()); |
| 131 | } |
| 132 | |
| 133 | #[test] |
| 134 | fn drain_empty() { |