Skip to content

Commit

Permalink
added tests for isEmpty / isNotEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
LowLevelSubmarine committed Mar 27, 2024
1 parent dd4ee69 commit 582fd64
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
12 changes: 10 additions & 2 deletions lib/src/ilist/ilist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "l_flat.dart";
@immutable
class IListEmpty<T> // ignore: must_be_immutable
extends IList<T> {
/// Creates a empty list. In most cases, you should use `const IList.empty()`.
/// Creates an empty list. In most cases, you should use `const IList.empty()`.
///
/// IMPORTANT: You must always use the `const` keyword.
/// It's always wrong to use an `IListEmpty()` which is not constant.
Expand All @@ -29,14 +29,22 @@ class IListEmpty<T> // ignore: must_be_immutable
@override
final ConfigList config;

/// A empty list is always flushed, by definition.
/// An empty list is always flushed, by definition.
@override
bool get isFlushed => true;

/// Nothing happens when you flush a empty list, by definition.
@override
IListEmpty<T> get flush => this;

/// An empty list is always empty, by definition
@override
bool get isEmpty => true;

/// An empty list is always empty, by definition
@override
bool get isNotEmpty => false;

@override
int get _counter => 0;

Expand Down
12 changes: 10 additions & 2 deletions lib/src/imap/imap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "m_replace.dart";
@immutable
class IMapEmpty<K, V> // ignore: must_be_immutable
extends IMap<K, V> {
/// Creates a empty map. In most cases, you should use `const IMap.empty()`.
/// Creates an empty map. In most cases, you should use `const IMap.empty()`.
///
/// IMPORTANT: You must always use the `const` keyword.
/// It's always wrong to use an `IMapEmpty()` which is not constant.
Expand All @@ -30,14 +30,22 @@ class IMapEmpty<K, V> // ignore: must_be_immutable
@override
final ConfigMap config;

/// A empty map is always flushed, by definition.
/// An empty map is always flushed, by definition.
@override
bool get isFlushed => true;

/// Nothing happens when you flush a empty map, by definition.
@override
IMapEmpty<K, V> get flush => this;

/// An empty map is always empty, by definition
@override
bool get isEmpty => true;

/// An empty map is always empty, by definition
@override
bool get isNotEmpty => false;

@override
int get _counter => 0;

Expand Down
12 changes: 10 additions & 2 deletions lib/src/iset/iset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "s_flat.dart";
@immutable
class ISetEmpty<T> // ignore: must_be_immutable
extends ISet<T> {
/// Creates a empty set. In most cases, you should use `const ISet.empty()`.
/// Creates an empty set. In most cases, you should use `const ISet.empty()`.
///
/// IMPORTANT: You must always use the `const` keyword.
/// It's always wrong to use an `ISetEmpty()` which is not constant.
Expand All @@ -29,14 +29,22 @@ class ISetEmpty<T> // ignore: must_be_immutable
@override
final ConfigSet config;

/// A empty set is always flushed, by definition.
/// An empty set is always flushed, by definition.
@override
bool get isFlushed => true;

/// Nothing happens when you flush a empty set, by definition.
@override
ISetEmpty<T> get flush => this;

/// An empty set is always empty, by definition
@override
bool get isEmpty => true;

/// An empty set is always empty, by definition
@override
bool get isNotEmpty => false;

@override
int get _counter => 0;

Expand Down
5 changes: 5 additions & 0 deletions test/ilist/ilist_empty_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ void main() {
expect(const IList.empty().equalItemsAndConfig(const IList.empty()), isTrue);
expect(const IList.empty().equalItemsAndConfig(const IListEmpty()), isTrue);
});

test(".isEmpty() | .isNotEmpty()", () {
expect(const IList.empty().isEmpty, isTrue);
expect(const IList.empty().isNotEmpty, isFalse);
});
}
5 changes: 5 additions & 0 deletions test/imap/imap_empty_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ void main() {
expect(const IMap.empty().equalItemsAndConfig(const IMap.empty()), isTrue);
expect(const IMap.empty().equalItemsAndConfig(const IMapEmpty()), isTrue);
});

test(".isEmpty() | .isNotEmpty()", () {
expect(const IMap.empty().isEmpty, isTrue);
expect(const IMap.empty().isNotEmpty, isFalse);
});
}
5 changes: 5 additions & 0 deletions test/iset/iset_empty_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ void main() {
expect(const ISet.empty().equalItemsAndConfig(const ISet.empty()), isTrue);
expect(const ISet.empty().equalItemsAndConfig(const ISetEmpty()), isTrue);
});

test(".isEmpty() | .isNotEmpty()", () {
expect(const ISet.empty().isEmpty, isTrue);
expect(const ISet.empty().isNotEmpty, isFalse);
});
}

0 comments on commit 582fd64

Please sign in to comment.