~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/time_test.cc

this was the first working build, and these changes make almost all the tests pass

removed unnecessary tests
added [init/deinit]_temporal_formats calls in tests
bug fixes in tests
call set_epoch_seconds in generators

disabled tests where the API needs calrification

fixed Timestamp and Date > and >= operators
fixed Time::from_int32_t
changed comment in temporal.h to reflact actual way code is working

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <gtest/gtest.h>
24
24
#include <drizzled/temporal.h>
 
25
#include <drizzled/temporal_format.h>
25
26
 
26
27
#include "generator.h"
27
28
 
139
140
 
140
141
TEST_F(TimeTest, operatorLessThanOrEqual_ComparingWithIdenticalTemporal_ShouldReturn_True)
141
142
{
142
 
  this->result= (this->sample_time < this->identical_with_sample_time);
 
143
  this->result= (this->sample_time <= this->identical_with_sample_time);
143
144
  
144
145
  ASSERT_TRUE(this->result);
145
146
}
146
147
 
147
148
TEST_F(TimeTest, operatorLessThanOrEqual_ComparingWithLaterTemporal_ShouldReturn_True)
148
149
{
149
 
  this->result= (this->sample_time < this->after_sample_time);
 
150
  this->result= (this->sample_time <= this->after_sample_time);
150
151
  
151
152
  ASSERT_TRUE(this->result);
152
153
}
153
154
 
154
155
TEST_F(TimeTest, operatorLessThanOrEqual_ComparingWithEarlierTemporal_ShouldReturn_False)
155
156
{
156
 
  this->result= (this->sample_time < this->before_sample_time);
 
157
  this->result= (this->sample_time <= this->before_sample_time);
157
158
  
158
159
  ASSERT_FALSE(this->result);
159
160
}
231
232
{
232
233
  char valid_string[Time::MAX_STRING_LENGTH]= "18:34:59";
233
234
  uint32_t hours, minutes, seconds;
 
235
 
 
236
  init_temporal_formats();
234
237
  
235
 
  result= sample_time.from_string(valid_string, Time::MAX_STRING_LENGTH);
 
238
  result= sample_time.from_string(valid_string, Time::MAX_STRING_LENGTH - 1);
236
239
  ASSERT_TRUE(result);
237
240
  
238
241
  hours= sample_time.hours();
239
242
  minutes= sample_time.minutes();
240
243
  seconds= sample_time.seconds();
 
244
 
 
245
  deinit_temporal_formats();
241
246
  
242
247
  EXPECT_EQ(18, hours);
243
248
  EXPECT_EQ(34, minutes);
247
252
TEST_F(TimeTest, from_string_invalidString_shouldReturn_False)
248
253
{
249
254
  char invalid_string[Time::MAX_STRING_LENGTH]= "1o:34:59";
 
255
 
 
256
  init_temporal_formats();
 
257
  result= sample_time.from_string(invalid_string, Time::MAX_STRING_LENGTH - 1);
 
258
  deinit_temporal_formats();
250
259
  
251
 
  result= sample_time.from_string(invalid_string, Time::MAX_STRING_LENGTH);
252
260
  ASSERT_FALSE(result);
253
261
}
254
262
 
255
 
TEST_F(TimeTest, from_int32_t_onValueCreatedBy_to_int32_t_shouldProduceOriginalTime)
 
263
TEST_F(TimeTest, to_int32_t)
 
264
{
 
265
  int32_t representation;
 
266
 
 
267
  sample_time.to_int32_t(&representation);
 
268
 
 
269
  ASSERT_EQ(representation, 183459);
 
270
}
 
271
 
 
272
TEST_F(TimeTest, from_int32_t_shouldPopulateTimeCorrectly)
256
273
{
257
274
  uint32_t decoded_hours, decoded_minutes, decoded_seconds;
258
 
  int32_t representation;
259
275
  Time decoded_time;
260
276
  
261
 
  sample_time.to_int32_t(&representation);
262
 
  decoded_time.from_int32_t(representation);
 
277
  decoded_time.from_int32_t(183459);
263
278
  
264
279
  decoded_hours= decoded_time.hours();
265
280
  decoded_minutes= decoded_time.minutes();