Skip to content

Commit

Permalink
rename number format function (#8136)
Browse files Browse the repository at this point in the history
  • Loading branch information
szakarias authored Oct 11, 2024
1 parent f88f7b0 commit 591b8b2
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions pkg/_pub_shared/test/format/number_format_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,39 @@ void main() {
});

test('Significant digit 0-999', () {
expect(computeWith3SignificantDigits(0), (value: '0', suffix: ''));
expect(computeWith3SignificantDigits(1), (value: '1', suffix: ''));
expect(computeWith3SignificantDigits(23), (value: '23', suffix: ''));
expect(computeWith3SignificantDigits(999), (value: '999', suffix: ''));
expect(formatWith3SignificantDigits(0), (value: '0', suffix: ''));
expect(formatWith3SignificantDigits(1), (value: '1', suffix: ''));
expect(formatWith3SignificantDigits(23), (value: '23', suffix: ''));
expect(formatWith3SignificantDigits(999), (value: '999', suffix: ''));
});

test('Significant digit 1000-999499', () {
expect(computeWith3SignificantDigits(1000), (value: '1.00', suffix: 'k'));
expect(computeWith3SignificantDigits(1049), (value: '1.05', suffix: 'k'));
expect(computeWith3SignificantDigits(1051), (value: '1.05', suffix: 'k'));
expect(computeWith3SignificantDigits(1100), (value: '1.10', suffix: 'k'));
expect(computeWith3SignificantDigits(9500), (value: '9.50', suffix: 'k'));
expect(computeWith3SignificantDigits(99500), (value: '99.5', suffix: 'k'));
expect(computeWith3SignificantDigits(100490), (value: '100', suffix: 'k'));
expect(computeWith3SignificantDigits(100500), (value: '101', suffix: 'k'));
expect(computeWith3SignificantDigits(199500), (value: '200', suffix: 'k'));
expect(computeWith3SignificantDigits(999499), (value: '999', suffix: 'k'));
expect(formatWith3SignificantDigits(1000), (value: '1.00', suffix: 'k'));
expect(formatWith3SignificantDigits(1049), (value: '1.05', suffix: 'k'));
expect(formatWith3SignificantDigits(1051), (value: '1.05', suffix: 'k'));
expect(formatWith3SignificantDigits(1100), (value: '1.10', suffix: 'k'));
expect(formatWith3SignificantDigits(9500), (value: '9.50', suffix: 'k'));
expect(formatWith3SignificantDigits(99500), (value: '99.5', suffix: 'k'));
expect(formatWith3SignificantDigits(100490), (value: '100', suffix: 'k'));
expect(formatWith3SignificantDigits(100500), (value: '101', suffix: 'k'));
expect(formatWith3SignificantDigits(199500), (value: '200', suffix: 'k'));
expect(formatWith3SignificantDigits(999499), (value: '999', suffix: 'k'));
});

test('Significant digit 999500-100000000', () {
expect(computeWith3SignificantDigits(999500), (value: '1.00', suffix: 'M'));
expect(computeWith3SignificantDigits(999999), (value: '1.00', suffix: 'M'));
expect(formatWith3SignificantDigits(999500), (value: '1.00', suffix: 'M'));
expect(formatWith3SignificantDigits(999999), (value: '1.00', suffix: 'M'));
expect(
computeWith3SignificantDigits(900000000), (value: '900', suffix: 'M'));
formatWith3SignificantDigits(900000000), (value: '900', suffix: 'M'));
expect(
computeWith3SignificantDigits(999500000), (value: '1.00', suffix: 'B'));
expect(computeWith3SignificantDigits(1009450000),
(value: '1.01', suffix: 'B'));
expect(computeWith3SignificantDigits(1094599999),
(value: '1.09', suffix: 'B'));
expect(computeWith3SignificantDigits(1095000001),
(value: '1.10', suffix: 'B'));
expect(computeWith3SignificantDigits(19000000000),
formatWith3SignificantDigits(999500000), (value: '1.00', suffix: 'B'));
expect(
formatWith3SignificantDigits(1009450000), (value: '1.01', suffix: 'B'));
expect(
formatWith3SignificantDigits(1094599999), (value: '1.09', suffix: 'B'));
expect(
formatWith3SignificantDigits(1095000001), (value: '1.10', suffix: 'B'));
expect(formatWith3SignificantDigits(19000000000),
(value: '19.0', suffix: 'B'));
});
}

0 comments on commit 591b8b2

Please sign in to comment.