Skip to content

Commit

Permalink
test(ratio): 🧪 use Ratio.zero whenever possible
Browse files Browse the repository at this point in the history
Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>
  • Loading branch information
albertms10 committed Jun 18, 2024
1 parent c0d4ea0 commit 8c38fff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/utils/ratio_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void main() {

group('.toDouble()', () {
test('returns this Ratio as a double', () {
expect(const Ratio.fromMixed(0).toDouble(), 0);
expect(Ratio.zero.toDouble(), 0);
expect(const Ratio.fromMixed(2).toDouble(), 2);
expect(const Ratio.fromMixed(0, 1, 3).toDouble(), 1 / 3);
expect(const Ratio.fromMixed(1, 3, 8).toDouble(), 1.375);
Expand All @@ -93,7 +93,7 @@ void main() {

group('.toString()', () {
test('returns the string representation of this Ratio', () {
expect(const Ratio.fromMixed(0).toString(), '0');
expect(Ratio.zero.toString(), '0');
expect(const Ratio.fromMixed(3).toString(), '3');
expect(const Ratio.fromMixed(0, 1, 3).toString(), '1/3');
expect(const Ratio.fromMixed(3, 5, 4).toString(), '4 1/4');
Expand All @@ -103,13 +103,13 @@ void main() {
group('.compareTo()', () {
test('sorts Ratios in a collection', () {
final orderedSet = SplayTreeSet<Ratio>.of({
const Ratio.fromMixed(0),
Ratio.zero,
const Ratio.fromMixed(1, 2, 2),
const Ratio.fromMixed(0, 7, 2),
const Ratio.fromMixed(0, 1, 9),
});
expect(orderedSet.toList(), const [
Ratio.fromMixed(0),
Ratio.zero,
Ratio.fromMixed(0, 1, 9),
Ratio.fromMixed(1, 2, 2),
Ratio.fromMixed(0, 7, 2),
Expand Down

0 comments on commit 8c38fff

Please sign in to comment.