mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Minor cleanup of the codebase, mostly putting braces on their own line in unit tests
This commit is contained in:
parent
08a73ce90b
commit
1eda5c751c
@ -133,4 +133,6 @@ Version ?
|
||||
- Update SQLite3 from 3.27.2 to 3.28.0 (2019-04-16)
|
||||
- #191 CMake Warning line 299
|
||||
- #190 Implement move constructors
|
||||
- #192 Add wrapper for bind parameter count
|
||||
- #192 Add wrapper for bind parameter count
|
||||
- #197 Add tuple_bind and execute_many
|
||||
- #199 Fix #156 misleading error message in exception from Statement::exec
|
||||
|
@ -301,7 +301,8 @@ The source code use the CamelCase naming style variant where:
|
||||
- files (.cpp/.h) are named like the class they contain
|
||||
- function and variable names begin with a lower case letter
|
||||
- member variables begin with a 'm', function arguments begin with a 'a', booleans with a 'b', pointers with a 'p'
|
||||
- each file, class, method and member variable is documented using Doxygen tags
|
||||
- each file, class, method and member variable is documented using Doxygen tags
|
||||
- braces on their own line
|
||||
See also http://www.appinf.com/download/CppCodingStyleGuide.pdf for good guidelines
|
||||
|
||||
## See also - Some other simple C++ SQLite wrappers:
|
||||
|
@ -3,7 +3,8 @@
|
||||
* @ingroup SQLiteCpp
|
||||
* @brief Convenience function to execute a Statement with multiple Parameter sets
|
||||
*
|
||||
* Copyright (c) 2019 Maximilian Bachmann (github@maxbachmann)
|
||||
* Copyright (c) 2019 Maximilian Bachmann (github maxbachmann)
|
||||
* Copyright (c) 2019 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
@ -39,15 +40,17 @@ namespace SQLite
|
||||
* \endcode
|
||||
* @param aDatabase Database to use
|
||||
* @param apQuery Query to use with all parameter sets
|
||||
* @param Arg first tuple with parameters
|
||||
* @param Types the following tuples with parameters
|
||||
* @param aArg first tuple with parameters
|
||||
* @param aParams the following tuples with parameters
|
||||
*/
|
||||
template <typename Arg, typename... Types>
|
||||
void execute_many(Database& aDatabase, const char* apQuery, Arg&& arg, Types&&... params) {
|
||||
void execute_many(Database& aDatabase, const char* apQuery, Arg&& aArg, Types&&... aParams)
|
||||
{
|
||||
SQLite::Statement query(aDatabase, apQuery);
|
||||
bind_exec(query, std::forward<decltype(arg)>(arg));
|
||||
(void)std::initializer_list<int>{
|
||||
((void)reset_bind_exec(query, std::forward<decltype(params)>(params)), 0)...
|
||||
bind_exec(query, std::forward<decltype(aArg)>(aArg));
|
||||
(void)std::initializer_list<int>
|
||||
{
|
||||
((void)reset_bind_exec(query, std::forward<decltype(aParams)>(aParams)), 0)...
|
||||
};
|
||||
}
|
||||
|
||||
@ -58,13 +61,13 @@ void execute_many(Database& aDatabase, const char* apQuery, Arg&& arg, Types&&..
|
||||
* This feature requires a c++14 capable compiler.
|
||||
*
|
||||
* @param apQuery Query to use
|
||||
* @param tuple tuple to bind
|
||||
* @param aTuple Tuple to bind
|
||||
*/
|
||||
template <typename ... Types>
|
||||
void reset_bind_exec(SQLite::Statement& query, std::tuple<Types...>&& tuple)
|
||||
void reset_bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple)
|
||||
{
|
||||
query.reset();
|
||||
bind_exec(query, std::forward<decltype(tuple)>(tuple));
|
||||
apQuery.reset();
|
||||
bind_exec(apQuery, std::forward<decltype(aTuple)>(aTuple));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,13 +76,13 @@ void reset_bind_exec(SQLite::Statement& query, std::tuple<Types...>&& tuple)
|
||||
* This feature requires a c++14 capable compiler.
|
||||
*
|
||||
* @param apQuery Query to use
|
||||
* @param tuple tuple to bind
|
||||
* @param aTuple Tuple to bind
|
||||
*/
|
||||
template <typename ... Types>
|
||||
void bind_exec(SQLite::Statement& query, std::tuple<Types...>&& tuple)
|
||||
void bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple)
|
||||
{
|
||||
bind(query, std::forward<decltype(tuple)>(tuple));
|
||||
while (query.executeStep()) {}
|
||||
bind(apQuery, std::forward<decltype(aTuple)>(aTuple));
|
||||
while (apQuery.executeStep()) {}
|
||||
}
|
||||
|
||||
} // namespace SQLite
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 2016 Paul Dreik (github@pauldreik.se)
|
||||
* Copyright (c) 2016-2019 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
* Copyright (c) 2019 Maximilian Bachmann (github@maxbachmann)
|
||||
* Copyright (c) 2019 Maximilian Bachmann (github maxbachmann)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
|
@ -198,7 +198,8 @@ void Database::createFunction(const char* apFuncName,
|
||||
{
|
||||
int TextRep = SQLITE_UTF8;
|
||||
// optimization if deterministic function (e.g. of nondeterministic function random())
|
||||
if (abDeterministic) {
|
||||
if (abDeterministic)
|
||||
{
|
||||
TextRep = TextRep|SQLITE_DETERMINISTIC;
|
||||
}
|
||||
const int ret = sqlite3_create_function_v2(mpSQLite, apFuncName, aNbArg, TextRep,
|
||||
@ -237,14 +238,16 @@ void Database::loadExtension(const char* apExtensionName, const char *apEntryPoi
|
||||
// Set the key for the current sqlite database instance.
|
||||
void Database::key(const std::string& aKey) const
|
||||
{
|
||||
int pass_len = static_cast<int>(aKey.length());
|
||||
int passLen = static_cast<int>(aKey.length());
|
||||
#ifdef SQLITE_HAS_CODEC
|
||||
if (pass_len > 0) {
|
||||
const int ret = sqlite3_key(mpSQLite, aKey.c_str(), pass_len);
|
||||
if (passLen > 0)
|
||||
{
|
||||
const int ret = sqlite3_key(mpSQLite, aKey.c_str(), passLen);
|
||||
check(ret);
|
||||
}
|
||||
#else // SQLITE_HAS_CODEC
|
||||
if (pass_len > 0) {
|
||||
if (passLen > 0)
|
||||
{
|
||||
const SQLite::Exception exception("No encryption support, recompile with SQLITE_HAS_CODEC to enable.");
|
||||
throw exception;
|
||||
}
|
||||
@ -255,11 +258,14 @@ void Database::key(const std::string& aKey) const
|
||||
void Database::rekey(const std::string& aNewKey) const
|
||||
{
|
||||
#ifdef SQLITE_HAS_CODEC
|
||||
int pass_len = aNewKey.length();
|
||||
if (pass_len > 0) {
|
||||
const int ret = sqlite3_rekey(mpSQLite, aNewKey.c_str(), pass_len);
|
||||
int passLen = aNewKey.length();
|
||||
if (passLen > 0)
|
||||
{
|
||||
const int ret = sqlite3_rekey(mpSQLite, aNewKey.c_str(), passLen);
|
||||
check(ret);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
const int ret = sqlite3_rekey(mpSQLite, nullptr, 0);
|
||||
check(ret);
|
||||
}
|
||||
@ -273,14 +279,18 @@ void Database::rekey(const std::string& aNewKey) const
|
||||
// Test if a file contains an unencrypted database.
|
||||
bool Database::isUnencrypted(const std::string& aFilename)
|
||||
{
|
||||
if (aFilename.length() > 0) {
|
||||
if (aFilename.length() > 0)
|
||||
{
|
||||
std::ifstream fileBuffer(aFilename.c_str(), std::ios::in | std::ios::binary);
|
||||
char header[16];
|
||||
if (fileBuffer.is_open()) {
|
||||
if (fileBuffer.is_open())
|
||||
{
|
||||
fileBuffer.seekg(0, std::ios::beg);
|
||||
fileBuffer.getline(header, 16);
|
||||
fileBuffer.close();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
const SQLite::Exception exception("Error opening file: " + aFilename);
|
||||
throw exception;
|
||||
}
|
||||
|
@ -21,7 +21,8 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
TEST(Backup, initException) {
|
||||
TEST(Backup, initException)
|
||||
{
|
||||
remove("backup_test.db3");
|
||||
SQLite::Database srcDB("backup_test.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
srcDB.exec("CREATE TABLE backup_test (id INTEGER PRIMARY KEY, value TEXT)");
|
||||
@ -34,7 +35,8 @@ TEST(Backup, initException) {
|
||||
remove("backup_test.db3");
|
||||
}
|
||||
|
||||
TEST(Backup, executeStepOne) {
|
||||
TEST(Backup, executeStepOne)
|
||||
{
|
||||
remove("backup_test.db3");
|
||||
remove("backup_test.db3.backup");
|
||||
SQLite::Database srcDB("backup_test.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
@ -66,7 +68,8 @@ TEST(Backup, executeStepOne) {
|
||||
remove("backup_test.db3.backup");
|
||||
}
|
||||
|
||||
TEST(Backup, executeStepAll) {
|
||||
TEST(Backup, executeStepAll)
|
||||
{
|
||||
remove("backup_test.db3");
|
||||
remove("backup_test.db3.backup");
|
||||
SQLite::Database srcDB("backup_test.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
@ -94,7 +97,8 @@ TEST(Backup, executeStepAll) {
|
||||
remove("backup_test.db3.backup");
|
||||
}
|
||||
|
||||
TEST(Backup, executeStepException) {
|
||||
TEST(Backup, executeStepException)
|
||||
{
|
||||
remove("backup_test.db3");
|
||||
remove("backup_test.db3.backup");
|
||||
SQLite::Database srcDB("backup_test.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
|
@ -21,7 +21,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
TEST(Column, basis) {
|
||||
TEST(Column, basis)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -187,7 +188,8 @@ TEST(Column, basis) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Column, getName) {
|
||||
TEST(Column, getName)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT)"));
|
||||
@ -214,7 +216,8 @@ TEST(Column, getName) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Column, stream) {
|
||||
TEST(Column, stream)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (msg TEXT)"));
|
||||
|
@ -29,14 +29,16 @@ void assertion_failed(const char* apFile, const long apLine, const char* apFunc,
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(SQLiteCpp, version) {
|
||||
TEST(SQLiteCpp, version)
|
||||
{
|
||||
EXPECT_STREQ(SQLITE_VERSION, SQLite::VERSION);
|
||||
EXPECT_EQ (SQLITE_VERSION_NUMBER, SQLite::VERSION_NUMBER);
|
||||
EXPECT_STREQ(SQLITE_VERSION, SQLite::getLibVersion());
|
||||
EXPECT_EQ (SQLITE_VERSION_NUMBER, SQLite::getLibVersionNumber());
|
||||
}
|
||||
|
||||
TEST(Database, ctorExecCreateDropExist) {
|
||||
TEST(Database, ctorExecCreateDropExist)
|
||||
{
|
||||
remove("test.db3");
|
||||
{
|
||||
// Try to open a non-existing database
|
||||
@ -70,7 +72,8 @@ SQLite::Database DatabaseBuilder(const char* apName)
|
||||
return SQLite::Database(apName, SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
|
||||
}
|
||||
|
||||
TEST(Database, moveConstructor) {
|
||||
TEST(Database, moveConstructor)
|
||||
{
|
||||
remove("test.db3");
|
||||
{
|
||||
// Create a new database, using the move constructor
|
||||
@ -87,7 +90,8 @@ TEST(Database, moveConstructor) {
|
||||
|
||||
#endif
|
||||
|
||||
TEST(Database, createCloseReopen) {
|
||||
TEST(Database, createCloseReopen)
|
||||
{
|
||||
remove("test.db3");
|
||||
{
|
||||
// Try to open the non-existing database
|
||||
@ -107,7 +111,8 @@ TEST(Database, createCloseReopen) {
|
||||
remove("test.db3");
|
||||
}
|
||||
|
||||
TEST(Database, inMemory) {
|
||||
TEST(Database, inMemory)
|
||||
{
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE);
|
||||
@ -126,7 +131,8 @@ TEST(Database, inMemory) {
|
||||
}
|
||||
|
||||
#if SQLITE_VERSION_NUMBER >= 3007015 // SQLite v3.7.15 is first version with PRAGMA busy_timeout
|
||||
TEST(Database, busyTimeout) {
|
||||
TEST(Database, busyTimeout)
|
||||
{
|
||||
{
|
||||
// Create a new database with default timeout of 0ms
|
||||
SQLite::Database db(":memory:");
|
||||
@ -163,7 +169,8 @@ TEST(Database, busyTimeout) {
|
||||
}
|
||||
#endif // SQLITE_VERSION_NUMBER >= 3007015
|
||||
|
||||
TEST(Database, exec) {
|
||||
TEST(Database, exec)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE);
|
||||
|
||||
@ -224,7 +231,8 @@ TEST(Database, exec) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Database, execAndGet) {
|
||||
TEST(Database, execAndGet)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE);
|
||||
|
||||
@ -242,7 +250,8 @@ TEST(Database, execAndGet) {
|
||||
EXPECT_EQ(3, db.execAndGet("SELECT weight FROM test WHERE value=\"first\"").getInt());
|
||||
}
|
||||
|
||||
TEST(Database, execException) {
|
||||
TEST(Database, execException)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -284,7 +293,8 @@ TEST(Database, execException) {
|
||||
// TODO: test Database::loadExtension()
|
||||
|
||||
#ifdef SQLITE_HAS_CODEC
|
||||
TEST(Database, encryptAndDecrypt) {
|
||||
TEST(Database, encryptAndDecrypt)
|
||||
{
|
||||
remove("test.db3");
|
||||
{
|
||||
// Try to open the non-existing database
|
||||
@ -328,7 +338,8 @@ TEST(Database, encryptAndDecrypt) {
|
||||
remove("test.db3");
|
||||
}
|
||||
#else // SQLITE_HAS_CODEC
|
||||
TEST(Database, encryptAndDecrypt) {
|
||||
TEST(Database, encryptAndDecrypt)
|
||||
{
|
||||
remove("test.db3");
|
||||
{
|
||||
// Try to open the non-existing database
|
||||
@ -350,4 +361,4 @@ TEST(Database, encryptAndDecrypt) {
|
||||
} // Close DB test.db3
|
||||
remove("test.db3");
|
||||
}
|
||||
#endif // SQLITE_HAS_CODEC
|
||||
#endif // SQLITE_HAS_CODEC
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
TEST(Exception, copy) {
|
||||
TEST(Exception, copy)
|
||||
{
|
||||
const SQLite::Exception ex1("some error", 2);
|
||||
const SQLite::Exception ex2 = ex1;
|
||||
EXPECT_STREQ(ex1.what(), ex2.what());
|
||||
@ -25,7 +26,8 @@ TEST(Exception, copy) {
|
||||
|
||||
// see http://eel.is/c++draft/exception#2 or http://www.cplusplus.com/reference/exception/exception/operator=/
|
||||
// an assignment operator is expected to be avaiable
|
||||
TEST(Exception, assignment) {
|
||||
TEST(Exception, assignment)
|
||||
{
|
||||
const SQLite::Exception ex1("some error", 2);
|
||||
SQLite::Exception ex2("some error2", 3);
|
||||
|
||||
@ -36,17 +38,22 @@ TEST(Exception, assignment) {
|
||||
EXPECT_EQ(ex1.getExtendedErrorCode(), ex2.getExtendedErrorCode());
|
||||
}
|
||||
|
||||
TEST(Exception, throw_catch) {
|
||||
TEST(Exception, throw_catch)
|
||||
{
|
||||
const char message[] = "some error";
|
||||
try {
|
||||
try
|
||||
{
|
||||
throw SQLite::Exception(message);
|
||||
} catch (const std::runtime_error& ex) {
|
||||
}
|
||||
catch (const std::runtime_error& ex)
|
||||
{
|
||||
EXPECT_STREQ(ex.what(), message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Exception, constructor) {
|
||||
TEST(Exception, constructor)
|
||||
{
|
||||
const char msg1[] = "error msg";
|
||||
std::string msg2 = msg1;
|
||||
{
|
||||
|
@ -3,9 +3,8 @@
|
||||
* @ingroup tests
|
||||
* @brief Test of variadic bind
|
||||
*
|
||||
* Copyright (c) 2016 Paul Dreik (github@pauldreik.se)
|
||||
* Copyright (c) 2016-2019 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
* Copyright (c) 2019 Maximilian Bachmann (github@maxbachmann)
|
||||
* Copyright (c) 2019 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
@ -20,14 +19,13 @@
|
||||
#include <cstdio>
|
||||
|
||||
#if (__cplusplus >= 201402L) || ( defined(_MSC_VER) && (_MSC_VER >= 1900) ) // c++14: Visual Studio 2015
|
||||
TEST(ExecuteMany, invalid) {
|
||||
TEST(ExecuteMany, invalid)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
|
||||
EXPECT_EQ(0, db.exec("DROP TABLE IF EXISTS test"));
|
||||
EXPECT_EQ(0,
|
||||
db.exec(
|
||||
"CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT DEFAULT 'default') "));
|
||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT DEFAULT 'default')"));
|
||||
EXPECT_TRUE(db.tableExists("test"));
|
||||
{
|
||||
execute_many(db, "INSERT INTO test VALUES (?, ?)",
|
||||
@ -40,7 +38,8 @@ TEST(ExecuteMany, invalid) {
|
||||
{
|
||||
SQLite::Statement query(db, std::string{"SELECT id, value FROM test ORDER BY id"});
|
||||
std::vector<std::pair<int, std::string> > results;
|
||||
while (query.executeStep()) {
|
||||
while (query.executeStep())
|
||||
{
|
||||
const int id = query.getColumn(0);
|
||||
std::string value = query.getColumn(1);
|
||||
results.emplace_back( id, std::move(value) );
|
||||
|
@ -21,7 +21,8 @@
|
||||
|
||||
#include <climits> // For INT_MAX
|
||||
|
||||
TEST(Statement, invalid) {
|
||||
TEST(Statement, invalid)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -103,7 +104,8 @@ SQLite::Statement StatementBuilder(SQLite::Database& aDb, const char* apQuery)
|
||||
return SQLite::Statement(aDb, apQuery);
|
||||
}
|
||||
|
||||
TEST(Statement, moveConstructor) {
|
||||
TEST(Statement, moveConstructor)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)"));
|
||||
@ -130,7 +132,8 @@ TEST(Statement, moveConstructor) {
|
||||
|
||||
#endif
|
||||
|
||||
TEST(Statement, executeStep) {
|
||||
TEST(Statement, executeStep)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -182,7 +185,8 @@ TEST(Statement, executeStep) {
|
||||
EXPECT_THROW(insert2.exec(), SQLite::Exception);
|
||||
}
|
||||
|
||||
TEST(Statement, tryExecuteStep) {
|
||||
TEST(Statement, tryExecuteStep)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -227,7 +231,8 @@ TEST(Statement, tryExecuteStep) {
|
||||
EXPECT_EQ(insert.tryReset(), SQLITE_CONSTRAINT);
|
||||
}
|
||||
|
||||
TEST(Statement, bindings) {
|
||||
TEST(Statement, bindings)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -393,7 +398,8 @@ TEST(Statement, bindings) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Statement, bindNoCopy) {
|
||||
TEST(Statement, bindNoCopy)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -432,7 +438,8 @@ TEST(Statement, bindNoCopy) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Statement, bindByName) {
|
||||
TEST(Statement, bindByName)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -538,7 +545,8 @@ TEST(Statement, bindByName) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Statement, bindNoCopyByName) {
|
||||
TEST(Statement, bindNoCopyByName)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -577,7 +585,8 @@ TEST(Statement, bindNoCopyByName) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Statement, isColumnNull) {
|
||||
TEST(Statement, isColumnNull)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
ASSERT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -639,7 +648,8 @@ TEST(Statement, isColumnNull) {
|
||||
EXPECT_THROW(query.isColumnNull(3), SQLite::Exception);
|
||||
}
|
||||
|
||||
TEST(Statement, isColumnNullByName) {
|
||||
TEST(Statement, isColumnNullByName)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
|
||||
ASSERT_EQ(SQLITE_OK, db.getErrorCode());
|
||||
@ -701,7 +711,8 @@ TEST(Statement, isColumnNullByName) {
|
||||
EXPECT_THROW(query.isColumnNull(3), SQLite::Exception);
|
||||
}
|
||||
|
||||
TEST(Statement, getColumnByName) {
|
||||
TEST(Statement, getColumnByName)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -737,7 +748,8 @@ TEST(Statement, getColumnByName) {
|
||||
EXPECT_EQ(0.123, real);
|
||||
}
|
||||
|
||||
TEST(Statement, getName) {
|
||||
TEST(Statement, getName)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT)"));
|
||||
@ -763,7 +775,8 @@ TEST(Statement, getName) {
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
TEST(Statement, getColumns) {
|
||||
TEST(Statement, getColumns)
|
||||
{
|
||||
struct GetRowTestStruct
|
||||
{
|
||||
int id;
|
||||
@ -819,7 +832,8 @@ TEST(Statement, getColumns) {
|
||||
#endif
|
||||
|
||||
#if (LONG_MAX > INT_MAX) // sizeof(long)==8 means the data model of the system is LP64 (64bits Linux)
|
||||
TEST(Statement, bind64bitsLong) {
|
||||
TEST(Statement, bind64bitsLong)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
@ -832,7 +846,8 @@ TEST(Statement, bind64bitsLong) {
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Statement, getBindParameterCount) {
|
||||
TEST(Statement, getBindParameterCount)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT)"));
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
TEST(Transaction, commitRollback) {
|
||||
TEST(Transaction, commitRollback)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||
|
@ -20,7 +20,8 @@
|
||||
#include <cstdio>
|
||||
|
||||
#if (__cplusplus >= 201103L) || ( defined(_MSC_VER) && (_MSC_VER >= 1800) ) // c++11: Visual Studio 2013
|
||||
TEST(VariadicBind, invalid) {
|
||||
TEST(VariadicBind, invalid)
|
||||
{
|
||||
// Create a new database
|
||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
|
||||
@ -56,7 +57,8 @@ TEST(VariadicBind, invalid) {
|
||||
{
|
||||
SQLite::Statement query(db, std::string{"SELECT id, value FROM test ORDER BY id"});
|
||||
std::vector<std::pair<int, std::string> > results;
|
||||
while (query.executeStep()) {
|
||||
while (query.executeStep())
|
||||
{
|
||||
const int id = query.getColumn(0);
|
||||
std::string value = query.getColumn(1);
|
||||
results.emplace_back( id, std::move(value) );
|
||||
@ -90,7 +92,8 @@ TEST(VariadicBind, invalid) {
|
||||
{
|
||||
SQLite::Statement query(db, std::string{"SELECT id, value FROM test2 ORDER BY id"});
|
||||
std::vector<std::pair<int, std::string> > results;
|
||||
while (query.executeStep()) {
|
||||
while (query.executeStep())
|
||||
{
|
||||
const int id = query.getColumn(0);
|
||||
std::string value = query.getColumn(1);
|
||||
results.emplace_back( id, std::move(value) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user