From 6c3600bcb7acf3b8f5679fab564adad3a9ec0fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Sun, 24 Jul 2022 14:48:36 +0200 Subject: [PATCH] Fix Statement unit test using long long & long long api have been replaced by int32_t and int64_t types TODO: we need to continue cleanup APIs to remove all long from the codebase before we can release a new version --- tests/Statement_test.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/Statement_test.cpp b/tests/Statement_test.cpp index 8a79a18f..2117adf9 100644 --- a/tests/Statement_test.cpp +++ b/tests/Statement_test.cpp @@ -327,7 +327,7 @@ TEST(Statement, bindings) // Fourth row with string/int64/float { const std::string fourth("fourth"); - const long long int64 = 12345678900000LL; + const int64_t int64 = 12345678900000LL; const float float32 = 0.234f; insert.bind(1, fourth); insert.bind(2, int64); @@ -370,7 +370,7 @@ TEST(Statement, bindings) // reset() without clearbindings() insert.reset(); - // Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b long long) + // Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b int64_t) { const uint32_t uint32 = 4294967295U; const long integer = -123; @@ -455,11 +455,11 @@ TEST(Statement, bindByName) EXPECT_EQ(SQLite::OK, db.getErrorCode()); // Create a new table - EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, int INTEGER, double REAL, long INTEGER)")); + EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, int INTEGER, long INTEGER, double REAL)")); EXPECT_EQ(SQLite::OK, db.getErrorCode()); // Insertion with bindable parameters - SQLite::Statement insert(db, "INSERT INTO test VALUES (NULL, @msg, @int, @double, @long)"); + SQLite::Statement insert(db, "INSERT INTO test VALUES (NULL, @msg, @int, @long, @double)"); // First row with text/int/double insert.bind("@msg", "first"); @@ -481,8 +481,8 @@ TEST(Statement, bindByName) EXPECT_EQ (1, query.getColumn(0).getInt64()); EXPECT_STREQ("first", query.getColumn(1).getText()); EXPECT_EQ (123, query.getColumn(2).getInt()); - EXPECT_EQ (0.123, query.getColumn(3).getDouble()); - EXPECT_EQ (-123, query.getColumn(4).getInt()); + EXPECT_EQ (-123, query.getColumn(3).getInt()); + EXPECT_EQ (0.123, query.getColumn(4).getDouble()); // reset() with clearbindings() and new bindings insert.reset(); @@ -491,13 +491,13 @@ TEST(Statement, bindByName) // Second row with string/int64/float { const std::string second("second"); - const long long int64 = 12345678900000LL; - const long integer = -123; + const int32_t int32 = -123; + const int64_t int64 = 12345678900000LL; const float float32 = 0.234f; insert.bind("@msg", second); - insert.bind("@int", int64); + insert.bind("@int", int32); + insert.bind("@long", int64); insert.bind("@double", float32); - insert.bind("@long", integer); EXPECT_EQ(1, insert.exec()); EXPECT_EQ(SQLITE_DONE, db.getErrorCode()); @@ -507,9 +507,9 @@ TEST(Statement, bindByName) EXPECT_FALSE(query.isDone()); EXPECT_EQ(2, query.getColumn(0).getInt64()); EXPECT_EQ(second, query.getColumn(1).getText()); - EXPECT_EQ(12345678900000LL, query.getColumn(2).getInt64()); - EXPECT_EQ(0.234f, query.getColumn(3).getDouble()); - EXPECT_EQ(-123, query.getColumn(4).getInt()); + EXPECT_EQ(-123, query.getColumn(2).getInt()); + EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64()); + EXPECT_EQ(0.234f, query.getColumn(4).getDouble()); } // reset() without clearbindings() @@ -530,7 +530,7 @@ TEST(Statement, bindByName) EXPECT_STREQ(buffer, query.getColumn(1).getText()); EXPECT_TRUE (query.isColumnNull(2)); EXPECT_EQ(0, query.getColumn(2).getInt()); - EXPECT_EQ(0.234f, query.getColumn(3).getDouble()); + EXPECT_EQ(0.234f, query.getColumn(4).getDouble()); } // reset() without clearbindings() @@ -551,7 +551,7 @@ TEST(Statement, bindByName) EXPECT_FALSE(query.isDone()); EXPECT_EQ(4, query.getColumn(0).getInt64()); EXPECT_EQ(4294967295U, query.getColumn(2).getUInt()); - EXPECT_EQ(12345678900000LL, query.getColumn(4).getInt64()); + EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64()); } } @@ -604,7 +604,7 @@ TEST(Statement, bindByNameString) // Second row with string/int64/float { const std::string second("second"); - const long long int64 = 12345678900000LL; + const int64_t int64 = 12345678900000LL; const long integer = -123; const float float32 = 0.234f; insert.bind(amsg, second);