Skip to content

Commit

Permalink
Fix inequality assertions for real numbers failing on Valgrind
Browse files Browse the repository at this point in the history
using appropriate EXPECT_DOUBLE_EQ()
instead of EXPECT_EQ()
  • Loading branch information
SRombauts committed Aug 29, 2023
1 parent e4ca307 commit 99e069a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tests/Column_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void test_column_basis(bool utf16)
EXPECT_STREQ("first", ptxt);
EXPECT_EQ("first", msg);
EXPECT_EQ(-123, integer);
EXPECT_EQ(0.123, real);
EXPECT_DOUBLE_EQ(0.123, real);
EXPECT_EQ(0, memcmp("bl\0b", pblob, size));
#if !defined(_MSC_VER) || _MSC_VER >= 1900
EXPECT_EQ((size_t)size, sblob.size());
Expand Down Expand Up @@ -129,7 +129,7 @@ static void test_column_basis(bool utf16)
EXPECT_EQ("first", msg1);
EXPECT_EQ("first", msg2);
EXPECT_EQ(-123, integer);
EXPECT_EQ(0.123, real);
EXPECT_DOUBLE_EQ(0.123, real);
EXPECT_EQ(0, memcmp("bl\0b", pblob, 4));
EXPECT_EQ(0, memcmp("bl\0b", &sblob[0], 4));
}
Expand Down Expand Up @@ -195,7 +195,7 @@ static void test_column_basis(bool utf16)
const SQLite::Column integer = query.getColumn(2);
EXPECT_EQ(-123, integer.getInt());
const SQLite::Column dbl = query.getColumn(3);
EXPECT_EQ(0.123, dbl.getDouble());
EXPECT_DOUBLE_EQ(0.123, dbl.getDouble());
}
}

Expand Down
24 changes: 12 additions & 12 deletions tests/Statement_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ TEST(Statement, executeStep)
EXPECT_EQ("first", msg);
EXPECT_EQ(123, integer);
EXPECT_EQ(123, integer2);
EXPECT_EQ(0.123, real);
EXPECT_DOUBLE_EQ(0.123, real);

// Step one more time to discover there is nothing more
query.executeStep();
Expand Down Expand Up @@ -227,7 +227,7 @@ TEST(Statement, tryExecuteStep)
EXPECT_EQ("first", msg);
EXPECT_EQ(123, integer);
EXPECT_EQ(123, integer2);
EXPECT_EQ(0.123, real);
EXPECT_DOUBLE_EQ(0.123, real);

// Step one more time to discover there is nothing more
EXPECT_EQ(query.tryExecuteStep(), SQLITE_DONE);
Expand Down Expand Up @@ -343,7 +343,7 @@ TEST(Statement, bindings)
EXPECT_EQ(4, query.getColumn(0).getInt64());
EXPECT_EQ(fourth, query.getColumn(1).getText());
EXPECT_EQ(12345678900000LL, query.getColumn(2).getInt64());
EXPECT_EQ(0.234f, query.getColumn(3).getDouble());
EXPECT_DOUBLE_EQ(0.234, query.getColumn(3).getDouble());
}

// reset() without clearbindings()
Expand All @@ -364,7 +364,7 @@ TEST(Statement, bindings)
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_DOUBLE_EQ(0.234, query.getColumn(3).getDouble());
}


Expand Down Expand Up @@ -510,7 +510,7 @@ TEST(Statement, bindByName)
EXPECT_EQ(second, query.getColumn(1).getText());
EXPECT_EQ(-123, query.getColumn(2).getInt());
EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64());
EXPECT_EQ(0.234f, query.getColumn(4).getDouble());
EXPECT_DOUBLE_EQ(0.234, query.getColumn(4).getDouble());
}

// reset() without clearbindings()
Expand All @@ -531,7 +531,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(4).getDouble());
EXPECT_DOUBLE_EQ(0.234, query.getColumn(4).getDouble());
}

// reset() without clearbindings()
Expand Down Expand Up @@ -595,7 +595,7 @@ TEST(Statement, bindByNameString)
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_DOUBLE_EQ(0.123, query.getColumn(3).getDouble());
EXPECT_EQ(-123, query.getColumn(4).getInt());

// reset() with clearbindings() and new bindings
Expand All @@ -622,7 +622,7 @@ TEST(Statement, bindByNameString)
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_DOUBLE_EQ(0.234, query.getColumn(3).getDouble());
EXPECT_EQ(-123, query.getColumn(4).getInt());
}

Expand All @@ -644,7 +644,7 @@ TEST(Statement, bindByNameString)
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_DOUBLE_EQ(0.234, query.getColumn(3).getDouble());
}

// reset() without clearbindings()
Expand Down Expand Up @@ -899,7 +899,7 @@ TEST(Statement, getColumnByName)
const double real = query.getColumn("double");
EXPECT_EQ("first", msg);
EXPECT_EQ(123, integer);
EXPECT_EQ(0.123, real);
EXPECT_DOUBLE_EQ(0.123, real);
}

TEST(Statement, getName)
Expand Down Expand Up @@ -1000,14 +1000,14 @@ TEST(Statement, getColumns)
EXPECT_EQ(1, testStruct.id);
EXPECT_EQ("first", testStruct.msg);
EXPECT_EQ(123, testStruct.integer);
EXPECT_EQ(0.123, testStruct.real);
EXPECT_DOUBLE_EQ(0.123, testStruct.real);

// Get only the first 2 columns
auto testStruct2 = query.getColumns<GetRowTestStruct, 2>();
EXPECT_EQ(1, testStruct2.id);
EXPECT_EQ("first", testStruct2.msg);
EXPECT_EQ(-1, testStruct2.integer);
EXPECT_EQ(0.0, testStruct2.real);
EXPECT_DOUBLE_EQ(0.0, testStruct2.real);
}
#endif

Expand Down

0 comments on commit 99e069a

Please sign in to comment.