LCOV - code coverage report
Current view: top level - src/Tools/Math - utils.cpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 9 13 69.2 %
Date: 2025-07-17 17:04:07 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include <sstream>
       2             : 
       3             : #include "Tools/Exception/exception.hpp"
       4             : #include "Tools/Math/utils.h"
       5             : 
       6             : size_t
       7         269 : spu::tools::find_smallest_common_multiple(const size_t a, const size_t b)
       8             : {
       9         269 :     if (a == 0 || b == 0)
      10             :     {
      11           0 :         std::stringstream message;
      12           0 :         message << "'a' and 'b' have to be strictly positive ('a' = " << a << ", 'b' = " << b << ").";
      13           0 :         throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());
      14           0 :     }
      15             : 
      16         269 :     size_t a2 = a, b2 = b;
      17        5915 :     while (a2 != b2)
      18             :     {
      19        5646 :         if (a2 > b2)
      20        2823 :             b2 += b;
      21        2823 :         else if (a2 < b2)
      22        2823 :             a2 += a;
      23             :     }
      24         269 :     return a2;
      25             : }

Generated by: LCOV version 1.14