date_time_util_test.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:flutter/foundation.dart';
  2. import 'package:photos/core/constants.dart';
  3. import 'package:photos/utils/date_time_util.dart';
  4. import 'package:test/test.dart';
  5. void main() {
  6. test("parseDateTimeFromFile", () {
  7. final List<String> validParsing = [
  8. "IMG-20221109-WA0000",
  9. '''Screenshot_20220807-195908_Firefox''',
  10. '''Screenshot_20220507-195908''',
  11. "2019-02-18 16.00.12-DCMX",
  12. "20221107_231730",
  13. "2020-11-01 02.31.02",
  14. "IMG_20210921_144423",
  15. "2019-10-31 155703",
  16. "IMG_20210921_144423_783",
  17. "Screenshot_2022-06-21-16-51-29-164_newFormat",
  18. ];
  19. for (String val in validParsing) {
  20. final parsedValue = parseDateTimeFromFileNameV2(val);
  21. expect(
  22. parsedValue != null,
  23. true,
  24. reason: "Failed to parse time from $val",
  25. );
  26. if (kDebugMode) {
  27. debugPrint("Parsed $val as ${parsedValue?.toIso8601String()}");
  28. }
  29. }
  30. });
  31. test("verify constants", () {
  32. expect(
  33. jan011991Time,
  34. DateTime(1991, 1, 1).toUtc().microsecondsSinceEpoch,
  35. reason: "constant mismatch",
  36. );
  37. });
  38. }