mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Fix part of issue #34 about 64 bits long with GCC on AMD64
This commit is contained in:
parent
7e16e8545f
commit
078365febc
@ -199,6 +199,16 @@ public:
|
||||
return getText();
|
||||
}
|
||||
#endif
|
||||
// NOTE : the following is required by GCC and Clang to cast a Column result in a long/int64_t
|
||||
/// @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
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
TEST(Column, basis) {
|
||||
@ -54,7 +54,9 @@ TEST(Column, basis) {
|
||||
|
||||
// validates every variant of cast operators, and conversions of types
|
||||
{
|
||||
int64_t id = query.getColumn(0); // operator sqlite3_int64()
|
||||
sqlite3_int64 id = query.getColumn(0); // operator sqlite3_int64()
|
||||
int64_t id2 = query.getColumn(0); // operator sqlite3_int64() (or long() with GCC 64bits)
|
||||
long id3 = query.getColumn(0); // operator sqlite3_int64() (or long() with GCC 64bits)
|
||||
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 int integer = query.getColumn(2); // operator int()
|
||||
@ -62,6 +64,8 @@ TEST(Column, basis) {
|
||||
const void* pblob = query.getColumn(4); // operator void*()
|
||||
const void* pempty = query.getColumn(5); // operator void*()
|
||||
EXPECT_EQ(1, id);
|
||||
EXPECT_EQ(1, id2);
|
||||
EXPECT_EQ(1, id3);
|
||||
EXPECT_STREQ("first", ptxt);
|
||||
EXPECT_EQ("first", msg);
|
||||
EXPECT_EQ(123, integer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user