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-09-04 20:26:16 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:matrix/matrix_api_lite/utils/logs.dart';
       2             : 
       3           7 : bool isVersionGreaterThanOrEqualTo(String version, String target) {
       4             :   try {
       5             :     final versionParts =
       6          28 :         version.substring(1).split('.').map(int.parse).toList();
       7          28 :     final targetParts = target.substring(1).split('.').map(int.parse).toList();
       8             : 
       9          21 :     for (int i = 0; i < versionParts.length; i++) {
      10          14 :       if (i >= targetParts.length) return true; // reached the end, both equal
      11          21 :       if (versionParts[i] > targetParts[i]) return true; // ver greater
      12          21 :       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