194
195
ASSERT_EQ(DateTime::MAX_STRING_LENGTH - 1 - 7, length);
197
TEST_F(DateTimeTest, from_string_validString_shouldPopulateCorrectly)
199
char valid_string[DateTime::MAX_STRING_LENGTH]= "2010-05-01 08:07:06";
201
init_temporal_formats();
203
result = datetime.from_string(valid_string, DateTime::MAX_STRING_LENGTH - 1);
206
assignDateTimeValues();
208
EXPECT_EQ(2010, years);
209
EXPECT_EQ(5, months);
212
EXPECT_EQ(7, minutes);
213
EXPECT_EQ(6, seconds);
215
deinit_temporal_formats();
218
198
TEST_F(DateTimeTest, to_int64_t)
220
200
Generator::DateTimeGen::make_datetime(&datetime, 2030, 8, 7, 14, 5, 13);
315
295
EXPECT_EQ(6, filled.tm_wday);
316
296
EXPECT_EQ(-1, filled.tm_isdst);
299
TEST_F(DateTimeTest, to_decimal)
301
drizzled::my_decimal to;
302
Generator::DateTimeGen::make_datetime(&datetime, 1987, 6, 13, 5, 10, 13);
304
datetime.to_decimal(&to);
306
ASSERT_EQ(19870,to.buf[0]);
307
ASSERT_EQ(613051013,to.buf[1]);
312
class DateTimeFromStringTest: public ::testing::TestWithParam<const char*>
317
uint32_t years, months, days;
318
uint32_t hours, minutes, seconds;
322
init_temporal_formats();
325
virtual void TearDown()
327
deinit_temporal_formats();
330
void assignDateTimeValues()
332
years = datetime.years();
333
months = datetime.months();
334
days = datetime.days();
335
hours = datetime.hours();
336
minutes = datetime.minutes();
337
seconds = datetime.seconds();
341
TEST_P(DateTimeFromStringTest, from_string_validString_formatsWithDateAndTimePresent_shouldPopulateCorrectly)
343
const char *valid_string = GetParam();
345
result = datetime.from_string(valid_string, strlen(valid_string));
348
assignDateTimeValues();
350
EXPECT_EQ(2010, years);
351
EXPECT_EQ(5, months);
354
EXPECT_EQ(7, minutes);
355
EXPECT_EQ(6, seconds);
358
INSTANTIATE_TEST_CASE_P(FormatsWithDateAndTimePresent, DateTimeFromStringTest,
359
::testing::Values("20100501080706",
360
"2010-05-01 08:07:06",
361
"2010/05/01T08:07:06",
367
TEST_P(DateTimeFromStringTest, from_string_validString_formatsWithDateHourAndMinutePresent_shouldPopulateCorrectly)
369
const char *valid_string = GetParam();
371
result = datetime.from_string(valid_string, strlen(valid_string));
374
assignDateTimeValues();
376
EXPECT_EQ(2010, years);
377
EXPECT_EQ(5, months);
380
EXPECT_EQ(7, minutes);
383
INSTANTIATE_TEST_CASE_P(FormatsWithDateHourAndMinutePresent, DateTimeFromStringTest,
384
::testing::Values("2010-05-01 08:07",