28
28
using namespace drizzled;
30
class DateTest : public ::testing::Test {
30
template <typename TemporalType>
31
class DateTest : public ::testing::Test
32
Date sample_date, date_identical_with_sample_date;
33
Date date_before_sample_date, date_after_sample_date;
35
DateTime datetime_identical_with_sample_date;
36
DateTime datetime_before_sample_date, datetime_after_sample_date;
38
Timestamp timestamp_identical_with_sample_date;
39
Timestamp timestamp_before_sample_date, timestamp_after_sample_date;
36
TemporalType identical_with_sample_date, before_sample_date, after_sample_date;
38
void initBeforeIdenticalAfter();
41
40
virtual void SetUp()
43
42
Generator::DateGen::make_date(&sample_date, 2010, 9, 8);
45
Generator::DateGen::make_date(&date_before_sample_date, 1980, 1, 1);
46
Generator::DateGen::make_date(&date_identical_with_sample_date, 2010, 9, 8);
47
Generator::DateGen::make_date(&date_after_sample_date, 2019, 5, 30);
49
Generator::DateTimeGen::make_datetime(&datetime_before_sample_date, 1990, 12, 31, 12, 12, 30, 1000);
50
Generator::DateTimeGen::make_datetime(&datetime_identical_with_sample_date, 2010, 9, 8, 0, 0, 0, 0);
51
Generator::DateTimeGen::make_datetime(&datetime_after_sample_date, 2020, 4, 4, 4, 4, 4, 4000);
53
Generator::TimestampGen::make_timestamp(×tamp_before_sample_date, 1980, 1, 1);
54
Generator::TimestampGen::make_timestamp(×tamp_identical_with_sample_date, 2010, 9, 8);
55
Generator::TimestampGen::make_timestamp(×tamp_after_sample_date, 2019, 5, 30);
43
initBeforeIdenticalAfter();
61
TEST_F(DateTest, operatorEqual_ComparingWithIdencticalDate_ShouldReturn_True)
63
bool result= (sample_date == date_identical_with_sample_date);
65
ASSERT_EQ(true, result);
68
TEST_F(DateTest, operatorEqual_ComparingWithDifferentDate_ShouldReturn_False)
70
bool result= (sample_date == date_before_sample_date);
72
ASSERT_EQ(false, result);
75
TEST_F(DateTest, operatorNotEqual_ComparingWithIdencticalDate_ShouldReturn_False)
77
bool result= (sample_date != date_identical_with_sample_date);
79
ASSERT_EQ(false, result);
82
TEST_F(DateTest, operatorNotEqual_ComparingWithDifferentDate_ShouldReturn_True)
84
bool result= (sample_date != date_before_sample_date);
86
ASSERT_EQ(true, result);
89
TEST_F(DateTest, operatorGreaterThan_ComparingWithIdenticalDate_ShouldReturn_False)
91
bool result= (sample_date > date_identical_with_sample_date);
93
ASSERT_EQ(false, result);
96
TEST_F(DateTest, operatorGreaterThan_ComparingWithLaterDate_ShouldReturn_False)
98
bool result= (sample_date > date_after_sample_date);
100
ASSERT_EQ(false, result);
103
TEST_F(DateTest, operatorGreaterThan_ComparingWithEarlierDate_ShouldReturn_True)
105
bool result= (sample_date > date_before_sample_date);
107
ASSERT_EQ(true, result);
110
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithIdenticalDate_ShouldReturn_True)
112
bool result= (sample_date >= date_identical_with_sample_date);
114
ASSERT_EQ(true, result);
117
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithLaterDate_ShouldReturn_False)
119
bool result= (sample_date >= date_after_sample_date);
121
ASSERT_EQ(false, result);
124
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithEarlierDate_ShouldReturn_True)
126
bool result= (sample_date >= date_before_sample_date);
128
ASSERT_EQ(true, result);
131
TEST_F(DateTest, operatorLessThan_ComparingWithIdenticalDate_ShouldReturn_False)
133
bool result= (sample_date < date_identical_with_sample_date);
135
ASSERT_EQ(false, result);
138
TEST_F(DateTest, operatorLessThan_ComparingWithLaterDate_ShouldReturn_True)
140
bool result= (sample_date < date_after_sample_date);
142
ASSERT_EQ(true, result);
145
TEST_F(DateTest, operatorLessThan_ComparingWithEarlierDate_ShouldReturn_False)
147
bool result= (sample_date < date_before_sample_date);
149
ASSERT_EQ(false, result);
152
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithIdenticalDate_ShouldReturn_True)
154
bool result= (sample_date < date_identical_with_sample_date);
156
ASSERT_EQ(true, result);
159
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithLaterDate_ShouldReturn_True)
161
bool result= (sample_date < date_after_sample_date);
163
ASSERT_EQ(true, result);
166
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithEarlierDate_ShouldReturn_False)
168
bool result= (sample_date < date_before_sample_date);
170
ASSERT_EQ(false, result);
173
/* Date operators for comparing with DateTime */
174
TEST_F(DateTest, operatorEqual_ComparingWithIdencticalDateTime_ShouldReturn_True)
176
bool result= (sample_date == datetime_identical_with_sample_date);
178
ASSERT_EQ(true, result);
181
TEST_F(DateTest, operatorEqual_ComparingWithDifferentDateTime_ShouldReturn_False)
183
bool result= (sample_date == datetime_before_sample_date);
185
ASSERT_EQ(false, result);
188
TEST_F(DateTest, operatorNotEqual_ComparingWithIdencticalDateTime_ShouldReturn_False)
190
bool result= (sample_date != datetime_identical_with_sample_date);
192
ASSERT_EQ(false, result);
195
TEST_F(DateTest, operatorNotEqual_ComparingWithDifferentDateTime_ShouldReturn_True)
197
bool result= (sample_date != datetime_before_sample_date);
199
ASSERT_EQ(true, result);
202
TEST_F(DateTest, operatorGreaterThan_ComparingWithIdenticalDateTime_ShouldReturn_False)
204
bool result= (sample_date > datetime_identical_with_sample_date);
206
ASSERT_EQ(false, result);
209
TEST_F(DateTest, operatorGreaterThan_ComparingWithLaterDateTime_ShouldReturn_False)
211
bool result= (sample_date > datetime_after_sample_date);
213
ASSERT_EQ(false, result);
216
TEST_F(DateTest, operatorGreaterThan_ComparingWithEarlierDateTime_ShouldReturn_True)
218
bool result= (sample_date > datetime_before_sample_date);
220
ASSERT_EQ(true, result);
223
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithIdenticalDateTime_ShouldReturn_True)
225
bool result= (sample_date >= datetime_identical_with_sample_date);
227
ASSERT_EQ(true, result);
230
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithLaterDateTime_ShouldReturn_False)
232
bool result= (sample_date >= datetime_after_sample_date);
234
ASSERT_EQ(false, result);
237
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithEarlierDateTime_ShouldReturn_True)
239
bool result= (sample_date >= datetime_before_sample_date);
241
ASSERT_EQ(true, result);
244
TEST_F(DateTest, operatorLessThan_ComparingWithIdenticalDateTime_ShouldReturn_False)
246
bool result= (sample_date < datetime_identical_with_sample_date);
248
ASSERT_EQ(false, result);
251
TEST_F(DateTest, operatorLessThan_ComparingWithLaterDateTime_ShouldReturn_True)
253
bool result= (sample_date < datetime_after_sample_date);
255
ASSERT_EQ(true, result);
258
TEST_F(DateTest, operatorLessThan_ComparingWithEarlierDateTime_ShouldReturn_False)
260
bool result= (sample_date < datetime_before_sample_date);
262
ASSERT_EQ(false, result);
265
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithIdenticalDateTime_ShouldReturn_True)
267
bool result= (sample_date < datetime_identical_with_sample_date);
269
ASSERT_EQ(true, result);
272
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithLaterDateTime_ShouldReturn_True)
274
bool result= (sample_date < datetime_after_sample_date);
276
ASSERT_EQ(true, result);
279
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithEarlierDateTime_ShouldReturn_False)
281
bool result= (sample_date < datetime_before_sample_date);
283
ASSERT_EQ(false, result);
287
/* Date operators for comparing with Timestamp */
288
TEST_F(DateTest, operatorEqual_ComparingWithIdencticalTimestamp_ShouldReturn_True)
290
bool result= (sample_date == timestamp_identical_with_sample_date);
292
ASSERT_EQ(true, result);
295
TEST_F(DateTest, operatorEqual_ComparingWithDifferentTimestamp_ShouldReturn_False)
297
bool result= (sample_date == timestamp_before_sample_date);
299
ASSERT_EQ(false, result);
302
TEST_F(DateTest, operatorNotEqual_ComparingWithIdencticalTimestamp_ShouldReturn_False)
304
bool result= (sample_date != timestamp_identical_with_sample_date);
306
ASSERT_EQ(false, result);
309
TEST_F(DateTest, operatorNotEqual_ComparingWithDifferentTimestamp_ShouldReturn_True)
311
bool result= (sample_date != timestamp_before_sample_date);
313
ASSERT_EQ(true, result);
316
TEST_F(DateTest, operatorGreaterThan_ComparingWithIdenticalTimestamp_ShouldReturn_False)
318
bool result= (sample_date > timestamp_identical_with_sample_date);
320
ASSERT_EQ(false, result);
323
TEST_F(DateTest, operatorGreaterThan_ComparingWithLaterTimestamp_ShouldReturn_False)
325
bool result= (sample_date > timestamp_after_sample_date);
327
ASSERT_EQ(false, result);
330
TEST_F(DateTest, operatorGreaterThan_ComparingWithEarlierTimestamp_ShouldReturn_True)
332
bool result= (sample_date > timestamp_before_sample_date);
334
ASSERT_EQ(true, result);
337
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithIdenticalTimestamp_ShouldReturn_True)
339
bool result= (sample_date >= timestamp_identical_with_sample_date);
341
ASSERT_EQ(true, result);
344
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithLaterTimestamp_ShouldReturn_False)
346
bool result= (sample_date >= timestamp_after_sample_date);
348
ASSERT_EQ(false, result);
351
TEST_F(DateTest, operatorGreaterThanOrEqual_ComparingWithEarlierTimestamp_ShouldReturn_True)
353
bool result= (sample_date >= timestamp_before_sample_date);
355
ASSERT_EQ(true, result);
358
TEST_F(DateTest, operatorLessThan_ComparingWithIdenticalTimestamp_ShouldReturn_False)
360
bool result= (sample_date < timestamp_identical_with_sample_date);
362
ASSERT_EQ(false, result);
365
TEST_F(DateTest, operatorLessThan_ComparingWithLaterTimestamp_ShouldReturn_True)
367
bool result= (sample_date < timestamp_after_sample_date);
369
ASSERT_EQ(true, result);
372
TEST_F(DateTest, operatorLessThan_ComparingWithEarlierTimestamp_ShouldReturn_False)
374
bool result= (sample_date < timestamp_before_sample_date);
376
ASSERT_EQ(false, result);
379
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithIdenticalTimestamp_ShouldReturn_True)
381
bool result= (sample_date < timestamp_identical_with_sample_date);
383
ASSERT_EQ(true, result);
386
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithLaterTimestamp_ShouldReturn_True)
388
bool result= (sample_date < timestamp_after_sample_date);
390
ASSERT_EQ(true, result);
393
TEST_F(DateTest, operatorLessThanOrEqual_ComparingWithEarlierTimestamp_ShouldReturn_False)
395
bool result= (sample_date < timestamp_before_sample_date);
397
ASSERT_EQ(false, result);
b'\\ No newline at end of file'
47
template<> void DateTest<Date>::initBeforeIdenticalAfter()
49
Generator::DateGen::make_date(&before_sample_date, 1980, 1, 1);
50
Generator::DateGen::make_date(&identical_with_sample_date, 2010, 9, 8);
51
Generator::DateGen::make_date(&after_sample_date, 2019, 5, 30);
54
template<> void DateTest<DateTime>::initBeforeIdenticalAfter()
56
Generator::DateTimeGen::make_datetime(&before_sample_date, 1990, 12, 31, 12, 12, 30, 1000);
57
Generator::DateTimeGen::make_datetime(&identical_with_sample_date, 2010, 9, 8, 0, 0, 0, 0);
58
Generator::DateTimeGen::make_datetime(&after_sample_date, 2020, 4, 4, 4, 4, 4, 4000);
61
template<> void DateTest<Timestamp>::initBeforeIdenticalAfter()
63
Generator::TimestampGen::make_timestamp(&before_sample_date, 1980, 1, 1);
64
Generator::TimestampGen::make_timestamp(&identical_with_sample_date, 2010, 9, 8);
65
Generator::TimestampGen::make_timestamp(&after_sample_date, 2019, 5, 30);
68
typedef ::testing::Types<Date, DateTime, Timestamp> typesForDateTest;
69
TYPED_TEST_CASE(DateTest, typesForDateTest);
71
TYPED_TEST(DateTest, operatorEqual_ComparingWithIdencticalTemporal_ShouldReturn_True)
73
bool result= (this->sample_date == this->identical_with_sample_date);
75
ASSERT_EQ(true, result);
78
TYPED_TEST(DateTest, operatorEqual_ComparingWithDifferentTemporal_ShouldReturn_False)
80
bool result= (this->sample_date == this->before_sample_date);
82
ASSERT_EQ(false, result);
85
TYPED_TEST(DateTest, operatorNotEqual_ComparingWithIdencticalTemporal_ShouldReturn_False)
87
bool result= (this->sample_date != this->identical_with_sample_date);
89
ASSERT_EQ(false, result);
92
TYPED_TEST(DateTest, operatorNotEqual_ComparingWithDifferentTemporal_ShouldReturn_True)
94
bool result= (this->sample_date != this->before_sample_date);
96
ASSERT_EQ(true, result);
99
TYPED_TEST(DateTest, operatorGreaterThan_ComparingWithIdenticalTemporal_ShouldReturn_False)
101
bool result= (this->sample_date > this->identical_with_sample_date);
103
ASSERT_EQ(false, result);
106
TYPED_TEST(DateTest, operatorGreaterThan_ComparingWithLaterTemporal_ShouldReturn_False)
108
bool result= (this->sample_date > this->after_sample_date);
110
ASSERT_EQ(false, result);
113
TYPED_TEST(DateTest, operatorGreaterThan_ComparingWithEarlierTemporal_ShouldReturn_True)
115
bool result= (this->sample_date > this->before_sample_date);
117
ASSERT_EQ(true, result);
120
TYPED_TEST(DateTest, operatorGreaterThanOrEqual_ComparingWithIdenticalTemporal_ShouldReturn_True)
122
bool result= (this->sample_date >= this->identical_with_sample_date);
124
ASSERT_EQ(true, result);
127
TYPED_TEST(DateTest, operatorGreaterThanOrEqual_ComparingWithLaterTemporal_ShouldReturn_False)
129
bool result= (this->sample_date >= this->after_sample_date);
131
ASSERT_EQ(false, result);
134
TYPED_TEST(DateTest, operatorGreaterThanOrEqual_ComparingWithEarlierTemporal_ShouldReturn_True)
136
bool result= (this->sample_date >= this->before_sample_date);
138
ASSERT_EQ(true, result);
141
TYPED_TEST(DateTest, operatorLessThan_ComparingWithIdenticalTemporal_ShouldReturn_False)
143
bool result= (this->sample_date < this->identical_with_sample_date);
145
ASSERT_EQ(false, result);
148
TYPED_TEST(DateTest, operatorLessThan_ComparingWithLaterTemporal_ShouldReturn_True)
150
bool result= (this->sample_date < this->after_sample_date);
152
ASSERT_EQ(true, result);
155
TYPED_TEST(DateTest, operatorLessThan_ComparingWithEarlierTemporal_ShouldReturn_False)
157
bool result= (this->sample_date < this->before_sample_date);
159
ASSERT_EQ(false, result);
162
TYPED_TEST(DateTest, operatorLessThanOrEqual_ComparingWithIdenticalTemporal_ShouldReturn_True)
164
bool result= (this->sample_date < this->identical_with_sample_date);
166
ASSERT_EQ(true, result);
169
TYPED_TEST(DateTest, operatorLessThanOrEqual_ComparingWithLaterTemporal_ShouldReturn_True)
171
bool result= (this->sample_date < this->after_sample_date);
173
ASSERT_EQ(true, result);
176
TYPED_TEST(DateTest, operatorLessThanOrEqual_ComparingWithEarlierTemporal_ShouldReturn_False)
178
bool result= (this->sample_date < this->before_sample_date);
180
ASSERT_EQ(false, result);