~drizzle-trunk/drizzle/development

1618 by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Brian Aker
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 <gtest/gtest.h>
24
1660.1.2 by Brian Aker
A couple of dead bits.
25
#include <drizzled/identifier.h>
1618 by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have
26
27
using namespace drizzled;
28
29
TEST(table_identifier_test_standard, Create)
30
{
31
  TableIdentifier identifier("test", "a");
1786.3.2 by Monty Taylor
Cleaned up the initial pass at this. It's not perfect, but it does work.
32
  EXPECT_EQ("test/a", identifier.getPath());
1954.2.1 by Brian Aker
getSQLPath() modified to take a string so that we can const the table
33
  std::string path;
34
  identifier.getSQLPath(path);
35
  EXPECT_EQ("test.a", path);
1618 by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have
36
}
37
38
TEST(table_identifier_test_temporary, Create)
39
{
40
  TableIdentifier identifier("test", "a", message::Table::TEMPORARY);
41
  EXPECT_EQ("/#sql", identifier.getPath().substr(0, 5));
1954.2.1 by Brian Aker
getSQLPath() modified to take a string so that we can const the table
42
  std::string path;
43
  identifier.getSQLPath(path);
44
  EXPECT_EQ("test.#a", path);
1618 by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have
45
}
46
47
TEST(table_identifier_test_internal, Create)
48
{
49
  TableIdentifier identifier("test", "a", message::Table::TEMPORARY);
50
  EXPECT_EQ("/#sql", identifier.getPath().substr(0, 5));
1954.2.1 by Brian Aker
getSQLPath() modified to take a string so that we can const the table
51
  std::string path;
52
  identifier.getSQLPath(path);
53
  EXPECT_EQ("test.#a", path);
1618 by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have
54
}
55
56
TEST(table_identifier_test_build_tmptable_filename, Static)
57
{
58
  std::vector<char> pathname;
59
60
  TableIdentifier::build_tmptable_filename(pathname);
61
62
  EXPECT_GT(pathname.size(), 0);
63
  EXPECT_GT(strlen(&pathname[0]), 0);
64
}
65
66
TEST(table_identifier_test_key, Key)
67
{
68
  TableIdentifier identifier("test", "a");
69
70
  const TableIdentifier::Key key= identifier.getKey();
71
72
  EXPECT_EQ(key.size(), 7);
1878.5.3 by Brian Aker
Update Key to work a bit faster.
73
  EXPECT_EQ(key.vector()[0], 't');
74
  EXPECT_EQ(key.vector()[1], 'e');
75
  EXPECT_EQ(key.vector()[2], 's');
76
  EXPECT_EQ(key.vector()[3], 't');
77
  EXPECT_EQ(key.vector()[4], 0);
78
  EXPECT_EQ(key.vector()[5], 'a');
79
  EXPECT_EQ(key.vector()[6], 0);
1618 by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have
80
}
81
82
TEST(table_identifier_test_key, KeyCompare)
83
{
84
  TableIdentifier identifier("test", "a");
85
  TableIdentifier identifier2("test", "a");
86
87
  EXPECT_EQ((identifier.getKey() == identifier.getKey()), true);
88
}