ЛШ_2009_02 / std.check.src.typeinfo.cpp

ru en cn

с начала прошло: 5594 д. 12:55
страница обновлена: 16.10.2024 01:24

std.check.src.typeinfo.cpp: src/typeinfo.cpp

#include 
#include 
#include "typeinfo.hpp"


namespace Check
{


const size_t MaxSizeValue = std::numeric_limits::max();


const Difference Difference::Empty = Difference();


#define CHECK_DECLARE_EPSILON(TYPE) \
  TYPE Comparer::epsilon = std::numeric_limits::min()

CHECK_DECLARE_EPSILON(float);
CHECK_DECLARE_EPSILON(double);
CHECK_DECLARE_EPSILON(long double);

#undef CHECK_DECLARE_EPSILON


size_t Comparer::slitWidth = 10;


bool Comparer::compare()
{
  const size_t length = std::min(left.length(), right.length());
  for (diffPos = 0; diffPos < length; ++diffPos)
    if (left[diffPos] != right[diffPos])
      return false;
  return left.length() == right.length();
}


Difference Comparer::difference() const
{
  const std::string first = quote(left, diffPos, slitWidth);
  const std::string second = quote(right, diffPos, slitWidth);
  return Difference(first, second);
}


}
Дальневосточный федеральный университет