2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
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 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
21 |
#include <config.h> |
2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
22 |
|
23 |
#define BOOST_TEST_DYN_LINK
|
|
24 |
#include <boost/test/unit_test.hpp> |
|
25 |
||
26 |
#include <drizzled/identifier.h> |
|
27 |
||
28 |
using namespace drizzled; |
|
29 |
||
30 |
BOOST_AUTO_TEST_SUITE(TableIdentifierTest) |
|
31 |
BOOST_AUTO_TEST_CASE(CreateStandard) |
|
32 |
{
|
|
33 |
identifier::Table identifier("test", "a"); |
|
34 |
BOOST_REQUIRE_EQUAL("test/a", identifier.getPath()); |
|
2246.4.2
by Olaf van der Spek
Refactor Identifier::getSQLPath() |
35 |
BOOST_REQUIRE_EQUAL("test.a", identifier.getSQLPath()); |
2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
36 |
}
|
37 |
||
38 |
BOOST_AUTO_TEST_CASE(CreateTemporary) |
|
39 |
{
|
|
40 |
identifier::Table identifier("test", "a", message::Table::TEMPORARY); |
|
41 |
BOOST_REQUIRE_EQUAL("/#sql", identifier.getPath().substr(0, 5)); |
|
2246.4.2
by Olaf van der Spek
Refactor Identifier::getSQLPath() |
42 |
BOOST_REQUIRE_EQUAL("test.#a", identifier.getSQLPath()); |
2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
43 |
}
|
44 |
||
45 |
BOOST_AUTO_TEST_CASE(CreateInternal) |
|
46 |
{
|
|
47 |
identifier::Table identifier("test", "a", message::Table::TEMPORARY); |
|
48 |
BOOST_REQUIRE_EQUAL("/#sql", identifier.getPath().substr(0, 5)); |
|
2246.4.2
by Olaf van der Spek
Refactor Identifier::getSQLPath() |
49 |
BOOST_REQUIRE_EQUAL("test.#a", identifier.getSQLPath()); |
2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
50 |
}
|
51 |
||
52 |
BOOST_AUTO_TEST_CASE(StaticTmpTable) |
|
53 |
{
|
|
2318.9.5
by Olaf van der Spek
Refactor build_table_filename |
54 |
std::string pathname(identifier::Table::build_tmptable_filename()); |
2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
55 |
|
56 |
BOOST_REQUIRE_GT(pathname.size(), 0); |
|
57 |
BOOST_REQUIRE_GT(strlen(&pathname[0]), 0); |
|
58 |
}
|
|
59 |
||
60 |
BOOST_AUTO_TEST_CASE(Key) |
|
61 |
{
|
|
62 |
identifier::Table identifier("test", "a"); |
|
63 |
||
64 |
const identifier::Table::Key key= identifier.getKey(); |
|
65 |
||
2478.2.2
by Stewart Smith
fix table_identifier unittest for having catalog as part of the key |
66 |
BOOST_REQUIRE_EQUAL(key.size(), 13); |
67 |
int i=0; |
|
2478.2.3
by Stewart Smith
fix table_identifier unittest for having CATALOG in table key |
68 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'L'); |
69 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'O'); |
|
70 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'C'); |
|
71 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'A'); |
|
72 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'L'); |
|
2478.2.2
by Stewart Smith
fix table_identifier unittest for having catalog as part of the key |
73 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 0); |
74 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 't'); |
|
75 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'e'); |
|
76 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 's'); |
|
77 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 't'); |
|
78 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 0); |
|
79 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 'a'); |
|
80 |
BOOST_REQUIRE_EQUAL(key.vector()[i++], 0); |
|
2097.2.4
by Andrew Hutchings
Convert all unit tests to boost::test |
81 |
}
|
82 |
||
83 |
BOOST_AUTO_TEST_CASE(KeyCompare) |
|
84 |
{
|
|
85 |
identifier::Table identifier("test", "a"); |
|
86 |
identifier::Table identifier2("test", "a"); |
|
87 |
||
88 |
BOOST_REQUIRE_EQUAL((identifier.getKey() == identifier.getKey()), true); |
|
89 |
}
|
|
90 |
BOOST_AUTO_TEST_SUITE_END() |