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
#define BOOST_TEST_DYN_LINK
24
#include <boost/test/unit_test.hpp>
26
#include <drizzled/identifier.h>
28
using namespace drizzled;
30
BOOST_AUTO_TEST_SUITE(TableIdentifierTest)
31
BOOST_AUTO_TEST_CASE(CreateStandard)
33
identifier::Table identifier("test", "a");
34
BOOST_REQUIRE_EQUAL("test/a", identifier.getPath());
36
identifier.getSQLPath(path);
37
BOOST_REQUIRE_EQUAL("test.a", path);
40
BOOST_AUTO_TEST_CASE(CreateTemporary)
42
identifier::Table identifier("test", "a", message::Table::TEMPORARY);
43
BOOST_REQUIRE_EQUAL("/#sql", identifier.getPath().substr(0, 5));
45
identifier.getSQLPath(path);
46
BOOST_REQUIRE_EQUAL("test.#a", path);
49
BOOST_AUTO_TEST_CASE(CreateInternal)
51
identifier::Table identifier("test", "a", message::Table::TEMPORARY);
52
BOOST_REQUIRE_EQUAL("/#sql", identifier.getPath().substr(0, 5));
54
identifier.getSQLPath(path);
55
BOOST_REQUIRE_EQUAL("test.#a", path);
58
BOOST_AUTO_TEST_CASE(StaticTmpTable)
60
std::vector<char> pathname;
62
identifier::Table::build_tmptable_filename(pathname);
64
BOOST_REQUIRE_GT(pathname.size(), 0);
65
BOOST_REQUIRE_GT(strlen(&pathname[0]), 0);
68
BOOST_AUTO_TEST_CASE(Key)
70
identifier::Table identifier("test", "a");
72
const identifier::Table::Key key= identifier.getKey();
74
BOOST_REQUIRE_EQUAL(key.size(), 7);
75
BOOST_REQUIRE_EQUAL(key.vector()[0], 't');
76
BOOST_REQUIRE_EQUAL(key.vector()[1], 'e');
77
BOOST_REQUIRE_EQUAL(key.vector()[2], 's');
78
BOOST_REQUIRE_EQUAL(key.vector()[3], 't');
79
BOOST_REQUIRE_EQUAL(key.vector()[4], 0);
80
BOOST_REQUIRE_EQUAL(key.vector()[5], 'a');
81
BOOST_REQUIRE_EQUAL(key.vector()[6], 0);
84
BOOST_AUTO_TEST_CASE(KeyCompare)
86
identifier::Table identifier("test", "a");
87
identifier::Table identifier2("test", "a");
89
BOOST_REQUIRE_EQUAL((identifier.getKey() == identifier.getKey()), true);
91
BOOST_AUTO_TEST_SUITE_END()