~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/plugin/client_test.cc

Merged vcol stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
21
 
#include "config.h"
22
 
 
23
 
#include <drizzled/plugin/client.h>
24
 
#include <drizzled/type/time.h>
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?
49
 
  type::Time dt(2010, 4, 5, 23, 45, 3, 777, type::DRIZZLE_TIMESTAMP_DATETIME);
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?
60
 
  type::Time dt(2010, 4, 5, 0, 0, 0, 0, type::DRIZZLE_TIMESTAMP_DATE);
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
 
{
70
 
  type::Time dt(23, 45, 3, 777, true);
71
 
  char expected[]= "-23:45:03.000777";
72
 
  
73
 
  client.store(&dt);
74
 
  
75
 
  ASSERT_STREQ(expected, buffer);
76
 
}