LCOV - code coverage report
Current view: top level - cell - DiscType.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 23 28 82.1 %
Date: 2025-12-06 00:15:40 Functions: 7 8 87.5 %

          Line data    Source code
       1             : #include "DiscType.hpp"
       2             : #include "ExceptionWithLocation.hpp"
       3             : #include "MathUtils.hpp"
       4             : 
       5             : namespace cell
       6             : {
       7             : 
       8          45 : DiscType::DiscType(const std::string& name, Radius radius, Mass mass)
       9             : {
      10          45 :     setName(name);
      11          45 :     setRadius(radius.value);
      12          45 :     setMass(mass.value);
      13          45 : }
      14             : 
      15         420 : const std::string& DiscType::getName() const
      16             : {
      17         420 :     return name_;
      18             : }
      19             : 
      20          45 : void DiscType::setName(const std::string& name)
      21             : {
      22          45 :     if (name.empty())
      23           0 :         throw ExceptionWithLocation("Disc type name cannot be empty");
      24             : 
      25          45 :     name_ = name;
      26          45 : }
      27             : 
      28         280 : double DiscType::getRadius() const
      29             : {
      30         280 :     return radius_;
      31             : }
      32             : 
      33          45 : void DiscType::setRadius(double radius)
      34             : {
      35          45 :     if (radius <= 0)
      36           0 :         throw ExceptionWithLocation("Disc type radius must be positive");
      37             : 
      38          45 :     radius_ = radius;
      39          45 : }
      40             : 
      41          62 : double DiscType::getMass() const
      42             : {
      43          62 :     return mass_;
      44             : }
      45             : 
      46          45 : void DiscType::setMass(double mass)
      47             : {
      48          45 :     if (mass <= 0)
      49           0 :         throw ExceptionWithLocation("Disc type mass must be positive");
      50             : 
      51          45 :     mass_ = mass;
      52          45 : }
      53             : 
      54           0 : bool DiscType::operator==(const DiscType& other) const
      55             : {
      56           0 :     return name_ == other.name_ && radius_ == other.radius_ && mass_ == other.mass_;
      57             : }
      58             : 
      59             : } // namespace cell

Generated by: LCOV version 1.14