LCOV - code coverage report
Current view: top level - lib/src/utils - versions_comparator.dart (source / functions) Hit Total Coverage
Test: merged.info Lines: 9 9 100.0 %
Date: 2024-11-12 07:37:08 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, s) {
      17           4 :     Logs().e(
      18           2 :       '[_isVersionGreaterThanOrEqualTo] Failed to parse version $version',
      19             :       e,
      20             :       s,
      21             :     );
      22             :     return false;
      23             :   }
      24             : }

Generated by: LCOV version 1.14