moxxy/test/cache_test.dart
Alexander "PapaTutuWawa c88003bea1 feat(service): Remove shared media entry on message retraction
Also: Fix some ordering oddities with the shared media widget and page.
2022-11-22 19:51:28 +01:00

25 lines
611 B
Dart

import 'package:moxxyv2/shared/cache.dart';
import 'package:test/test.dart';
void main() {
test('Test the LRU cache', () {
final cache = LRUCache<String, int>(2);
cache.cache('a', 1);
cache.cache('b', 2);
expect(cache.inCache('a'), true);
expect(cache.inCache('b'), true);
cache.cache('c', 3);
expect(cache.inCache('a'), false);
expect(cache.inCache('b'), true);
expect(cache.inCache('c'), true);
cache.cache('c', 4);
expect(cache.inCache('b'), true);
expect(cache.inCache('c'), true);
expect(cache.getValue('c'), 4);
});
}