| 1 |
/* -*- c-basic-offset: 2 -*- */ |
| 2 |
/* |
| 3 |
Copyright(C) 2012-2015 Kouhei Sutou <[email protected]> |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Lesser General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2.1 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public |
| 16 |
License along with this library; if not, write to the Free Software |
| 17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <string.h> |
| 21 |
#include <cppcutter.h> |
| 22 |
|
| 23 |
#include <mrn_path_mapper.hpp> |
| 24 |
|
| 25 |
namespace test_mrn_path_mapper { |
| 26 |
namespace db_path { |
| 27 |
namespace without_prefix { |
| 28 |
void test_normal_db() { |
| 29 |
mrn::PathMapper mapper("./db/", NULL); |
| 30 |
cppcut_assert_equal("db.mrn", mapper.db_path()); |
| 31 |
} |
| 32 |
|
| 33 |
void test_normal_table() { |
| 34 |
mrn::PathMapper mapper("./db/table", NULL); |
| 35 |
cppcut_assert_equal("db.mrn", mapper.db_path()); |
| 36 |
} |
| 37 |
|
| 38 |
void test_temporary_table() { |
| 39 |
mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); |
| 40 |
cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0.mrn", |
| 41 |
mapper.db_path()); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
namespace with_prefix { |
| 46 |
void test_normal_db() { |
| 47 |
mrn::PathMapper mapper("./db/", "mroonga.data/"); |
| 48 |
cppcut_assert_equal("mroonga.data/db.mrn", mapper.db_path()); |
| 49 |
} |
| 50 |
|
| 51 |
void test_normal_table() { |
| 52 |
mrn::PathMapper mapper("./db/table", "mroonga.data/"); |
| 53 |
cppcut_assert_equal("mroonga.data/db.mrn", mapper.db_path()); |
| 54 |
} |
| 55 |
|
| 56 |
void test_temporary_table() { |
| 57 |
mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", "mroonga.data/"); |
| 58 |
cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0.mrn", |
| 59 |
mapper.db_path()); |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
namespace db_name { |
| 65 |
void test_normal_db() { |
| 66 |
mrn::PathMapper mapper("./db/", NULL); |
| 67 |
cppcut_assert_equal("db", mapper.db_name()); |
| 68 |
} |
| 69 |
|
| 70 |
void test_normal_table() { |
| 71 |
mrn::PathMapper mapper("./db/table", NULL); |
| 72 |
cppcut_assert_equal("db", mapper.db_name()); |
| 73 |
} |
| 74 |
|
| 75 |
void test_temporary_table() { |
| 76 |
mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); |
| 77 |
cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0", |
| 78 |
mapper.db_name()); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
namespace table_name { |
| 83 |
void test_normal_table() { |
| 84 |
mrn::PathMapper mapper("./db/table", NULL); |
| 85 |
cppcut_assert_equal("table", mapper.table_name()); |
| 86 |
} |
| 87 |
|
| 88 |
void test_temporary_table() { |
| 89 |
mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); |
| 90 |
cppcut_assert_equal("#sql27c5_1_0", mapper.table_name()); |
| 91 |
} |
| 92 |
|
| 93 |
void test_underscore_start_table() { |
| 94 |
mrn::PathMapper mapper("./db/_table", NULL); |
| 95 |
cppcut_assert_equal("@005ftable", mapper.table_name()); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
namespace mysql_table_name { |
| 100 |
void test_normal_table() { |
| 101 |
mrn::PathMapper mapper("./db/table", NULL); |
| 102 |
cppcut_assert_equal("table", mapper.mysql_table_name()); |
| 103 |
} |
| 104 |
|
| 105 |
void test_temporary_table() { |
| 106 |
mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); |
| 107 |
cppcut_assert_equal("#sql27c5_1_0", mapper.mysql_table_name()); |
| 108 |
} |
| 109 |
|
| 110 |
void test_underscore_start_table() { |
| 111 |
mrn::PathMapper mapper("./db/_table", NULL); |
| 112 |
cppcut_assert_equal("_table", mapper.mysql_table_name()); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
namespace mysql_path { |
| 117 |
void test_normal_table() { |
| 118 |
mrn::PathMapper mapper("./db/table"); |
| 119 |
cppcut_assert_equal("./db/table", mapper.mysql_path()); |
| 120 |
} |
| 121 |
|
| 122 |
void test_temporary_table() { |
| 123 |
mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0"); |
| 124 |
cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0", |
| 125 |
mapper.mysql_path()); |
| 126 |
} |
| 127 |
|
| 128 |
void test_partition_table_path() { |
| 129 |
mrn::PathMapper mapper("./db/table#P#p1"); |
| 130 |
cppcut_assert_equal("./db/table", mapper.mysql_path()); |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|