| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); | 358 comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); |
| 359 EXPECT_EQ(FieldComparator::SAME, | 359 EXPECT_EQ(FieldComparator::SAME, |
| 360 comparator_.Compare(message_1_, message_2_, | 360 comparator_.Compare(message_1_, message_2_, |
| 361 field_float, -1, -1, NULL)); | 361 field_float, -1, -1, NULL)); |
| 362 EXPECT_EQ(FieldComparator::DIFFERENT, | 362 EXPECT_EQ(FieldComparator::DIFFERENT, |
| 363 comparator_.Compare(message_1_, message_2_, | 363 comparator_.Compare(message_1_, message_2_, |
| 364 field_double, -1, -1, NULL)); | 364 field_double, -1, -1, NULL)); |
| 365 | 365 |
| 366 // +inf should be equal even though they are not technically within margin or | 366 // +inf should be equal even though they are not technically within margin or |
| 367 // fraction. | 367 // fraction. |
| 368 message_1_.set_optional_float(numeric_limits<float>::infinity()); | 368 message_1_.set_optional_float(std::numeric_limits<float>::infinity()); |
| 369 message_2_.set_optional_float(numeric_limits<float>::infinity()); | 369 message_2_.set_optional_float(std::numeric_limits<float>::infinity()); |
| 370 message_1_.set_optional_double(numeric_limits<double>::infinity()); | 370 message_1_.set_optional_double(std::numeric_limits<double>::infinity()); |
| 371 message_2_.set_optional_double(numeric_limits<double>::infinity()); | 371 message_2_.set_optional_double(std::numeric_limits<double>::infinity()); |
| 372 comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); | 372 comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); |
| 373 comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); | 373 comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); |
| 374 EXPECT_EQ(FieldComparator::SAME, | 374 EXPECT_EQ(FieldComparator::SAME, |
| 375 comparator_.Compare(message_1_, message_2_, | 375 comparator_.Compare(message_1_, message_2_, |
| 376 field_float, -1, -1, NULL)); | 376 field_float, -1, -1, NULL)); |
| 377 EXPECT_EQ(FieldComparator::SAME, | 377 EXPECT_EQ(FieldComparator::SAME, |
| 378 comparator_.Compare(message_1_, message_2_, | 378 comparator_.Compare(message_1_, message_2_, |
| 379 field_double, -1, -1, NULL)); | 379 field_double, -1, -1, NULL)); |
| 380 | 380 |
| 381 // -inf should be equal even though they are not technically within margin or | 381 // -inf should be equal even though they are not technically within margin or |
| 382 // fraction. | 382 // fraction. |
| 383 message_1_.set_optional_float(-numeric_limits<float>::infinity()); | 383 message_1_.set_optional_float(-std::numeric_limits<float>::infinity()); |
| 384 message_2_.set_optional_float(-numeric_limits<float>::infinity()); | 384 message_2_.set_optional_float(-std::numeric_limits<float>::infinity()); |
| 385 message_1_.set_optional_double(-numeric_limits<double>::infinity()); | 385 message_1_.set_optional_double(-std::numeric_limits<double>::infinity()); |
| 386 message_2_.set_optional_double(-numeric_limits<double>::infinity()); | 386 message_2_.set_optional_double(-std::numeric_limits<double>::infinity()); |
| 387 comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); | 387 comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); |
| 388 comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); | 388 comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); |
| 389 EXPECT_EQ(FieldComparator::SAME, | 389 EXPECT_EQ(FieldComparator::SAME, |
| 390 comparator_.Compare(message_1_, message_2_, | 390 comparator_.Compare(message_1_, message_2_, |
| 391 field_float, -1, -1, NULL)); | 391 field_float, -1, -1, NULL)); |
| 392 EXPECT_EQ(FieldComparator::SAME, | 392 EXPECT_EQ(FieldComparator::SAME, |
| 393 comparator_.Compare(message_1_, message_2_, | 393 comparator_.Compare(message_1_, message_2_, |
| 394 field_double, -1, -1, NULL)); | 394 field_double, -1, -1, NULL)); |
| 395 } | 395 } |
| 396 | 396 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 EXPECT_EQ(FieldComparator::DIFFERENT, | 479 EXPECT_EQ(FieldComparator::DIFFERENT, |
| 480 comparator_.Compare(message_1_, message_2_, field, 1, 1, NULL)); | 480 comparator_.Compare(message_1_, message_2_, field, 1, 1, NULL)); |
| 481 EXPECT_EQ(FieldComparator::SAME, | 481 EXPECT_EQ(FieldComparator::SAME, |
| 482 comparator_.Compare(message_1_, message_2_, field, 1, 0, NULL)); | 482 comparator_.Compare(message_1_, message_2_, field, 1, 0, NULL)); |
| 483 } | 483 } |
| 484 | 484 |
| 485 } // namespace util | 485 } // namespace util |
| 486 } // namespace protobuf | 486 } // namespace protobuf |
| 487 } // namespace | 487 } // namespace |
| 488 } // namespace google | 488 } // namespace google |
| OLD | NEW |