Files
flame/test/memory_cache_test.dart
Renan ccee9a466b Move files to src and comply with the dart package layout convention (#621)
* 👌 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>
2021-01-20 09:05:43 -03:00

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);
});
});
}