~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/temporal_interval_test.cc

little fix in include.am 
fixed temporal_format_test to compile
fixed temporal_interval_test and main so that environment gets initialized properly before tests
tests for TemporalInterval::initFromItem
fixed bug in TemporalInterval::getIntervalFromString, which caused microseconds not to get expanded, when high end elements were not present

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <drizzled/plugin/listen.h>
32
32
 
33
33
using namespace drizzled;
34
 
/*
 
34
 
35
35
class ItemStub : public Item
36
36
{
37
37
  ItemStub(Session *fake_session) : Item(fake_session, this)
81
81
    {
82
82
      fake_client= plugin::Listen::getNullClient();
83
83
      fake_session = new Session(fake_client);
 
84
      fake_session->thread_stack= (char*) &fake_session;
 
85
      fake_session->initGlobals();
84
86
      item = ItemStub::get_item_stub(fake_session);
85
87
 
86
88
      string_to_return.alloc(100);//TODO: some reasonable size here
93
95
 
94
96
TEST_F(TemporalIntervalTest, initFromItem_intervalWeek)
95
97
{
96
 
  char string[] = "aaa";
 
98
  char string[] = "30";
97
99
  item->string_to_return->set_ascii(string, strlen(string));
98
100
  item->int_to_return = 30;
99
101
 
101
103
 
102
104
  ASSERT_EQ(210, interval.get_day());
103
105
}
104
 
*/
 
 
b'\\ No newline at end of file'
 
106
 
 
107
TEST_F(TemporalIntervalTest, initFromItem_intervalDayMicrosecond)
 
108
{
 
109
  char string[] = "7 12:45:19.777";
 
110
  item->string_to_return->set_ascii(string, strlen(string));
 
111
 
 
112
  interval.initFromItem(item.get(), INTERVAL_DAY_MICROSECOND, &buffer);
 
113
 
 
114
  EXPECT_EQ(7, interval.get_day());
 
115
  EXPECT_EQ(12, interval.get_hour());
 
116
  EXPECT_EQ(45, interval.get_minute());
 
117
  EXPECT_EQ(19, interval.get_second());
 
118
  EXPECT_EQ(777000, interval.get_second_part());
 
119
}
 
120
 
 
121
TEST_F(TemporalIntervalTest, initFromItem_intervalDayMicrosecond_tooFewArguments_shouldLeaveHighEndItems)
 
122
{
 
123
  char string[] = "45:19.777";
 
124
  item->string_to_return->set_ascii(string, strlen(string));
 
125
  
 
126
  interval.initFromItem(item.get(), INTERVAL_DAY_MICROSECOND, &buffer);
 
127
  
 
128
  EXPECT_EQ(0, interval.get_day());
 
129
  EXPECT_EQ(0, interval.get_hour());
 
130
  EXPECT_EQ(45, interval.get_minute());
 
131
  EXPECT_EQ(19, interval.get_second());
 
132
  EXPECT_EQ(777000, interval.get_second_part());
 
133
}
 
134