Skip to content

Commit 3757998

Browse files
committed
Improve test coverage of Database: improve tests & remove a variant of createFunction()
1 parent 0fd0746 commit 3757998

2 files changed

Lines changed: 3 additions & 34 deletions

File tree

include/SQLiteCpp/Database.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -368,38 +368,6 @@ class Database
368368
void (*apFinal)(sqlite3_context *) = nullptr, // NOLINT(readability/casting)
369369
void (*apDestroy)(void *) = nullptr);
370370

371-
/**
372-
* @brief Create or redefine a SQL function or aggregate in the sqlite database.
373-
*
374-
* This is the equivalent of the sqlite3_create_function_v2 command.
375-
* @see http://www.sqlite.org/c3ref/create_function.html
376-
*
377-
* @note UTF-8 text encoding assumed.
378-
*
379-
* @param[in] aFuncName Name of the SQL function to be created or redefined
380-
* @param[in] aNbArg Number of arguments in the function
381-
* @param[in] abDeterministic Optimize for deterministic functions (most are). A random number generator is not.
382-
* @param[in] apApp Arbitrary pointer of user data, accessible with sqlite3_user_data().
383-
* @param[in] apFunc Pointer to a C-function to implement a scalar SQL function (apStep & apFinal nullptr)
384-
* @param[in] apStep Pointer to a C-function to implement an aggregate SQL function (apFunc nullptr)
385-
* @param[in] apFinal Pointer to a C-function to implement an aggregate SQL function (apFunc nullptr)
386-
* @param[in] apDestroy If not nullptr, then it is the destructor for the application data pointer.
387-
*
388-
* @throw SQLite::Exception in case of error
389-
*/
390-
void createFunction(const std::string& aFuncName,
391-
int aNbArg,
392-
bool abDeterministic,
393-
void* apApp,
394-
void (*apFunc)(sqlite3_context *, int, sqlite3_value **),
395-
void (*apStep)(sqlite3_context *, int, sqlite3_value **) = nullptr,
396-
void (*apFinal)(sqlite3_context *) = nullptr,
397-
void (*apDestroy)(void *) = nullptr)
398-
{
399-
createFunction(aFuncName.c_str(), aNbArg, abDeterministic,
400-
apApp, apFunc, apStep, apFinal, apDestroy);
401-
}
402-
403371
/**
404372
* @brief Load a module into the current sqlite database instance.
405373
*

tests/Database_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ TEST(Database, execAndGet)
271271
// Get a single value result with an easy to use shortcut
272272
EXPECT_STREQ("second", db.execAndGet("SELECT value FROM test WHERE id=2"));
273273
EXPECT_STREQ("third", db.execAndGet("SELECT value FROM test WHERE weight=7"));
274-
EXPECT_EQ(3, db.execAndGet("SELECT weight FROM test WHERE value=\"first\"").getInt());
274+
const std::string query("SELECT weight FROM test WHERE value=\"first\"");
275+
EXPECT_EQ(3, db.execAndGet(query).getInt());
275276
}
276277

277278
TEST(Database, execException)
@@ -405,7 +406,7 @@ TEST(Database, getHeaderInfo)
405406
db.exec("PRAGMA main.application_id = 2468");
406407

407408
// Parse header fields from test database
408-
SQLite::Header h = SQLite::Database::getHeaderInfo("test.db3");
409+
const SQLite::Header h = db.getHeaderInfo();
409410

410411
//Test header values explicitly set via PRAGMA statements
411412
EXPECT_EQ(h.userVersion, 12345);

0 commit comments

Comments
 (0)