mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-13 03:10:42 +08:00
* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631) * Move files to src and comply with the dart package layout convention * Fixing widgets example Co-authored-by: Serge Matveenko <lig@countzero.co> Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
32 lines
855 B
Dart
32 lines
855 B
Dart
import 'package:test/test.dart';
|
|
|
|
import 'package:flame/src/memory_cache.dart';
|
|
|
|
void main() {
|
|
group('MemoryCache', () {
|
|
test('basic cache addition', () {
|
|
final cache = MemoryCache<int, String>();
|
|
cache.setValue(0, 'bla');
|
|
expect(cache.getValue(0), 'bla');
|
|
});
|
|
|
|
test('contains key', () {
|
|
final cache = MemoryCache<int, String>();
|
|
cache.setValue(0, 'bla');
|
|
expect(cache.containsKey(0), true);
|
|
expect(cache.containsKey(1), false);
|
|
});
|
|
|
|
test('cache size', () {
|
|
final cache = MemoryCache<int, String>(cacheSize: 1);
|
|
cache.setValue(0, 'bla');
|
|
cache.setValue(1, 'ble');
|
|
expect(cache.containsKey(0), false);
|
|
expect(cache.containsKey(1), true);
|
|
expect(cache.getValue(0), null);
|
|
expect(cache.getValue(1), 'ble');
|
|
expect(cache.size, 1);
|
|
});
|
|
});
|
|
}
|