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()); |
33 |
EXPECT_EQ("test.a", identifier.getSQLPath()); |
|
1618
by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have |
34 |
}
|
35 |
||
36 |
TEST(table_identifier_test_temporary, Create) |
|
37 |
{
|
|
38 |
TableIdentifier identifier("test", "a", message::Table::TEMPORARY); |
|
39 |
EXPECT_EQ("/#sql", identifier.getPath().substr(0, 5)); |
|
40 |
EXPECT_EQ("test.#a", identifier.getSQLPath()); |
|
41 |
}
|
|
42 |
||
43 |
TEST(table_identifier_test_internal, Create) |
|
44 |
{
|
|
45 |
TableIdentifier identifier("test", "a", message::Table::TEMPORARY); |
|
46 |
EXPECT_EQ("/#sql", identifier.getPath().substr(0, 5)); |
|
47 |
EXPECT_EQ("test.#a", identifier.getSQLPath()); |
|
48 |
}
|
|
49 |
||
50 |
TEST(table_identifier_test_build_tmptable_filename, Static) |
|
51 |
{
|
|
52 |
std::vector<char> pathname; |
|
53 |
||
54 |
TableIdentifier::build_tmptable_filename(pathname); |
|
55 |
||
56 |
EXPECT_GT(pathname.size(), 0); |
|
57 |
EXPECT_GT(strlen(&pathname[0]), 0); |
|
58 |
}
|
|
59 |
||
60 |
TEST(table_identifier_test_key, Key) |
|
61 |
{
|
|
62 |
TableIdentifier identifier("test", "a"); |
|
63 |
||
64 |
const TableIdentifier::Key key= identifier.getKey(); |
|
65 |
||
66 |
EXPECT_EQ(key.size(), 7); |
|
1878.5.3
by Brian Aker
Update Key to work a bit faster. |
67 |
EXPECT_EQ(key.vector()[0], 't'); |
68 |
EXPECT_EQ(key.vector()[1], 'e'); |
|
69 |
EXPECT_EQ(key.vector()[2], 's'); |
|
70 |
EXPECT_EQ(key.vector()[3], 't'); |
|
71 |
EXPECT_EQ(key.vector()[4], 0); |
|
72 |
EXPECT_EQ(key.vector()[5], 'a'); |
|
73 |
EXPECT_EQ(key.vector()[6], 0); |
|
1618
by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have |
74 |
}
|
75 |
||
76 |
TEST(table_identifier_test_key, KeyCompare) |
|
77 |
{
|
|
78 |
TableIdentifier identifier("test", "a"); |
|
79 |
TableIdentifier identifier2("test", "a"); |
|
80 |
||
81 |
EXPECT_EQ((identifier.getKey() == identifier.getKey()), true); |
|
82 |
}
|