MCPcopy Create free account
hub / github.com/apache/impala / DateFormatTC

Class DateFormatTC

be/src/runtime/date-test.cc:479–513  ·  view source on GitHub ↗

Used to test custom date output test cases i.e. date value -> string.

Source from the content-addressed store, hash-verified

477
478// Used to test custom date output test cases i.e. date value -> string.
479struct DateFormatTC {
480 const int32_t days_since_epoch;
481 const char* fmt;
482 const char* str;
483 bool should_fail;
484
485 DateFormatTC(int32_t days_since_epoch, const char* fmt, const char* str,
486 bool should_fail = false)
487 : days_since_epoch(days_since_epoch),
488 fmt(fmt),
489 str(str),
490 should_fail(should_fail) {
491 }
492
493 void Run(int id, const TimestampValue& now) const {
494 DateTimeFormatContext dt_ctx(fmt);
495 dt_ctx.SetCenturyBreakAndCurrentTime(now);
496
497 stringstream desc;
498 desc << "DateFormatTC [" << id << "]: " << "days_since_epoch:" << days_since_epoch
499 << " fmt:" << fmt << " str:" << str;
500
501 ASSERT_TRUE(SimpleDateFormatTokenizer::Tokenize(&dt_ctx, PARSE, false)) << desc.str();
502
503 const DateValue cust_dv(days_since_epoch);
504 EXPECT_TRUE(cust_dv.IsValid()) << desc.str();
505 EXPECT_GE(dt_ctx.fmt_out_len, dt_ctx.fmt_len) << desc.str();
506
507 string buff = cust_dv.Format(dt_ctx);
508 EXPECT_TRUE(!buff.empty()) << desc.str();
509 EXPECT_LE(buff.length(), dt_ctx.fmt_out_len) << desc.str();
510 EXPECT_EQ(buff, string(str, strlen(str))) << desc.str();
511 }
512
513};
514
515TEST(DateTest, FormatComplexFormats) {
516 const TimestampValue now(date(1980, 2, 28), time_duration(16, 14, 24));

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68