mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Add a unit test for error in exec()
This commit is contained in:
parent
249639ca70
commit
c0b2d81db9
@ -48,8 +48,7 @@ set(CPPLINT_ARG_VERBOSE "--verbose=3")
|
||||
set(CPPLINT_ARG_LINELENGTH "--linelength=120")
|
||||
|
||||
# Print CXX compiler information
|
||||
message (STATUS "CMAKE_CXX_COMPILER_ID '${CMAKE_CXX_COMPILER_ID}'")
|
||||
message (STATUS "CMAKE_CXX_COMPILER_VERSION '${CMAKE_CXX_COMPILER_VERSION}'")
|
||||
message (STATUS "CMAKE_CXX_COMPILER '${CMAKE_CXX_COMPILER}' '${CMAKE_CXX_COMPILER_ID}' '${CMAKE_CXX_COMPILER_VERSION}'")
|
||||
|
||||
# Print CXX FLAGS
|
||||
message (STATUS "CMAKE_CXX_FLAGS '${CMAKE_CXX_FLAGS}'")
|
||||
|
@ -124,6 +124,16 @@ TEST(Statement, executeStep) {
|
||||
|
||||
// Step after "the end" throw an exception
|
||||
EXPECT_THROW(query.executeStep(), SQLite::Exception);
|
||||
|
||||
// Try to insert a new row with the same PRIMARY KEY: "UNIQUE constraint failed: test.id"
|
||||
SQLite::Statement insert(db, "INSERT INTO test VALUES (1, \"impossible\", 456, 0.456)");
|
||||
EXPECT_THROW(insert.executeStep(), SQLite::Exception);
|
||||
// in this case, reset() do throw again the same error
|
||||
EXPECT_THROW(insert.reset(), SQLite::Exception);
|
||||
|
||||
// Try again to insert a new row with the same PRIMARY KEY (with an alternative method): "UNIQUE constraint failed: test.id"
|
||||
SQLite::Statement insert2(db, "INSERT INTO test VALUES (1, \"impossible\", 456, 0.456)");
|
||||
EXPECT_THROW(insert2.exec(), SQLite::Exception);
|
||||
}
|
||||
|
||||
TEST(Statement, bindings) {
|
||||
@ -366,9 +376,9 @@ TEST(Statement, getColumnByName) {
|
||||
EXPECT_THROW(query.getColumn("unknown"), SQLite::Exception);
|
||||
EXPECT_THROW(query.getColumn(""), SQLite::Exception);
|
||||
|
||||
const std::string msg = query.getColumn("msg");
|
||||
const int integer = query.getColumn("int");
|
||||
const double real = query.getColumn("double");
|
||||
const std::string msg = query.getColumn("msg");
|
||||
const int integer = query.getColumn("int");
|
||||
const double real = query.getColumn("double");
|
||||
EXPECT_EQ("first", msg);
|
||||
EXPECT_EQ(123, integer);
|
||||
EXPECT_EQ(0.123, real);
|
||||
|
Loading…
x
Reference in New Issue
Block a user