20 #include "catch2/catch.hpp" 28 TEST_CASE(
"DBHelper unit tests: Default constructor: DBHelper()",
"[db]"){
35 SECTION(
"openDB(const std::string filename) with 'test_db.db'"){
36 int ret_code = db.
openDB(
"test_db.db");
37 REQUIRE(ret_code == 0);
39 REQUIRE(db.
getFilename().compare(
"test_db.db") == 0);
47 SECTION(
"openDB(const std::string filename) with 'none.db'"){
48 REQUIRE(db.
openDB(
"none.db") != 0);
65 TEST_CASE(
"Parameterised constructor: DBHelper(const std::string filename) with 'test.db'",
"[db]"){
71 SECTION(
"openDB(const std::string filename) with 'test_db.db'"){
72 REQUIRE(db.
openDB(
"test_db.db") == 0);
74 REQUIRE(db.
getFilename().compare(
"test_db.db") == 0);
88 TEST_CASE(
"Parameterised constructor: DBHelper(const std::string filename) with 'none.db'",
"[db]"){
94 SECTION(
"openDB(const std::string filename) with 'none.db'"){
95 REQUIRE(db.
openDB(
"none.db") != 0 );
110 TEST_CASE(
"CorpusUtils unit tests: Default constructor: CorpusUtils()",
"[db]"){
119 SECTION(
"Load data: data_type=noun, table is default ('corpus')"){
122 REQUIRE(n_size[0] != 0);
123 REQUIRE(n_size[1] != 0);
125 SECTION(
"Load data: data_type=verb, table is default ('corpus')"){
128 REQUIRE(v_size[0] != 0);
129 REQUIRE(v_size[1] != 0);
131 SECTION(
"Load data: data_type=noun and verb, table is default ('corpus')"){
134 REQUIRE(v_size[0] != 0);
135 REQUIRE(v_size[1] != 0);
139 REQUIRE(vn_size[0] != v_size[0]);
140 REQUIRE(vn_size[1] != v_size[1]);
142 SECTION(
"Load data: data_type=noun and verb, table='basis'"){
145 REQUIRE(v_size[0] != 0);
146 REQUIRE(v_size[1] != 0);
150 REQUIRE(vn_size[0] != v_size[0]);
151 REQUIRE(vn_size[1] != v_size[1]);
159 TEST_CASE(
"CorpusUtils unit tests: Paramaterised constructor: CorpusUtils(test_db.db)",
"[db]"){
169 SECTION(
"Load data: data_type=noun, table is default ('corpus')"){
172 REQUIRE(n_size[0] != 0);
173 REQUIRE(n_size[1] != 0);
175 SECTION(
"Load data: data_type=verb, table is default ('corpus')"){
178 REQUIRE(v_size[0] != 0);
179 REQUIRE(v_size[1] != 0);
181 SECTION(
"Load data: data_type=noun and verb, table is default ('corpus')"){
184 REQUIRE(v_size[0] != 0);
185 REQUIRE(v_size[1] != 0);
189 REQUIRE(vn_size[0] != v_size[0]);
190 REQUIRE(vn_size[1] != v_size[1]);
192 SECTION(
"Load data: data_type=noun and verb, table='basis'"){
195 REQUIRE(v_size[0] != 0);
196 REQUIRE(v_size[1] != 0);
200 REQUIRE(vn_size[0] != v_size[0]);
201 REQUIRE(vn_size[1] != v_size[1]);
Database access and manipulation functions.
NTB & getNameToBin()
Get the NTB object. This is a map of maps, wherein the first key represents the grammatical type to l...
void closeDB()
Closes the database if the DB pointer is open.
BTN & getBinToName()
Get the BTN object. This is a map of maps, wherein the first key represents the grammatical type to l...
void loadData(const std::string data_type, const std::string table="corpus")
Loads from the database for a given data type (noun, verb, etc)
sqlite3 * getDBRef()
Returns a pointer to the DB object.
const std::string get_database_filename()
Get the database filename object.
int openDB(const std::string filename)
Opens the requested database, and gives the return code of the operation. If the DB pointer has alrea...
std::string getFilename()
Get the name of the opened database.
DBHelper & getDBHelper()
Return reference to database object.
TEST_CASE("DBHelper unit tests: Default constructor: DBHelper()","[db]")
Testing default constructor and subsequent functions on DBHelper class.