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-03-14 12:33:06 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         242 : spu::tools::find_smallest_common_multiple(const size_t a, const size_t b)
       8             : {
       9         242 :     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         242 :     size_t a2 = a, b2 = b;
      17        4926 :     while (a2 != b2)
      18             :     {
      19        4684 :         if (a2 > b2)
      20        2342 :             b2 += b;
      21        2342 :         else if (a2 < b2)
      22        2342 :             a2 += a;
      23             :     }
      24         242 :     return a2;
      25             : }

Generated by: LCOV version 1.14