Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Aug 20, 2021
1 parent 4baaf8f commit 3c0afc7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/map_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ void main() {
});
});

group('count', () {
test('empty', () {
expect(<String, int>{}.count(), 0);
});

test('count elements', () {
expect({1: 'a', 2: 'b'}.count(), 2);
});

test('count even', () {
final map = {1: 'a', 2: 'b', 3: 'c'};
expect(map.count((it) => it.key % 2 == 0), 1);
});
});

group('filter', () {
test('filter', () {
final pokemon = {
Expand Down Expand Up @@ -88,6 +103,23 @@ void main() {
});
});

group('getOrElse', () {
test('get', () {
final pokemon = {
1: 'Bulbasaur',
2: 'Ivysaur',
};
expect(pokemon.getOrElse(1, () => 'None'), 'Bulbasaur');
});
test('else', () {
final pokemon = {
1: 'Bulbasaur',
2: 'Ivysaur',
};
expect(pokemon.getOrElse(10, () => 'None'), 'None');
});
});

group('mapEntries', () {
test('map entries', () {
final pokemon = {
Expand Down

0 comments on commit 3c0afc7

Please sign in to comment.