Go to the documentation of this file.
52 : float_comparison_(EXACT),
53 treat_nan_as_equal_(
false),
54 has_default_tolerance_(
false) {}
65 switch (
field->cpp_type()) {
66 #define COMPARE_FIELD(METHOD) \
67 if (field->is_repeated()) { \
68 return ResultFromBoolean(Compare##METHOD( \
69 *field, reflection_1->GetRepeated##METHOD(message_1, field, index_1), \
70 reflection_2->GetRepeated##METHOD(message_2, field, index_2))); \
72 return ResultFromBoolean( \
73 Compare##METHOD(*field, reflection_1->Get##METHOD(message_1, field), \
74 reflection_2->Get##METHOD(message_2, field))); \
76 break; // Make sure no fall-through is introduced.
91 if (
field->is_repeated()) {
99 message_1,
field, index_1, &scratch1),
101 message_2,
field, index_2, &scratch2)));
125 <<
" of CppType = " <<
field->cpp_type();
134 return differencer->
Compare(message1, message2,
149 <<
"Field has to be float or double type. Field name is: "
150 <<
field->full_name();
155 double value_1,
double value_2) {
166 float value_1,
float value_2) {
170 template <
typename T>
172 T value_1,
T value_2) {
173 if (value_1 == value_2) {
193 if (tolerance ==
NULL) {
200 value_1, value_2,
static_cast<T>(tolerance->
fraction),
201 static_cast<T>(tolerance->
margin));
207 bool boolean_result)
const {
unsigned long long int UInt64
const std::string & GetStringReference(const Message &message, const FieldDescriptor *field, std::string *scratch) const
bool CompareDouble(const FieldDescriptor &field, double value_1, double value_2)
ComparisonResult ResultFromBoolean(bool boolean_result) const
static bool WithinFractionOrMargin(const T x, const T y, const T fraction, const T margin)
virtual ~FieldComparator()
const std::string & GetRepeatedStringReference(const Message &message, const FieldDescriptor *field, int index, std::string *scratch) const
const Reflection * GetReflection() const
GLsizei const GLchar *const * string
~DefaultFieldComparator() override
TypeWithSize< 4 >::Int Int32
#define T(upbtypeconst, upbtype, ctype, default_value)
FloatingPoint< double > Double
TypeWithSize< 4 >::UInt UInt32
const Collection::value_type::second_type * FindOrNull(const Collection &collection, const typename Collection::value_type::first_type &key)
FloatComparison float_comparison_
void SetFractionAndMargin(const FieldDescriptor *field, double fraction, double margin)
ToleranceMap map_tolerance_
FloatingPoint< float > Float
bool Compare(const Message &message1, const Message &message2)
#define GOOGLE_LOG(LEVEL)
std::vector< MessageDifferencer::SpecificField > * parent_fields() const
const FieldDescriptor * field
Tolerance default_tolerance_
bool CompareFloat(const FieldDescriptor &field, float value_1, float value_2)
#define GOOGLE_CHECK(EXPRESSION)
bool CompareEnum(const FieldDescriptor &field, const EnumValueDescriptor *value_1, const EnumValueDescriptor *value_2)
void SetDefaultFractionAndMargin(double fraction, double margin)
static bool AlmostEquals(T a, T b)
ComparisonResult Compare(const Message &message_1, const Message &message_2, const FieldDescriptor *field, int index_1, int index_2, const util::FieldContext *field_context) override
bool CompareDoubleOrFloat(const FieldDescriptor &field, T value_1, T value_2)
bool has_default_tolerance_
bool CompareString(const FieldDescriptor &, const std::string &value_1, const std::string &value_2)
#define COMPARE_FIELD(METHOD)
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:51