A whole lot of stuff
This commit is contained in:
parent
faf319322a
commit
ad850d2be6
50 changed files with 3013 additions and 213 deletions
29
test/estimated_refund_test.dart
Normal file
29
test/estimated_refund_test.dart
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fuel_tax_tracker/services/estimated_refund.dart';
|
||||
|
||||
void main() {
|
||||
test('the rate itself is 12.5 cents per gallon', () {
|
||||
expect(moHighwayFuelTaxRefundRatePerGallon, 0.125);
|
||||
});
|
||||
|
||||
test('multiplies whole gallons by the rate', () {
|
||||
expect(estimatedFuelRefund(10), 1.25);
|
||||
expect(estimatedFuelRefund(20), 2.50);
|
||||
expect(estimatedFuelRefund(0), 0);
|
||||
});
|
||||
|
||||
test('rounds fractional gallons to the nearest whole gallon before multiplying', () {
|
||||
// 10.523 rounds up to 11 gallons: 11 * $0.125 = $1.375, floored to $1.37.
|
||||
expect(estimatedFuelRefund(10.523), 1.37);
|
||||
// 10.4 rounds down to 10 gallons: 10 * $0.125 = $1.25 exactly.
|
||||
expect(estimatedFuelRefund(10.4), 1.25);
|
||||
});
|
||||
|
||||
test('rounds the resulting cents down, never up', () {
|
||||
// 1 gallon * $0.125 = $0.125 — rounding to the nearest cent would give
|
||||
// $0.13, but this must floor to $0.12 instead.
|
||||
expect(estimatedFuelRefund(1), 0.12);
|
||||
// 3 gallons * $0.125 = $0.375 — floors to $0.37, not $0.38.
|
||||
expect(estimatedFuelRefund(3), 0.37);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue