// This test intentianally contains failed expectation. Run it manually with // `--gtest_also_run_disabled_tests` flag to check how error message looks like // in various scenarios.
TEST(NearMatcherTest, DISABLED_PrintsDetailedError) {
EXPECT_THAT(Timestamp::Millis(5), Near(Timestamp::Millis(10)));
EXPECT_THAT(Timestamp::Millis(15), Near(Timestamp::Millis(10)));
EXPECT_THAT(Timestamp::MinusInfinity(),
Near(Timestamp::Millis(10), TimeDelta::Millis(20)));
TEST(NearMatcherTest, CanMatchTypesWrappedIntoOptional) { // nullopt is less than any non-optional and thus always fails the match.
EXPECT_THAT(std::optional<Timestamp>(std::nullopt), Not(Near(Timestamp::Seconds(1), TimeDelta::Millis(10))));
// Check lower bound behave as usual when `max_error.us() == expected.us()`
EXPECT_THAT(Timestamp::Micros(1),
Near(Timestamp::Millis(10), TimeDelta::Millis(10)));
EXPECT_THAT(Timestamp::Zero(), Not(Near(Timestamp::Millis(10), TimeDelta::Millis(10))));
// max_error.us() > expected.us() scenario shouldn't compare with negative // `Timestamp` values while they are invalid.
EXPECT_THAT(Timestamp::Micros(1),
Near(Timestamp::Millis(10), TimeDelta::Millis(11)));
EXPECT_THAT(Timestamp::Zero(),
Near(Timestamp::Millis(10), TimeDelta::Millis(11)));
// Some values still can be too small when lower bound is below zero.
EXPECT_THAT(Timestamp::MinusInfinity(), Not(Near(Timestamp::Millis(10), TimeDelta::Millis(11))));
EXPECT_THAT(std::optional<Timestamp>(std::nullopt), Not(Near(Timestamp::Millis(10), TimeDelta::Millis(11))));
// Checks on the upper bounds should work in `max_error.us() > expected.us()` // scenario same as in more common 'max_error.us() <= expected.us()` scenario.
EXPECT_THAT(Timestamp::Micros(20'999),
Near(Timestamp::Millis(10), TimeDelta::Millis(11)));
EXPECT_THAT(Timestamp::Millis(21), Not(Near(Timestamp::Millis(10), TimeDelta::Millis(11))));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.