~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/date_test.cc

fix/hack? which makes parameterized tests compile
date format tests
separated tests for format groups in datetime

Show diffs side-by-side

added added

removed removed

Lines of Context:
468
468
 
469
469
  ASSERT_EQ(19870506, to.buf[0]);
470
470
}
 
471
 
 
472
class DateFromStringTest: public ::testing::TestWithParam<const char*>
 
473
{
 
474
  protected:
 
475
    Date date;
 
476
    bool result;
 
477
    uint32_t years, months, days;
 
478
    
 
479
    virtual void SetUp()
 
480
    {
 
481
      init_temporal_formats();
 
482
    }
 
483
    
 
484
    virtual void TearDown()
 
485
    {
 
486
      deinit_temporal_formats();
 
487
    }
 
488
    
 
489
    void assign_date_values()
 
490
    {
 
491
      years= date.years();
 
492
      months= date.months();
 
493
      days= date.days();
 
494
    }
 
495
};
 
496
 
 
497
TEST_P(DateFromStringTest, from_string)
 
498
{
 
499
  const char *valid_string = GetParam();
 
500
  
 
501
  result= date.from_string(valid_string, strlen(valid_string));
 
502
  ASSERT_TRUE(result);
 
503
  
 
504
  assign_date_values();
 
505
  
 
506
  EXPECT_EQ(2010, years);
 
507
  EXPECT_EQ(6, months);
 
508
  EXPECT_EQ(7, days);
 
509
}
 
510
 
 
511
/* TODO:for some reason this was not declared by the macro, needs clarification*/
 
512
testing::internal::ParamGenerator<const char*> gtest_ValidStringDateFromStringTest_EvalGenerator_();
 
513
 
 
514
INSTANTIATE_TEST_CASE_P(ValidString, DateFromStringTest,
 
515
                        ::testing::Values("20100607", /* YYYYMMDD */
 
516
                                          "06/07/2010",/* MM[-/.]DD[-/.]YYYY (US common format)*/
 
517
                                          "10.06.07",/* YY[-/.]MM[-/.]DD */
 
518
                                          "10/6/7",/* YY[-/.][M]M[-/.][D]D */
 
519
                                          "2010-6-7"/* YYYY[-/.][M]M[-/.][D]D */));
 
520
                                          
 
521
 
 
522
                                          
 
 
b'\\ No newline at end of file'