1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
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.
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.
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
23
#include <gtest/gtest.h>
25
#include <drizzled/identifier.h>
27
using namespace drizzled;
29
TEST(table_identifier_test_standard, Create)
31
TableIdentifier identifier("test", "a");
32
EXPECT_EQ("test/a", identifier.getPath());
34
identifier.getSQLPath(path);
35
EXPECT_EQ("test.a", path);
38
TEST(table_identifier_test_temporary, Create)
40
TableIdentifier identifier("test", "a", message::Table::TEMPORARY);
41
EXPECT_EQ("/#sql", identifier.getPath().substr(0, 5));
43
identifier.getSQLPath(path);
44
EXPECT_EQ("test.#a", path);
47
TEST(table_identifier_test_internal, Create)
49
TableIdentifier identifier("test", "a", message::Table::TEMPORARY);
50
EXPECT_EQ("/#sql", identifier.getPath().substr(0, 5));
52
identifier.getSQLPath(path);
53
EXPECT_EQ("test.#a", path);
56
TEST(table_identifier_test_build_tmptable_filename, Static)
58
std::vector<char> pathname;
60
TableIdentifier::build_tmptable_filename(pathname);
62
EXPECT_GT(pathname.size(), 0);
63
EXPECT_GT(strlen(&pathname[0]), 0);
66
TEST(table_identifier_test_key, Key)
68
TableIdentifier identifier("test", "a");
70
const TableIdentifier::Key key= identifier.getKey();
72
EXPECT_EQ(key.size(), 7);
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);
82
TEST(table_identifier_test_key, KeyCompare)
84
TableIdentifier identifier("test", "a");
85
TableIdentifier identifier2("test", "a");
87
EXPECT_EQ((identifier.getKey() == identifier.getKey()), true);