Last active
May 30, 2025 12:36
-
-
Save jxstxn1/36417ca642fa7dd91a381ba54c3bf99d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter_test/flutter_test.dart'; | |
void main() { | |
test('should round 0.145 to 0.15', () { | |
const value = 0.145; | |
final rounded = value.toStringAsFixed(2); | |
expect(rounded, '0.15'); // actual 0.14 | |
}); | |
test('should round 0.145 to 0.15', () { | |
const value = 0.145; | |
final rounded = (value * 100).round() / 100; | |
expect(rounded, 0.15); // actual 0.14 | |
}); | |
test('should round 1.145 to 0.15', () { | |
const value = 1.145; | |
final rounded = value.toStringAsFixed(2); | |
expect(rounded, '1.15'); | |
}); | |
test('should round 1.145 to 1.15', () { | |
const value = 1.145; | |
final rounded = (value * 100).round() / 100; | |
expect(rounded, 1.15); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment