Switch from sqlite3_int64 to int64_t

This commit is contained in:
Sébastien Rombauts 2016-07-05 08:02:46 +02:00
parent a2abbf1d96
commit 646d25ca95
11 changed files with 92 additions and 91 deletions

View File

@ -5,6 +5,11 @@
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers> <triggers>clean,full,incremental,</triggers>
@ -75,5 +80,6 @@
<nature>org.eclipse.cdt.core.ccnature</nature> <nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

2
cpplint.py vendored
View File

@ -4499,7 +4499,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
template = required[required_header_unstripped][1] template = required[required_header_unstripped][1]
if required_header_unstripped.strip('<>"') not in include_state: if required_header_unstripped.strip('<>"') not in include_state:
error(filename, required[required_header_unstripped][0], error(filename, required[required_header_unstripped][0],
'build/include_what_you_use', 4, 'build/include_what_you_use', 2,
'Add #include ' + required_header_unstripped + ' for ' + template) 'Add #include ' + required_header_unstripped + ' for ' + template)

View File

@ -16,6 +16,7 @@
#include <SQLiteCpp/Exception.h> #include <SQLiteCpp/Exception.h>
#include <string> #include <string>
#include <stdint.h>
namespace SQLite namespace SQLite
@ -41,13 +42,6 @@ namespace SQLite
class Column class Column
{ {
public: public:
// Make clang happy by explicitly implementing the copy-constructor:
Column(const Column & aOther) :
mStmtPtr(aOther.mStmtPtr),
mIndex(aOther.mIndex)
{
}
/** /**
* @brief Encapsulation of a Column in a Row of the result. * @brief Encapsulation of a Column in a Row of the result.
* *
@ -55,18 +49,25 @@ public:
* @param[in] aIndex Index of the column in the row of result * @param[in] aIndex Index of the column in the row of result
*/ */
Column(Statement::Ptr& aStmtPtr, int aIndex) noexcept; // nothrow Column(Statement::Ptr& aStmtPtr, int aIndex) noexcept; // nothrow
/// @brief Simple destructor /// Simple destructor
virtual ~Column() noexcept; // nothrow virtual ~Column() noexcept; // nothrow
// default copy constructor and assignment operator are perfectly suited : // default copy constructor and assignment operator are perfectly suited :
// they copy the Statement::Ptr which in turn increments the reference counter. // they copy the Statement::Ptr which in turn increments the reference counter.
/// Make clang happy by explicitly implementing the copy-constructor:
Column(const Column & aOther) :
mStmtPtr(aOther.mStmtPtr),
mIndex(aOther.mIndex)
{
}
/** /**
* @brief Return a pointer to the named assigned to this result column (potentially aliased) * @brief Return a pointer to the named assigned to this result column (potentially aliased)
* *
* @see getOriginName() to get original column name (not aliased) * @see getOriginName() to get original column name (not aliased)
*/ */
const char* getName() const noexcept; // nothrow const char* getName() const noexcept; // nothrow
#ifdef SQLITE_ENABLE_COLUMN_METADATA #ifdef SQLITE_ENABLE_COLUMN_METADATA
/** /**
@ -76,36 +77,36 @@ public:
* - when building the SQLite library itself (which is the case for the Debian libsqlite3 binary for instance), * - when building the SQLite library itself (which is the case for the Debian libsqlite3 binary for instance),
* - and also when compiling this wrapper. * - and also when compiling this wrapper.
*/ */
const char* getOriginName() const noexcept; // nothrow const char* getOriginName() const noexcept; // nothrow
#endif #endif
/// @brief Return the integer value of the column. /// Return the integer value of the column.
int getInt() const noexcept; // nothrow int getInt() const noexcept; // nothrow
/// @brief Return the 64bits integer value of the column. /// Return the 64bits integer value of the column.
sqlite3_int64 getInt64() const noexcept; // nothrow int64_t getInt64() const noexcept; // nothrow
/// @brief Return the double (64bits float) value of the column. /// Return the double (64bits float) value of the column.
double getDouble() const noexcept; // nothrow double getDouble() const noexcept; // nothrow
/** /**
* @brief Return a pointer to the text value (NULL terminated string) of the column. * @brief Return a pointer to the text value (NULL terminated string) of the column.
* *
* @warning The value pointed at is only valid while the statement is valid (ie. not finalized), * @warning The value pointed at is only valid while the statement is valid (ie. not finalized),
* thus you must copy it before using it beyond its scope (to a std::string for instance). * thus you must copy it before using it beyond its scope (to a std::string for instance).
*/ */
const char* getText(const char* apDefaultValue = "") const noexcept; // nothrow const char* getText(const char* apDefaultValue = "") const noexcept; // nothrow
/** /**
* @brief Return a pointer to the binary blob value of the column. * @brief Return a pointer to the binary blob value of the column.
* *
* @warning The value pointed at is only valid while the statement is valid (ie. not finalized), * @warning The value pointed at is only valid while the statement is valid (ie. not finalized),
* thus you must copy it before using it beyond its scope (to a std::string for instance). * thus you must copy it before using it beyond its scope (to a std::string for instance).
*/ */
const void* getBlob() const noexcept; // nothrow const void* getBlob() const noexcept; // nothrow
/** /**
* @brief Return a std::string for a TEXT or BLOB column. * @brief Return a std::string for a TEXT or BLOB column.
* *
* Note this correctly handles strings that contain null bytes. * Note this correctly handles strings that contain null bytes.
* *
*/ */
std::string getString() const noexcept; // nothrow std::string getString() const noexcept; // nothrow
/** /**
* @brief Return the type of the value of the column * @brief Return the type of the value of the column
@ -117,27 +118,27 @@ public:
*/ */
int getType() const noexcept; // nothrow int getType() const noexcept; // nothrow
/// @brief Test if the column is an integer type value (meaningful only before any conversion) /// Test if the column is an integer type value (meaningful only before any conversion)
inline bool isInteger() const noexcept // nothrow inline bool isInteger() const noexcept // nothrow
{ {
return (SQLITE_INTEGER == getType()); return (SQLITE_INTEGER == getType());
} }
/// @brief Test if the column is a floating point type value (meaningful only before any conversion) /// Test if the column is a floating point type value (meaningful only before any conversion)
inline bool isFloat() const noexcept // nothrow inline bool isFloat() const noexcept // nothrow
{ {
return (SQLITE_FLOAT == getType()); return (SQLITE_FLOAT == getType());
} }
/// @brief Test if the column is a text type value (meaningful only before any conversion) /// Test if the column is a text type value (meaningful only before any conversion)
inline bool isText() const noexcept // nothrow inline bool isText() const noexcept // nothrow
{ {
return (SQLITE_TEXT == getType()); return (SQLITE_TEXT == getType());
} }
/// @brief Test if the column is a binary blob type value (meaningful only before any conversion) /// Test if the column is a binary blob type value (meaningful only before any conversion)
inline bool isBlob() const noexcept // nothrow inline bool isBlob() const noexcept // nothrow
{ {
return (SQLITE_BLOB == getType()); return (SQLITE_BLOB == getType());
} }
/// @brief Test if the column is NULL (meaningful only before any conversion) /// Test if the column is NULL (meaningful only before any conversion)
inline bool isNull() const noexcept // nothrow inline bool isNull() const noexcept // nothrow
{ {
return (SQLITE_NULL == getType()); return (SQLITE_NULL == getType());
@ -154,28 +155,42 @@ public:
*/ */
int getBytes() const noexcept; int getBytes() const noexcept;
/// @brief Alias returning the number of bytes used by the text (or blob) value of the column /// Alias returning the number of bytes used by the text (or blob) value of the column
inline int size() const noexcept inline int size() const noexcept
{ {
return getBytes (); return getBytes ();
} }
/// @brief Inline cast operator to int /// Inline cast operator to int
inline operator int() const inline operator int() const
{ {
return getInt(); return getInt();
} }
/// @brief Inline cast operator to 32bits unsigned integer #if !defined(__x86_64__) || defined(__APPLE__)
/// Inline cast operator to long as 32bits integer for 32bit systems
inline operator long() const
{
return getInt();
}
#endif // __x86_64__
#if defined(__GNUC__) && !defined(__APPLE__)
/// Inline cast operator to long long for GCC and Clang
inline operator long long() const
{
return getInt64();
}
#endif // __GNUC__
/// Inline cast operator to 64bits integer
inline operator int64_t() const
{
return getInt64();
}
/// Inline cast operator to 32bits unsigned integer
inline operator uint32_t() const inline operator uint32_t() const
{ {
return static_cast<uint32_t>(getInt64()); return static_cast<uint32_t>(getInt64());
} }
/// @brief Inline cast operator to 64bits integer /// Inline cast operator to double
inline operator sqlite3_int64() const
{
return getInt64();
}
/// @brief Inline cast operator to double
inline operator double() const inline operator double() const
{ {
return getDouble(); return getDouble();
@ -218,18 +233,7 @@ public:
} }
#endif #endif
// NOTE : the following is required by GCC and Clang to cast a Column result in a long/int64_t /// Return UTF-8 encoded English language explanation of the most recent error.
/// @brief Inline cast operator to long as 64bits integer
inline operator long() const
{
#ifdef __x86_64__
return getInt64();
#else
return getInt();
#endif
}
/// @brief Return UTF-8 encoded English language explanation of the most recent error.
inline const char* errmsg() const inline const char* errmsg() const
{ {
return sqlite3_errmsg(mStmtPtr); return sqlite3_errmsg(mStmtPtr);

View File

@ -237,7 +237,7 @@ public:
* *
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none. * @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
*/ */
inline sqlite3_int64 getLastInsertRowid() const noexcept // nothrow inline int64_t getLastInsertRowid() const noexcept // nothrow
{ {
return sqlite3_last_insert_rowid(mpSQLite); return sqlite3_last_insert_rowid(mpSQLite);
} }
@ -252,25 +252,25 @@ public:
return sqlite3_total_changes(mpSQLite); return sqlite3_total_changes(mpSQLite);
} }
/// @brief Return the filename used to open the database. /// Return the filename used to open the database.
inline const std::string& getFilename() const noexcept // nothrow inline const std::string& getFilename() const noexcept // nothrow
{ {
return mFilename; return mFilename;
} }
/// @brief Return the numeric result code for the most recent failed API call (if any). /// Return the numeric result code for the most recent failed API call (if any).
inline int getErrorCode() const noexcept // nothrow inline int getErrorCode() const noexcept // nothrow
{ {
return sqlite3_errcode(mpSQLite); return sqlite3_errcode(mpSQLite);
} }
/// @brief Return the extended numeric result code for the most recent failed API call (if any). /// Return the extended numeric result code for the most recent failed API call (if any).
inline int getExtendedErrorCode() const noexcept // nothrow inline int getExtendedErrorCode() const noexcept // nothrow
{ {
return sqlite3_extended_errcode(mpSQLite); return sqlite3_extended_errcode(mpSQLite);
} }
/// @brief Return UTF-8 encoded English language explanation of the most recent failed API call (if any). /// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
inline const char* errmsg() const noexcept // nothrow inline const char* errmsg() const noexcept // nothrow
{ {
return sqlite3_errmsg(mpSQLite); return sqlite3_errmsg(mpSQLite);

View File

@ -68,14 +68,10 @@ public:
*/ */
Statement(Database& aDatabase, const std::string& aQuery); Statement(Database& aDatabase, const std::string& aQuery);
/** /// Finalize and unregister the SQL query from the SQLite Database Connection.
* @brief Finalize and unregister the SQL query from the SQLite Database Connection.
*/
virtual ~Statement() noexcept; // nothrow virtual ~Statement() noexcept; // nothrow
/** /// Reset the statement to make it ready for a new execution.
* @brief Reset the statement to make it ready for a new execution.
*/
void reset(); void reset();
/** /**
@ -110,7 +106,7 @@ public:
/** /**
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*/ */
void bind(const int aIndex, const sqlite3_int64 aValue); void bind(const int aIndex, const int64_t aValue);
/** /**
* @brief Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * @brief Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*/ */
@ -169,7 +165,7 @@ public:
/** /**
* @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*/ */
void bind(const char* apName, const sqlite3_int64 aValue); void bind(const char* apName, const int64_t aValue);
/** /**
* @brief Bind a 32bits unsigned int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * @brief Bind a 32bits unsigned int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*/ */
@ -232,7 +228,7 @@ public:
/** /**
* @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*/ */
inline void bind(const std::string& aName, const sqlite3_int64 aValue) inline void bind(const std::string& aName, const int64_t aValue)
{ {
bind(aName.c_str(), aValue); bind(aName.c_str(), aValue);
} }
@ -314,7 +310,6 @@ public:
bind(aName.c_str()); bind(aName.c_str());
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
/** /**
@ -449,32 +444,32 @@ public:
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
/// @brief Return the UTF-8 SQL Query. /// Return the UTF-8 SQL Query.
inline const std::string& getQuery() const inline const std::string& getQuery() const
{ {
return mQuery; return mQuery;
} }
/// @brief Return the number of columns in the result set returned by the prepared statement /// Return the number of columns in the result set returned by the prepared statement
inline int getColumnCount() const inline int getColumnCount() const
{ {
return mColumnCount; return mColumnCount;
} }
/// @brief true when a row has been fetched with executeStep() /// true when a row has been fetched with executeStep()
inline bool isOk() const inline bool isOk() const
{ {
return mbOk; return mbOk;
} }
/// @brief true when the last executeStep() had no more row to fetch /// true when the last executeStep() had no more row to fetch
inline bool isDone() const inline bool isDone() const
{ {
return mbDone; return mbDone;
} }
/// @brief Return the numeric result code for the most recent failed API call (if any). /// Return the numeric result code for the most recent failed API call (if any).
inline int getErrorCode() const noexcept // nothrow inline int getErrorCode() const noexcept // nothrow
{ {
return sqlite3_errcode(mStmtPtr); return sqlite3_errcode(mStmtPtr);
} }
/// @brief Return the extended numeric result code for the most recent failed API call (if any). /// Return the extended numeric result code for the most recent failed API call (if any).
inline int getExtendedErrorCode() const noexcept // nothrow inline int getExtendedErrorCode() const noexcept // nothrow
{ {
return sqlite3_extended_errcode(mStmtPtr); return sqlite3_extended_errcode(mStmtPtr);
@ -503,13 +498,13 @@ private:
// Decrement the ref counter and finalize the sqlite3_stmt when it reaches 0 // Decrement the ref counter and finalize the sqlite3_stmt when it reaches 0
~Ptr() noexcept; // nothrow (no virtual destructor needed here) ~Ptr() noexcept; // nothrow (no virtual destructor needed here)
/// @brief Inline cast operator returning the pointer to SQLite Database Connection Handle /// Inline cast operator returning the pointer to SQLite Database Connection Handle
inline operator sqlite3*() const inline operator sqlite3*() const
{ {
return mpSQLite; return mpSQLite;
} }
/// @brief Inline cast operator returning the pointer to SQLite Statement Object /// Inline cast operator returning the pointer to SQLite Statement Object
inline operator sqlite3_stmt*() const inline operator sqlite3_stmt*() const
{ {
return mpStmt; return mpStmt;

View File

@ -15,8 +15,6 @@
#include <sqlite3.h> #include <sqlite3.h>
#include <string>
namespace SQLite namespace SQLite
{ {

View File

@ -11,13 +11,11 @@
#include <SQLiteCpp/Column.h> #include <SQLiteCpp/Column.h>
#include <iostream> #include <iostream>
#include <string>
namespace SQLite namespace SQLite
{ {
// Encapsulation of a Column in a row of the result pointed by the prepared Statement. // Encapsulation of a Column in a row of the result pointed by the prepared Statement.
Column::Column(Statement::Ptr& aStmtPtr, int aIndex) noexcept : // nothrow Column::Column(Statement::Ptr& aStmtPtr, int aIndex) noexcept : // nothrow
mStmtPtr(aStmtPtr), mStmtPtr(aStmtPtr),
@ -52,7 +50,7 @@ int Column::getInt() const noexcept // nothrow
} }
// Return the 64bits integer value of the column specified by its index starting at 0 // Return the 64bits integer value of the column specified by its index starting at 0
sqlite3_int64 Column::getInt64() const noexcept // nothrow int64_t Column::getInt64() const noexcept // nothrow
{ {
return sqlite3_column_int64(mStmtPtr, mIndex); return sqlite3_column_int64(mStmtPtr, mIndex);
} }

View File

@ -14,7 +14,6 @@
#include <SQLiteCpp/Assertion.h> #include <SQLiteCpp/Assertion.h>
#include <SQLiteCpp/Exception.h> #include <SQLiteCpp/Exception.h>
#include <string>
#ifndef SQLITE_DETERMINISTIC #ifndef SQLITE_DETERMINISTIC
#define SQLITE_DETERMINISTIC 0x800 #define SQLITE_DETERMINISTIC 0x800

View File

@ -15,8 +15,6 @@
#include <SQLiteCpp/Assertion.h> #include <SQLiteCpp/Assertion.h>
#include <SQLiteCpp/Exception.h> #include <SQLiteCpp/Exception.h>
#include <string>
namespace SQLite namespace SQLite
{ {
@ -74,7 +72,7 @@ void Statement::bind(const int aIndex, const int aValue)
} }
// Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement // Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
void Statement::bind(const int aIndex, const sqlite3_int64 aValue) void Statement::bind(const int aIndex, const int64_t aValue)
{ {
const int ret = sqlite3_bind_int64(mStmtPtr, aIndex, aValue); const int ret = sqlite3_bind_int64(mStmtPtr, aIndex, aValue);
check(ret); check(ret);
@ -155,7 +153,7 @@ void Statement::bind(const char* apName, const int aValue)
} }
// Bind a 64bits int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement // Bind a 64bits int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
void Statement::bind(const char* apName, const sqlite3_int64 aValue) void Statement::bind(const char* apName, const int64_t aValue)
{ {
const int index = sqlite3_bind_parameter_index(mStmtPtr, apName); const int index = sqlite3_bind_parameter_index(mStmtPtr, apName);
const int ret = sqlite3_bind_int64(mStmtPtr, index, aValue); const int ret = sqlite3_bind_int64(mStmtPtr, index, aValue);

View File

@ -16,7 +16,6 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cstdio> #include <cstdio>
#include <stdint.h>
TEST(Column, basis) { TEST(Column, basis) {
@ -55,18 +54,20 @@ TEST(Column, basis) {
// validates every variant of cast operators, and conversions of types // validates every variant of cast operators, and conversions of types
{ {
sqlite3_int64 id = query.getColumn(0); // operator sqlite3_int64() const sqlite3_int64 id1 = query.getColumn(0); // operator int64_t()
int64_t id2 = query.getColumn(0); // operator sqlite3_int64() (or long() with GCC 64bits) const int64_t id2 = query.getColumn(0); // operator int64_t()
long id3 = query.getColumn(0); // operator sqlite3_int64() (or long() with GCC 64bits) const long long id3 = query.getColumn(0); // operator int64_t()
const long id4 = query.getColumn(0); // operator int64_t() or long() depending on compiler/architecture
const char* ptxt = query.getColumn(1); // operator const char*() const char* ptxt = query.getColumn(1); // operator const char*()
const std::string msg = query.getColumn(1); // operator std::string() (or const char* with MSVC) const std::string msg = query.getColumn(1); // operator std::string() (or const char* with MSVC)
const int integer = query.getColumn(2); // operator int() const int integer = query.getColumn(2); // operator int()
const double real = query.getColumn(3); // operator double() const double real = query.getColumn(3); // operator double()
const void* pblob = query.getColumn(4); // operator void*() const void* pblob = query.getColumn(4); // operator void*()
const void* pempty = query.getColumn(5); // operator void*() const void* pempty = query.getColumn(5); // operator void*()
EXPECT_EQ(1, id); EXPECT_EQ(1, id1);
EXPECT_EQ(1, id2); EXPECT_EQ(1, id2);
EXPECT_EQ(1, id3); EXPECT_EQ(1, id3);
EXPECT_EQ(1, id4);
EXPECT_STREQ("first", ptxt); EXPECT_STREQ("first", ptxt);
EXPECT_EQ("first", msg); EXPECT_EQ("first", msg);
EXPECT_EQ(123, integer); EXPECT_EQ(123, integer);

View File

@ -108,13 +108,15 @@ TEST(Statement, executeStep) {
query.executeStep(); query.executeStep();
EXPECT_TRUE (query.isOk()); EXPECT_TRUE (query.isOk());
EXPECT_FALSE(query.isDone()); EXPECT_FALSE(query.isDone());
const sqlite3_int64 id = query.getColumn(0); const int64_t id = query.getColumn(0);
const std::string msg = query.getColumn(1); const std::string msg = query.getColumn(1);
const int integer = query.getColumn(2); const int integer = query.getColumn(2);
const long integer2= query.getColumn(2);
const double real = query.getColumn(3); const double real = query.getColumn(3);
EXPECT_EQ(1, id); EXPECT_EQ(1, id);
EXPECT_EQ("first", msg); EXPECT_EQ("first", msg);
EXPECT_EQ(123, integer); EXPECT_EQ(123, integer);
EXPECT_EQ(123, integer2);
EXPECT_EQ(0.123, real); EXPECT_EQ(0.123, real);
// Step one more time to discover there is nothing more // Step one more time to discover there is nothing more
@ -210,10 +212,10 @@ TEST(Statement, bindings) {
insert.clearBindings(); insert.clearBindings();
// Fourth row with string/int64/float // Fourth row with string/int64/float
const std::string second("second"); const std::string fourth("fourth");
const sqlite_int64 int64 = 12345678900000LL; const int64_t int64 = 12345678900000LL;
const float float32 = 0.234f; const float float32 = 0.234f;
insert.bind(1, second); insert.bind(1, fourth);
insert.bind(2, int64); insert.bind(2, int64);
insert.bind(3, float32); insert.bind(3, float32);
EXPECT_EQ(1, insert.exec()); EXPECT_EQ(1, insert.exec());
@ -224,14 +226,14 @@ TEST(Statement, bindings) {
EXPECT_TRUE (query.isOk()); EXPECT_TRUE (query.isOk());
EXPECT_FALSE(query.isDone()); EXPECT_FALSE(query.isDone());
EXPECT_EQ(4, query.getColumn(0).getInt64()); EXPECT_EQ(4, query.getColumn(0).getInt64());
EXPECT_EQ(second, query.getColumn(1).getText()); EXPECT_EQ(fourth, query.getColumn(1).getText());
EXPECT_EQ(12345678900000LL, query.getColumn(2).getInt64()); EXPECT_EQ(12345678900000LL, query.getColumn(2).getInt64());
EXPECT_EQ(0.234f, query.getColumn(3).getDouble()); EXPECT_EQ(0.234f, query.getColumn(3).getDouble());
// reset() without clearbindings() // reset() without clearbindings()
insert.reset(); insert.reset();
// Fourth row with binary buffer and a null parameter // Fifth row with binary buffer and a null parameter
const char buffer[] = "binary"; const char buffer[] = "binary";
insert.bind(1, buffer, sizeof(buffer)); insert.bind(1, buffer, sizeof(buffer));
insert.bind(2); insert.bind(2);
@ -288,7 +290,7 @@ TEST(Statement, bindByName) {
// Second row with string/int64/float // Second row with string/int64/float
const std::string second("second"); const std::string second("second");
const sqlite_int64 int64 = 12345678900000LL; const int64_t int64 = 12345678900000LL;
const float float32 = 0.234f; const float float32 = 0.234f;
insert.bind("@msg", second); insert.bind("@msg", second);
insert.bind("@int", int64); insert.bind("@int", int64);