From 7e5f5ed338e7df5f6575f1d60d33f53c2c647484 Mon Sep 17 00:00:00 2001 From: minhqdao Date: Thu, 7 Oct 2021 13:54:31 +0200 Subject: [PATCH] Organize imports and fix trailing commas --- lib/dartx.dart | 6 +-- lib/src/comparable.dart | 6 ++- lib/src/io/directory.dart | 32 ++++++++++------ lib/src/io/file.dart | 4 +- lib/src/iterable.dart | 22 ++++++++--- lib/src/map.dart | 8 ++-- lib/src/num.dart | 6 ++- lib/src/sorted_list.dart | 14 +++++-- test/comparable_test.dart | 74 +++++++++++++++++++++--------------- test/directory.dart | 2 +- test/file_system_entity.dart | 2 +- test/function_test.dart | 2 +- test/iterable_num_test.dart | 2 +- test/iterable_test.dart | 53 +++++++++++++++++--------- test/list_test.dart | 2 +- test/map_test.dart | 62 +++++++++++++++++++----------- test/num_test.dart | 26 ++++++++----- test/range_test.dart | 62 ++++++++++++++++++++---------- test/sorted_list_test.dart | 13 ++++--- test/string_test.dart | 18 +++++---- 20 files changed, 265 insertions(+), 151 deletions(-) diff --git a/lib/dartx.dart b/lib/dartx.dart index 9b568a1..0a3522c 100644 --- a/lib/dartx.dart +++ b/lib/dartx.dart @@ -10,17 +10,17 @@ import 'package:characters/characters.dart' as characters; import 'package:collection/collection.dart' as collection; import 'package:crypto/crypto.dart' as crypto; -export 'package:time/time.dart'; export 'package:characters/characters.dart'; +export 'package:time/time.dart'; part 'src/comparable.dart'; part 'src/comparator.dart'; part 'src/function.dart'; -part 'src/iterable_num.dart'; part 'src/iterable.dart'; +part 'src/iterable_num.dart'; part 'src/list.dart'; part 'src/map.dart'; part 'src/num.dart'; +part 'src/range.dart'; part 'src/sorted_list.dart'; part 'src/string.dart'; -part 'src/range.dart'; diff --git a/lib/src/comparable.dart b/lib/src/comparable.dart index 8df26b6..fc5c344 100644 --- a/lib/src/comparable.dart +++ b/lib/src/comparable.dart @@ -26,8 +26,10 @@ extension ComparableCoerceInExtension> on T { /// or [maximumValue] if this value is greater than [maximumValue]. T coerceIn(T minimumValue, [T? maximumValue]) { if (maximumValue != null && minimumValue > maximumValue) { - throw ArgumentError('Cannot coerce value to an empty range: ' - 'maximum $maximumValue is less than minimum $minimumValue.'); + throw ArgumentError( + 'Cannot coerce value to an empty range: ' + 'maximum $maximumValue is less than minimum $minimumValue.', + ); } if (this < minimumValue) return minimumValue; if (maximumValue != null && this > maximumValue) return maximumValue; diff --git a/lib/src/io/directory.dart b/lib/src/io/directory.dart index 1513400..bbf3527 100644 --- a/lib/src/io/directory.dart +++ b/lib/src/io/directory.dart @@ -1,13 +1,15 @@ part of dartx_io; extension DirectorySubDirExtension on Directory { - Directory subdir(String part1, - [String? part2, - String? part3, - String? part4, - String? part5, - String? part6, - String? part7]) { + Directory subdir( + String part1, [ + String? part2, + String? part3, + String? part4, + String? part5, + String? part6, + String? part7, + ]) { return Directory( path_helper.join(path, part1, part2, part3, part4, part5, part6, part7), ); @@ -35,7 +37,9 @@ extension DirectoryCopyRecursivelyExtension on Directory { await target.create(recursive: true); await for (final file in list(recursive: true)) { final copyTo = path_helper.join( - target.path, path_helper.relative(file.path, from: path)); + target.path, + path_helper.relative(file.path, from: path), + ); if (file is Directory) { await Directory(copyTo).create(recursive: true); } else if (file is File) { @@ -56,11 +60,14 @@ extension DirectoryContainsExtension on Directory { /// Returns a [Future] holding the value. /// /// For the sync method, see [containsSync()]. - Future contains(FileSystemEntity entity, - {bool recursive = false}) async { + Future contains( + FileSystemEntity entity, { + bool recursive = false, + }) async { final entities = list(recursive: recursive); return entities.any( - (element) => FileSystemEntity.identicalSync(entity.path, element.path)); + (element) => FileSystemEntity.identicalSync(entity.path, element.path), + ); } } @@ -76,7 +83,8 @@ extension DirectoryContainsSyncExtension on Directory { bool containsSync(FileSystemEntity entity, {bool recursive = false}) { final entities = listSync(recursive: recursive); return entities.any( - (element) => FileSystemEntity.identicalSync(entity.path, element.path)); + (element) => FileSystemEntity.identicalSync(entity.path, element.path), + ); } } diff --git a/lib/src/io/file.dart b/lib/src/io/file.dart index b7260d9..491f39e 100644 --- a/lib/src/io/file.dart +++ b/lib/src/io/file.dart @@ -26,7 +26,9 @@ extension FileForEachBlockExtension on File { /// /// You can use this function for huge files. Future forEachBlock( - int blockSize, void Function(Uint8List buffer) action) async { + int blockSize, + void Function(Uint8List buffer) action, + ) async { final raf = await open(); // ignore: literal_only_boolean_expressions while (true) { diff --git a/lib/src/iterable.dart b/lib/src/iterable.dart index add8a3b..1b17168 100644 --- a/lib/src/iterable.dart +++ b/lib/src/iterable.dart @@ -600,7 +600,9 @@ extension IterableFilterIndexedTo on Iterable { /// Appends all elements matching the given [predicate] to the given /// [destination]. void filterIndexedTo( - List destination, bool Function(E element, int index) predicate) => + List destination, + bool Function(E element, int index) predicate, + ) => whereIndexedTo(destination, predicate); } @@ -627,7 +629,9 @@ extension IterableFilterNotToIndexed on Iterable { /// Appends all elements not matching the given [predicate] to the given /// [destination]. void filterNotToIndexed( - List destination, bool Function(E element, int index) predicate) => + List destination, + bool Function(E element, int index) predicate, + ) => whereNotToIndexed(destination, predicate); } @@ -639,7 +643,8 @@ extension IterableFilterNotNull on Iterable { extension IterableWhereIndexed on Iterable { /// Returns all elements that satisfy the given [predicate]. Iterable whereIndexed( - bool Function(E element, int index) predicate) sync* { + bool Function(E element, int index) predicate, + ) sync* { var index = 0; for (final element in this) { if (predicate(element, index++)) { @@ -665,7 +670,9 @@ extension IterableWhereIndexedTo on Iterable { /// Appends all elements matching the given [predicate] to the given /// [destination]. void whereIndexedTo( - List destination, bool Function(E element, int index) predicate) { + List destination, + bool Function(E element, int index) predicate, + ) { var index = 0; for (final element in this) { if (predicate(element, index++)) { @@ -689,7 +696,8 @@ extension IterableWhereNot on Iterable { extension IterableWhereNotIndexed on Iterable { /// Returns all elements not matching the given [predicate]. Iterable whereNotIndexed( - bool Function(E element, int index) predicate) sync* { + bool Function(E element, int index) predicate, + ) sync* { var index = 0; for (final element in this) { if (!predicate(element, index++)) { @@ -715,7 +723,9 @@ extension IterableWhereNotToIndexed on Iterable { /// Appends all elements not matching the given [predicate] to the given /// [destination]. void whereNotToIndexed( - List destination, bool Function(E element, int index) predicate) { + List destination, + bool Function(E element, int index) predicate, + ) { var index = 0; for (final element in this) { if (!predicate(element, index++)) { diff --git a/lib/src/map.dart b/lib/src/map.dart index afd2582..5550e0d 100644 --- a/lib/src/map.dart +++ b/lib/src/map.dart @@ -156,7 +156,8 @@ extension MapMapValues on Map { extension MapMaxBy on Map { /// Returns the first entry yielding the largest value of the given function or `null` if there are no entries. MapEntry? maxBy( - R Function(MapEntry) selector) { + R Function(MapEntry) selector, + ) { final i = entries.iterator; if (!i.moveNext()) return null; MapEntry maxElement = i.current; @@ -192,7 +193,8 @@ extension MapMaxWith on Map { extension MapMinBy on Map { /// Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. MapEntry? minBy( - R Function(MapEntry) selector) { + R Function(MapEntry) selector, + ) { final i = entries.iterator; if (!i.moveNext()) return null; MapEntry minElement = i.current; @@ -278,7 +280,7 @@ class Pair { final B second; @override - String toString() => "($first, $second)"; + String toString() => '($first, $second)'; @override bool operator ==(Object other) => diff --git a/lib/src/num.dart b/lib/src/num.dart index 8dd8bb8..1cd9d49 100644 --- a/lib/src/num.dart +++ b/lib/src/num.dart @@ -16,8 +16,10 @@ extension NumCoerceInExtension on T { /// ```` T coerceIn(T minimumValue, [T? maximumValue]) { if (maximumValue != null && minimumValue > maximumValue) { - throw ArgumentError('Cannot coerce value to an empty range: ' - 'maximum $maximumValue is less than minimum $minimumValue.'); + throw ArgumentError( + 'Cannot coerce value to an empty range: ' + 'maximum $maximumValue is less than minimum $minimumValue.', + ); } if (this < minimumValue) return minimumValue; if (maximumValue != null && this > maximumValue) return maximumValue; diff --git a/lib/src/sorted_list.dart b/lib/src/sorted_list.dart index 907d805..2a705ed 100644 --- a/lib/src/sorted_list.dart +++ b/lib/src/sorted_list.dart @@ -1,8 +1,10 @@ part of dartx; Comparator _getComparator( - int order, Comparable Function(E element) selector, - {Comparator? parent}) { + int order, + Comparable Function(E element) selector, { + Comparator? parent, +}) { int newComparator(E a, E b) { return order * selector(a).compareTo(selector(b)); } @@ -190,8 +192,12 @@ abstract class _DelegatingList extends _DelegatingIterable delegate.setAll(index, iterable); @override - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) => + void setRange( + int start, + int end, + Iterable iterable, [ + int skipCount = 0, + ]) => delegate.setRange(start, end, iterable, skipCount); @override diff --git a/test/comparable_test.dart b/test/comparable_test.dart index 6c03e97..1ae8c60 100644 --- a/test/comparable_test.dart +++ b/test/comparable_test.dart @@ -14,47 +14,61 @@ class _WrappedInt implements Comparable<_WrappedInt> { void main() { group('ComparableX', () { test('.coerceIn()', () { - expect(DateTime(1984, 11, 19).coerceIn(DateTime(1984, 11, 1)), - DateTime(1984, 11, 19)); expect( - DateTime(1984, 11, 19).coerceIn( - DateTime(1984, 11, 1), - DateTime(1984, 11, 20), - ), - DateTime(1984, 11, 19)); + DateTime(1984, 11, 19).coerceIn(DateTime(1984, 11, 1)), + DateTime(1984, 11, 19), + ); expect( - DateTime(1984, 10, 28).coerceIn( - DateTime(1984, 11, 1), - DateTime(1984, 11, 20), - ), - DateTime(1984, 11, 1)); + DateTime(1984, 11, 19).coerceIn( + DateTime(1984, 11, 1), + DateTime(1984, 11, 20), + ), + DateTime(1984, 11, 19), + ); expect( - DateTime(1984, 12, 1).coerceIn( - DateTime(1984, 11, 1), - DateTime(1984, 11, 20), - ), - DateTime(1984, 11, 20)); + DateTime(1984, 10, 28).coerceIn( + DateTime(1984, 11, 1), + DateTime(1984, 11, 20), + ), + DateTime(1984, 11, 1), + ); + expect( + DateTime(1984, 12, 1).coerceIn( + DateTime(1984, 11, 1), + DateTime(1984, 11, 20), + ), + DateTime(1984, 11, 20), + ); expect(() => 10.coerceIn(3, 2), throwsArgumentError); expect( - () => DateTime.now().coerceIn( - DateTime(1984, 11, 20), - DateTime(1984, 11, 1), - ), - throwsArgumentError); + () => DateTime.now().coerceIn( + DateTime(1984, 11, 20), + DateTime(1984, 11, 1), + ), + throwsArgumentError, + ); }); test('.coerceAtLeast()', () { - expect(DateTime(1984, 11, 19).coerceAtLeast(DateTime(1984, 1, 1)), - DateTime(1984, 11, 19)); - expect(DateTime(1984, 11, 19).coerceAtLeast(DateTime(1984, 11, 20)), - DateTime(1984, 11, 20)); + expect( + DateTime(1984, 11, 19).coerceAtLeast(DateTime(1984, 1, 1)), + DateTime(1984, 11, 19), + ); + expect( + DateTime(1984, 11, 19).coerceAtLeast(DateTime(1984, 11, 20)), + DateTime(1984, 11, 20), + ); }); test('.coerceAtMost()', () { - expect(DateTime(1984, 11, 19).coerceAtMost(DateTime(1984, 11, 20)), - DateTime(1984, 11, 19)); - expect(DateTime(1984, 11, 19).coerceAtMost(DateTime(1984, 11, 1)), - DateTime(1984, 11, 1)); + expect( + DateTime(1984, 11, 19).coerceAtMost(DateTime(1984, 11, 20)), + DateTime(1984, 11, 19), + ); + expect( + DateTime(1984, 11, 19).coerceAtMost(DateTime(1984, 11, 1)), + DateTime(1984, 11, 1), + ); }); test('.between()', () { diff --git a/test/directory.dart b/test/directory.dart index 9c8a5c3..950d263 100644 --- a/test/directory.dart +++ b/test/directory.dart @@ -1,8 +1,8 @@ import 'dart:io'; +import 'package:dartx/dartx_io.dart'; import 'package:path/path.dart'; import 'package:test/test.dart'; -import 'package:dartx/dartx_io.dart'; void main() { group('Directory', () { diff --git a/test/file_system_entity.dart b/test/file_system_entity.dart index 2a1eed9..1f06f58 100644 --- a/test/file_system_entity.dart +++ b/test/file_system_entity.dart @@ -1,7 +1,7 @@ import 'dart:io'; -import 'package:test/test.dart'; import 'package:dartx/dartx_io.dart'; +import 'package:test/test.dart'; void main() { group('FileSystemEntity', () { diff --git a/test/function_test.dart b/test/function_test.dart index 06a1333..3c9b5ab 100644 --- a/test/function_test.dart +++ b/test/function_test.dart @@ -1,6 +1,6 @@ // ignore_for_file: prefer_function_declarations_over_variables -import 'package:test/test.dart'; import 'package:dartx/dartx.dart'; +import 'package:test/test.dart'; void main() { group('Function', () { diff --git a/test/iterable_num_test.dart b/test/iterable_num_test.dart index 0595c81..bce9ed1 100644 --- a/test/iterable_num_test.dart +++ b/test/iterable_num_test.dart @@ -1,5 +1,5 @@ -import 'package:test/test.dart'; import 'package:dartx/dartx.dart'; +import 'package:test/test.dart'; void main() { group('IterableNumX', () { diff --git a/test/iterable_test.dart b/test/iterable_test.dart index 4497db3..1017278 100644 --- a/test/iterable_test.dart +++ b/test/iterable_test.dart @@ -196,22 +196,27 @@ void main() { test('.sortedBy()', () { expect([].sortedBy((it) => 1), []); - expect(['this', 'is', 'a', 'abcde'].sortedBy((it) => it.length), - ['a', 'is', 'this', 'abcde']); + expect( + ['this', 'is', 'a', 'abcde'].sortedBy((it) => it.length), + ['a', 'is', 'this', 'abcde'], + ); }); test('.sortedWith()', () { expect([].sortedWith((a, b) => 0), []); expect( - ['this', 'is', 'a', 'abcde'] - .sortedWith((a, b) => a.length.compareTo(b.length)), - ['a', 'is', 'this', 'abcde']); + ['this', 'is', 'a', 'abcde'] + .sortedWith((a, b) => a.length.compareTo(b.length)), + ['a', 'is', 'this', 'abcde'], + ); }); test('.sortedByDescending()', () { expect([].sortedByDescending((it) => 1), []); - expect(['this', 'is', 'a', 'abcde'].sortedByDescending((it) => it.length), - ['abcde', 'this', 'is', 'a']); + expect( + ['this', 'is', 'a', 'abcde'].sortedByDescending((it) => it.length), + ['abcde', 'this', 'is', 'a'], + ); }); test('.joinToString()', () { @@ -501,28 +506,36 @@ void main() { expect([].mapNotNull((it) => 1), []); expect([1, 2, 3, 4].mapNotNull((it) => null), []); expect( - [1, 2, 3, 4].mapNotNull((it) => it % 2 == 0 ? it * 2 : null), [4, 8]); + [1, 2, 3, 4].mapNotNull((it) => it % 2 == 0 ? it * 2 : null), + [4, 8], + ); }); test('.mapIndexed()', () { expect([].mapIndexed((index, it) => 1), []); - expect([1, 2, 3, 4].mapIndexed((index, it) => null), - [null, null, null, null]); + expect( + [1, 2, 3, 4].mapIndexed((index, it) => null), + [null, null, null, null], + ); expect([5, 4, null, 2].mapIndexed((index, it) => index), [0, 1, 2, 3]); expect( - [1, 2, 3, 4].mapIndexed((index, it) => it % 2 == 0 ? it * 2 : null), - [null, 4, null, 8]); + [1, 2, 3, 4].mapIndexed((index, it) => it % 2 == 0 ? it * 2 : null), + [null, 4, null, 8], + ); }); test('.mapIndexedNotNull()', () { expect([].mapIndexedNotNull((index, it) => 1), []); expect([1, 2, 3, 4].mapIndexedNotNull((index, it) => null), []); - expect([5, 4, null, 2].mapIndexedNotNull((index, it) => index), - [0, 1, 2, 3]); expect( - [1, 2, 3, 4] - .mapIndexedNotNull((index, it) => it % 2 == 0 ? it * 2 : null), - [4, 8]); + [5, 4, null, 2].mapIndexedNotNull((index, it) => index), + [0, 1, 2, 3], + ); + expect( + [1, 2, 3, 4] + .mapIndexedNotNull((index, it) => it % 2 == 0 ? it * 2 : null), + [4, 8], + ); }); test('.onEach()', () { @@ -560,8 +573,10 @@ void main() { expect(list.chunked(1), list.map((it) => [it])); expect(list.chunked(10).length, 5); - expect(list.chunked(10).elementAt(3), - [30, 31, 32, 33, 34, 35, 36, 37, 38, 39]); + expect( + list.chunked(10).elementAt(3), + [30, 31, 32, 33, 34, 35, 36, 37, 38, 39], + ); expect(list.chunked(11).length, 5); expect(list.chunked(11).elementAt(4), [44, 45, 46, 47, 48, 49]); diff --git a/test/list_test.dart b/test/list_test.dart index 7eaaf2f..c9ae991 100644 --- a/test/list_test.dart +++ b/test/list_test.dart @@ -1,5 +1,5 @@ -import 'package:test/test.dart'; import 'package:dartx/dartx.dart'; +import 'package:test/test.dart'; void main() { group('ListX', () { diff --git a/test/map_test.dart b/test/map_test.dart index 3cc487e..1a7eab5 100644 --- a/test/map_test.dart +++ b/test/map_test.dart @@ -1,5 +1,5 @@ -import 'package:test/test.dart'; import 'package:dartx/dartx.dart'; +import 'package:test/test.dart'; void main() { group('MapX', () { @@ -18,7 +18,9 @@ void main() { test('all() empty map', () { final map = {}; expect( - map.none((key, value) => key == 1 && value == 'Bulbasaur'), true); + map.none((key, value) => key == 1 && value == 'Bulbasaur'), + true, + ); expect(map.none((key, value) => false), true); }); }); @@ -37,7 +39,9 @@ void main() { test('any() empty map', () { final map = {}; expect( - map.any((key, value) => key == 1 && value == 'Bulbasaur'), false); + map.any((key, value) => key == 1 && value == 'Bulbasaur'), + false, + ); expect(map.any((key, value) => true), false); expect(map.any((key, value) => false), false); }); @@ -178,7 +182,9 @@ void main() { group('maxWith', () { int _numKeyComparison( - MapEntry value, MapEntry other) { + MapEntry value, + MapEntry other, + ) { return value.key.compareTo(other.key); } @@ -212,7 +218,9 @@ void main() { group('minWith', () { int _numKeyComparison( - MapEntry value, MapEntry other) { + MapEntry value, + MapEntry other, + ) { return value.key.compareTo(other.key); } @@ -305,14 +313,18 @@ void main() { 3: 'Stegosaur', }; expect( - map.none((key, value) => key == 1 && value == 'Bulbasaur'), false); + map.none((key, value) => key == 1 && value == 'Bulbasaur'), + false, + ); expect(map.none((_, value) => value == 'Random text'), true); }); test('none() empty map', () { final map = {}; expect( - map.none((key, value) => key == 1 && value == 'Bulbasaur'), true); + map.none((key, value) => key == 1 && value == 'Bulbasaur'), + true, + ); expect(map.none((key, value) => false), true); }); }); @@ -326,40 +338,46 @@ void main() { }); test('returns values put inside', () { - final pair = Pair('a', 'b'); + const pair = Pair('a', 'b'); expect(pair.first, 'a'); expect(pair.second, 'b'); }); test('equals based on items', () { - final p1 = Pair('a', 'b'); - final p2 = Pair('a', 'b'); + const p1 = Pair('a', 'b'); + const p2 = Pair('a', 'b'); expect(identical(p1, p2), isFalse); expect(p1, p2); - expect(Pair('a', 'b').hashCode, Pair('a', 'b').hashCode); - expect(Pair('a', 'b'), isNot(equals(Pair('a', 'c')))); - expect(Pair('a', 'b').hashCode, isNot(equals(Pair('a', 'c').hashCode))); - expect(Pair('a', 'b'), isNot(equals(Pair('c', 'b')))); - expect(Pair('a', 'b').hashCode, isNot(equals(Pair('c', 'b').hashCode))); - - expect(Pair(null, null), Pair(null, null)); - expect(Pair(null, null).hashCode, Pair(null, null).hashCode); + expect(const Pair('a', 'b').hashCode, const Pair('a', 'b').hashCode); + expect(const Pair('a', 'b'), isNot(equals(const Pair('a', 'c')))); + expect( + const Pair('a', 'b').hashCode, + isNot(equals(const Pair('a', 'c').hashCode)), + ); + expect(const Pair('a', 'b'), isNot(equals(const Pair('c', 'b')))); + expect( + const Pair('a', 'b').hashCode, + isNot(equals(const Pair('c', 'b').hashCode)), + ); + + expect(const Pair(null, null), const Pair(null, null)); + expect(const Pair(null, null).hashCode, const Pair(null, null).hashCode); }); test('toString', () { - expect(Pair('a', 'b').toString(), '(a, b)'); - expect(Pair(null, null).toString(), '(null, null)'); + expect(const Pair('a', 'b').toString(), '(a, b)'); + expect(const Pair(null, null).toString(), '(null, null)'); }); test('construct pair with T1.to(T2)', () { - final Pair pair = Pair('foo', 42); + const Pair pair = Pair('foo', 42); expect(pair.first, 'foo'); expect(pair.second, 42); }); test('toList', () { - final pair = Pair('a', 'b'); + const pair = Pair('a', 'b'); expect(pair.toList(), ['a', 'b']); }); }); diff --git a/test/num_test.dart b/test/num_test.dart index 4cca1c9..0cac808 100644 --- a/test/num_test.dart +++ b/test/num_test.dart @@ -1,7 +1,7 @@ import 'dart:typed_data'; -import 'package:test/test.dart'; import 'package:dartx/dartx.dart'; +import 'package:test/test.dart'; void main() { group('NumX', () { @@ -74,19 +74,27 @@ void main() { group('IntX', () { test('toBytes', () { - expect(123456789.toBytes(), - Uint8List.fromList([0, 0, 0, 0, 7, 91, 205, 21])); - expect(123456789.toBytes(Endian.little), - Uint8List.fromList([21, 205, 91, 7, 0, 0, 0, 0])); + expect( + 123456789.toBytes(), + Uint8List.fromList([0, 0, 0, 0, 7, 91, 205, 21]), + ); + expect( + 123456789.toBytes(Endian.little), + Uint8List.fromList([21, 205, 91, 7, 0, 0, 0, 0]), + ); }); }); group('DoubleX', () { test('toBytes', () { - expect(123.456.toBytes(), - Uint8List.fromList([64, 94, 221, 47, 26, 159, 190, 119])); - expect(123.455.toBytes(Endian.little), - Uint8List.fromList([133, 235, 81, 184, 30, 221, 94, 64])); + expect( + 123.456.toBytes(), + Uint8List.fromList([64, 94, 221, 47, 26, 159, 190, 119]), + ); + expect( + 123.455.toBytes(Endian.little), + Uint8List.fromList([133, 235, 81, 184, 30, 221, 94, 64]), + ); }); }); } diff --git a/test/range_test.dart b/test/range_test.dart index a2dfe7e..39f0545 100644 --- a/test/range_test.dart +++ b/test/range_test.dart @@ -62,42 +62,64 @@ void main() { }); test('endInclusive', () { expect( - DateTime(1995).rangeTo(DateTime(2020)).endInclusive, DateTime(2020)); + DateTime(1995).rangeTo(DateTime(2020)).endInclusive, + DateTime(2020), + ); expect( - DateTime(1995).rangeTo(DateTime(2020)).endInclusive, isA()); + DateTime(1995).rangeTo(DateTime(2020)).endInclusive, + isA(), + ); }); test('contains (upwards)', () { - expect(DateTime(1995).rangeTo(DateTime(2020)).contains(DateTime(2016)), - isTrue); - expect(DateTime(1995).rangeTo(DateTime(2020)).contains(DateTime(1988)), - isFalse); + expect( + DateTime(1995).rangeTo(DateTime(2020)).contains(DateTime(2016)), + isTrue, + ); + expect( + DateTime(1995).rangeTo(DateTime(2020)).contains(DateTime(1988)), + isFalse, + ); }); test('contains (downwards)', () { - expect(DateTime(2020).rangeTo(DateTime(1995)).contains(DateTime(2016)), - isTrue); - expect(DateTime(2020).rangeTo(DateTime(1995)).contains(DateTime(1988)), - isFalse); + expect( + DateTime(2020).rangeTo(DateTime(1995)).contains(DateTime(2016)), + isTrue, + ); + expect( + DateTime(2020).rangeTo(DateTime(1995)).contains(DateTime(1988)), + isFalse, + ); }); test('rangeTo returns ComparableRange', () { - expect(DateTime(1995).rangeTo(DateTime(2020)), - isA>()); + expect( + DateTime(1995).rangeTo(DateTime(2020)), + isA>(), + ); }); test('hashcode equal no matter the order', () { - expect(DateTime(1995).rangeTo(DateTime(2020)).hashCode, - DateTime(2020).rangeTo(DateTime(1995)).hashCode); + expect( + DateTime(1995).rangeTo(DateTime(2020)).hashCode, + DateTime(2020).rangeTo(DateTime(1995)).hashCode, + ); }); test('equal', () { - expect(DateTime(1995).rangeTo(DateTime(2020)), - DateTime(1995).rangeTo(DateTime(2020))); + expect( + DateTime(1995).rangeTo(DateTime(2020)), + DateTime(1995).rangeTo(DateTime(2020)), + ); expect('a'.rangeTo('b'), 'a'.rangeTo('b')); }); test('not equals when items swapped', () { - expect(DateTime(1995).rangeTo(DateTime(2020)), - isNot(DateTime(2020).rangeTo(DateTime(1995)))); + expect( + DateTime(1995).rangeTo(DateTime(2020)), + isNot(DateTime(2020).rangeTo(DateTime(1995))), + ); }); test('toString', () { - expect(DateTime(1995).rangeTo(DateTime(2020)).toString(), - '1995-01-01 00:00:00.000..2020-01-01 00:00:00.000'); + expect( + DateTime(1995).rangeTo(DateTime(2020)).toString(), + '1995-01-01 00:00:00.000..2020-01-01 00:00:00.000', + ); }); test('alphabetical range', () { final alphabet = 'a'.rangeTo('z'); diff --git a/test/sorted_list_test.dart b/test/sorted_list_test.dart index 1dab414..ee0db1d 100644 --- a/test/sorted_list_test.dart +++ b/test/sorted_list_test.dart @@ -265,12 +265,13 @@ void main() { .thenBy((item) => item.c); expect( - sorted.toList(), - equals(const [ - Item(0, 1, 2), - Item(1, 2, 0), - Item(2, 1, 0), - ])); + sorted.toList(), + equals(const [ + Item(0, 1, 2), + Item(1, 2, 0), + Item(2, 1, 0), + ]), + ); }); }); } diff --git a/test/string_test.dart b/test/string_test.dart index 96422a7..d24d5b3 100644 --- a/test/string_test.dart +++ b/test/string_test.dart @@ -141,15 +141,19 @@ void main() { expect('message digest'.md5, 'f96b697d7cb7938d525a2f31aaf161d0'); expect('เดโŒ›๏ค™ะ‘๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'.md5, 'c7834eff7c967101cfb65b8f6d15ad46'); expect( - 'abcdefghijklmnopqrstuvwxyz'.md5, 'c3fcd3d76192e4007dfb496cca67e13b'); + 'abcdefghijklmnopqrstuvwxyz'.md5, + 'c3fcd3d76192e4007dfb496cca67e13b', + ); expect( - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.md5, - 'd174ab98d277d9f5a5611c2c9f419d9f'); + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.md5, + 'd174ab98d277d9f5a5611c2c9f419d9f', + ); expect( - '12345678901234567890123456789012345678901234567890123456789012' - '345678901234567890' - .md5, - '57edf4a22be3c955ac49da2e2107b67a'); + '12345678901234567890123456789012345678901234567890123456789012' + '345678901234567890' + .md5, + '57edf4a22be3c955ac49da2e2107b67a', + ); }); test('.removePrefix()', () {