~drizzle-trunk/drizzle/development

1377.8.40 by Paweł Blokus
minor style fixes
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Pawel Blokus
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
 
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
21
#include <config.h>
1377.8.40 by Paweł Blokus
minor style fixes
22
23
#include <drizzled/plugin/client.h>
2032 by Brian Aker
MErge in the include changes.
24
#include <drizzled/type/time.h>
1377.8.40 by Paweł Blokus
minor style fixes
25
#include <gtest/gtest.h>
26
#include <string.h>
27
28
#include "plugin_stubs.h"
29
30
using namespace drizzled;
31
32
class ClientTest : public ::testing::Test
33
{
34
public:
35
  char buffer[40];
36
  ClientStub client;
37
38
  virtual void SetUp()
39
  {
40
    memset(buffer, '\0', sizeof(buffer));
41
    client.set_store_ret_val(true);
42
    client.set_last_call_char_ptr(buffer);
43
  }
44
};
45
46
TEST_F(ClientTest, store_drizzle_time_datetime)
47
{
48
  //TODO: is the sign intentionally ignored in the case of a datetime?
2088.8.9 by Brian Aker
Merge in namespace of enum.
49
  type::Time dt(2010, 4, 5, 23, 45, 3, 777, type::DRIZZLE_TIMESTAMP_DATETIME);
1377.8.40 by Paweł Blokus
minor style fixes
50
  char expected[]= "2010-04-05 23:45:03.000777";
51
52
  client.store(&dt);
53
54
  ASSERT_STREQ(expected, buffer);
55
}
56
57
TEST_F(ClientTest, store_drizzle_time_date)
58
{
59
  //TODO: is the sign intentionally ignored in the case of a date?
2088.8.9 by Brian Aker
Merge in namespace of enum.
60
  type::Time dt(2010, 4, 5, 0, 0, 0, 0, type::DRIZZLE_TIMESTAMP_DATE);
1377.8.40 by Paweł Blokus
minor style fixes
61
  char expected[]= "2010-04-05";
62
  
63
  client.store(&dt);
64
  
65
  ASSERT_STREQ(expected, buffer);
66
}
67
68
TEST_F(ClientTest, store_drizzle_time_time)
69
{
2082.4.2 by Brian Aker
Merge in changes for factor on type::Time
70
  type::Time dt(23, 45, 3, 777, true);
1377.8.40 by Paweł Blokus
minor style fixes
71
  char expected[]= "-23:45:03.000777";
72
  
73
  client.store(&dt);
74
  
75
  ASSERT_STREQ(expected, buffer);
76
}