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

Method Run

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

Source from the content-addressed store, hash-verified

261 }
262
263 void Run(int id, const TimestampValue& now) const {
264 DateTimeFormatContext dt_ctx(fmt);
265 dt_ctx.SetCenturyBreakAndCurrentTime(now);
266
267 stringstream desc;
268 desc << "DateTC [" << id << "]: " << " fmt:" << fmt << " str:" << str
269 << " expected date:" << expected_year << "/" << expected_month << "/"
270 << expected_day;
271
272 bool parse_result = SimpleDateFormatTokenizer::Tokenize(&dt_ctx, PARSE, false);
273 if (fmt_should_fail) {
274 EXPECT_FALSE(parse_result) << desc.str();
275 return;
276 } else {
277 ASSERT_TRUE(parse_result) << desc.str();
278 }
279
280 DateValue cust_dv = DateValue::ParseSimpleDateFormat(str, strlen(str), dt_ctx);
281 if (str_should_fail) {
282 EXPECT_FALSE(cust_dv.IsValid()) << desc.str();
283 return;
284 }
285
286 // Check the date (based on any date format tokens being present)
287 ValidateDate(cust_dv, expected_year, expected_month, expected_day, desc.str());
288
289 // Check formatted date
290 if (!should_format) return;
291
292 string buff = cust_dv.Format(dt_ctx);
293 EXPECT_TRUE(!buff.empty()) << desc.str();
294 EXPECT_LE(buff.length(), dt_ctx.fmt_len) << desc.str();
295 EXPECT_EQ(string(str, strlen(str)), buff) << desc.str();
296 }
297};
298
299TEST(DateTest, ParseFormatEdgeCases) {

Callers 1

TESTFunction · 0.45

Calls 7

ValidateDateFunction · 0.85
strMethod · 0.45
IsValidMethod · 0.45
FormatMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected