~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/generator.cc

moved shared generators to Temporal
added file for DateTime tests
added tests for DateTime

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
  date->set_days(26);
42
42
}
43
43
 
44
 
void Generator::DateGen::leap_day_in_leap_year(drizzled::Date *date)
 
44
void Generator::TemporalGen::leap_day_in_leap_year(drizzled::Temporal *temporal)
45
45
{
46
 
  date->set_years(2008);
47
 
  date->set_months(2);
48
 
  date->set_days(29);
 
46
  temporal->set_years(2008);
 
47
  temporal->set_months(2);
 
48
  temporal->set_days(29);
49
49
}
50
50
 
51
 
void Generator::DateGen::leap_day_in_non_leap_year(drizzled::Date *date)
 
51
void Generator::TemporalGen::leap_day_in_non_leap_year(drizzled::Temporal *temporal)
52
52
{
53
 
  date->set_years(2010);
54
 
  date->set_months(2);
55
 
  date->set_days(29);
 
53
  temporal->set_years(2010);
 
54
  temporal->set_months(2);
 
55
  temporal->set_days(29);
56
56
}
57
57
 
58
58
void Generator::TimeGen::make_time(drizzled::Time *time,
63
63
  time->set_seconds(seconds);
64
64
}
65
65
 
66
 
void Generator::TimeGen::make_min_time(drizzled::Time *time)
 
66
void Generator::TemporalGen::make_min_time(drizzled::Temporal *temporal)
67
67
{
68
 
  time->set_hours(0);
69
 
  time->set_minutes(0);
70
 
  time->set_seconds(0);
 
68
  temporal->set_hours(0);
 
69
  temporal->set_minutes(0);
 
70
  temporal->set_seconds(0);
71
71
}
72
72
 
73
 
void Generator::TimeGen::make_max_time(drizzled::Time *time)
 
73
void Generator::TemporalGen::make_max_time(drizzled::Temporal *temporal)
74
74
{
75
 
  time->set_hours(23);
76
 
  time->set_minutes(59);
77
 
  time->set_seconds(59);
 
75
  temporal->set_hours(23);
 
76
  temporal->set_minutes(59);
 
77
  temporal->set_seconds(59);
78
78
}
79
79
 
80
80
void Generator::DateTimeGen::make_datetime(drizzled::DateTime *datetime,
81
81
                   uint32_t years, uint32_t months, uint32_t days, uint32_t hours,
82
 
                   uint32_t minutes, uint32_t seconds, uint32_t useconds)
 
82
                   uint32_t minutes, uint32_t seconds)
83
83
{
84
84
  datetime->set_years(years);
85
85
  datetime->set_months(months);
87
87
  datetime->set_hours(hours);
88
88
  datetime->set_minutes(minutes);
89
89
  datetime->set_seconds(seconds);
90
 
  datetime->set_useconds(useconds);
91
90
}                     
92
91
 
 
92
void Generator::DateTimeGen::make_valid_datetime(drizzled::DateTime *datetime)
 
93
{
 
94
  datetime->set_years(1999);
 
95
  datetime->set_months(8);
 
96
  datetime->set_days(15);
 
97
  datetime->set_hours(13);
 
98
  datetime->set_minutes(34);
 
99
  datetime->set_seconds(6);
 
100
}
 
101
 
93
102
void Generator::TimestampGen::make_timestamp(drizzled::Timestamp *timestamp,
94
103
                           uint32_t years, uint32_t months, uint32_t days)
95
104
{