~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/table_identifier.cc

  • Committer: Monty Taylor
  • Date: 2009-04-12 08:14:18 UTC
  • mto: (992.1.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: mordred@inaugust.com-20090412081418-dc6gh3g3awkrhwov
Merged compress, uncompress and uncompressed_length into one plugin lib. Yay new plugin registration!

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 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
 
 
25
 
#include <drizzled/identifier.h>
26
 
 
27
 
using namespace drizzled;
28
 
 
29
 
TEST(table_identifier_test_standard, Create)
30
 
{
31
 
  TableIdentifier identifier("test", "a");
32
 
  EXPECT_EQ("test/a", identifier.getPath());
33
 
  std::string path;
34
 
  identifier.getSQLPath(path);
35
 
  EXPECT_EQ("test.a", path);
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));
42
 
  std::string path;
43
 
  identifier.getSQLPath(path);
44
 
  EXPECT_EQ("test.#a", path);
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));
51
 
  std::string path;
52
 
  identifier.getSQLPath(path);
53
 
  EXPECT_EQ("test.#a", path);
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);
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);
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
 
}