Мастер-класс. Подготовительная ступень 2015-2016. / std.check.src.typeinfo.cpp

ru en cn

с начала прошло: 2984 д. 09:38
страница обновлена: 05.12.2023 02:30

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);
}


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