LCOV - code coverage report
Current view: top level - lib/src/utils - versions_comparator.dart (source / functions) Coverage Total Hit
Test: merged.info Lines: 100.0 % 9 9
Test Date: 2025-01-14 13:39:53 Functions: - 0 0

            Line data    Source code
       1              : import 'package:matrix/matrix_api_lite/utils/logs.dart';
       2              : 
       3            8 : bool isVersionGreaterThanOrEqualTo(String version, String target) {
       4              :   try {
       5              :     final versionParts =
       6           32 :         version.substring(1).split('.').map(int.parse).toList();
       7           32 :     final targetParts = target.substring(1).split('.').map(int.parse).toList();
       8              : 
       9           24 :     for (int i = 0; i < versionParts.length; i++) {
      10           16 :       if (i >= targetParts.length) return true; // reached the end, both equal
      11           24 :       if (versionParts[i] > targetParts[i]) return true; // ver greater
      12           24 :       if (versionParts[i] < targetParts[i]) return false; // tar greater
      13              :     }
      14              : 
      15              :     return true;
      16              :   } catch (e) {
      17            4 :     Logs().w(
      18            2 :       '[_isVersionGreaterThanOrEqualTo] Failed to parse version $version',
      19              :       e,
      20              :     );
      21              :     return false;
      22              :   }
      23              : }
        

Generated by: LCOV version 2.0-1