+
+namespace folly {
+namespace test {
+
+template <typename T1, typename T2>
+::testing::AssertionResult
+AreWithinSecs(T1 val1, T2 val2, std::chrono::seconds acceptableDeltaSecs) {
+ auto deltaSecs =
+ std::chrono::duration_cast<std::chrono::seconds>(val1 - val2);
+ if (deltaSecs <= acceptableDeltaSecs &&
+ deltaSecs >= -1 * acceptableDeltaSecs) {
+ return ::testing::AssertionSuccess();
+ } else {
+ return ::testing::AssertionFailure()
+ << val1.count() << " and " << val2.count() << " are not within "
+ << acceptableDeltaSecs.count() << " secs of each other";
+ }
+}
+}
+}