From c8284338aa5831aca3a7822787afcb9a316a7ebb Mon Sep 17 00:00:00 2001 From: misha Date: Wed, 15 Apr 2026 16:27:27 +0300 Subject: [PATCH] feat(image_compress_utility): adde test for corupted images --- .../image_compress_utility_test.dart | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/core/image_compressing/image_compress_utility_test.dart b/test/core/image_compressing/image_compress_utility_test.dart index 9f619520..456543f2 100644 --- a/test/core/image_compressing/image_compress_utility_test.dart +++ b/test/core/image_compressing/image_compress_utility_test.dart @@ -426,5 +426,27 @@ void main() { } } }); + + test('compressFile - does not crash on corrupted image', () async { + final file = File('corrupted.jpg'); + + try { + await file.writeAsBytes([ + 0xFF, 0xD8, 0xFF, 0xE0, + 0x00, 0x10, + 0x4A, 0x46, 0x49, 0x46, + 0xFF, 0xDA, + ]); + + final result = await ImageCompressUtility.compressFile(file); + + expect(result, isA()); + expect(result.path, file.path); + } finally { + if (await file.exists()) { + await file.delete(); + } + } + }); }); }