Skip to content

Commit 4e9b663

Browse files
pedroerpfacebook-github-bot
authored andcommitted
Add gtest pretty printer for Timestamp (facebookincubator#9932)
Summary: Pull Request resolved: facebookincubator#9932 Adding pretty printer function to make gtest equality comparison fail with a legible error message. Before: ``` Expected equality of these values: Timestamp(0, 0) Which is: 16-byte object <00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00> dateTrunc("hour", Timestamp(1667725199 ,0)) Which is: (16-byte object <80-69 67-63 00-00 00-00 00-00 00-00 00-00 00-00>) ``` After ``` Expected equality of these values: Timestamp(0, 0) Which is: sec: 0, ns: 0 dateTrunc("hour", Timestamp(1667725199 ,0)) Which is: (sec: 1667721600, ns: 0) ``` Reviewed By: mbasmanova Differential Revision: D57805196 fbshipit-source-id: aef3b690155adacf9fa5bdae6003b163911a8e6c
1 parent cbf9b55 commit 4e9b663

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

velox/type/Timestamp.h

+5
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ struct Timestamp {
413413
return obj;
414414
}
415415

416+
// Pretty printer for gtest.
417+
friend void PrintTo(const Timestamp& timestamp, std::ostream* os) {
418+
*os << "sec: " << timestamp.seconds_ << ", ns: " << timestamp.nanos_;
419+
}
420+
416421
private:
417422
int64_t seconds_;
418423
uint64_t nanos_;

0 commit comments

Comments
 (0)