LCOV - code coverage report
Current view: top level - cell - PhysicalObject.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 12 83.3 %
Date: 2026-03-09 23:46:38 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "PhysicalObject.hpp"
       2             : #include "ExceptionWithLocation.hpp"
       3             : #include "MathUtils.hpp"
       4             : 
       5             : #include <cmath>
       6             : 
       7             : namespace cell
       8             : {
       9             : 
      10         330 : void PhysicalObject::setVelocity(const Vector2d& velocity)
      11             : {
      12             : #ifdef DEBUG
      13         330 :     if (isNanOrInf(velocity))
      14           0 :         throw ExceptionWithLocation("Trying to assign an invalid value to velocity");
      15             : #endif
      16         330 :     velocity_ = velocity;
      17         330 : }
      18             : 
      19         350 : void PhysicalObject::setPosition(const Vector2d& position)
      20             : {
      21             : #ifdef DEBUG
      22         350 :     if (isNanOrInf(position))
      23           0 :         throw ExceptionWithLocation("Trying to assign an invalid value to position");
      24             : #endif
      25         350 :     position_ = position;
      26         350 : }
      27             : 
      28         680 : bool PhysicalObject::isNanOrInf(const Vector2d& vec) const
      29             : {
      30         680 :     return std::isnan(vec.x) || std::isnan(vec.y) || std::isinf(vec.x) || std::isinf(vec.y);
      31             : }
      32             : 
      33             : } // namespace cell

Generated by: LCOV version 1.14