61 lines
1.8 KiB
Dart
61 lines
1.8 KiB
Dart
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group('double', () {
|
|
test('default', () {
|
|
expect(NumberFormat().parse("1.234"), 1.234);
|
|
});
|
|
group('decimalPattern', () {
|
|
test('default', () {
|
|
expect(NumberFormat.decimalPattern().parse("1.234"), 1.234);
|
|
});
|
|
test('en', () {
|
|
expect(NumberFormat.decimalPattern("en").parse("1.234,567"), 1.234567);
|
|
});
|
|
test('de', () {
|
|
expect(NumberFormat.decimalPattern("de").parse("1.234,567"), 1234.567);
|
|
});
|
|
});
|
|
group('scientific', () {
|
|
const double expected = 1.2345;
|
|
test('default', () {
|
|
expect(NumberFormat.scientificPattern().parse("123.45E-2"), expected);
|
|
});
|
|
test('en', () {
|
|
expect(
|
|
NumberFormat.scientificPattern("en").parse("123.45E-2"), expected);
|
|
});
|
|
test('de', () {
|
|
expect(
|
|
NumberFormat.scientificPattern("de").parse("123,45E-2"), expected);
|
|
});
|
|
});
|
|
});
|
|
|
|
group('DateTime', () {
|
|
final expectedDateTime = DateTime(2021, 12, 24, 11, 30, 0);
|
|
|
|
test('parse', () {
|
|
expect(DateTime.parse("2021-12-24 11:30:00"), expectedDateTime);
|
|
});
|
|
group('DateFormat', () {
|
|
test('with pattern', () {
|
|
expect(DateFormat("dd.MM.yyyy hh:mm:ss").parse("24.12.2021 11:30:00"),
|
|
expectedDateTime);
|
|
});
|
|
|
|
final expectedDate = DateTime(2021, 12, 24);
|
|
test('yMd("en")', () {
|
|
initializeDateFormatting("en");
|
|
expect(DateFormat.yMd("en").parse("12/24/2021"), expectedDate);
|
|
});
|
|
test('yMd("de")', () {
|
|
initializeDateFormatting("de");
|
|
expect(DateFormat.yMd("de").parse("24.12.2021"), expectedDate);
|
|
});
|
|
});
|
|
});
|
|
}
|