mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 17:56:13 -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")
|
set(CPPLINT_ARG_LINELENGTH "--linelength=120")
|
||||||
|
|
||||||
# Print CXX compiler information
|
# Print CXX compiler information
|
||||||
message (STATUS "CMAKE_CXX_COMPILER_ID '${CMAKE_CXX_COMPILER_ID}'")
|
message (STATUS "CMAKE_CXX_COMPILER '${CMAKE_CXX_COMPILER}' '${CMAKE_CXX_COMPILER_ID}' '${CMAKE_CXX_COMPILER_VERSION}'")
|
||||||
message (STATUS "CMAKE_CXX_COMPILER_VERSION '${CMAKE_CXX_COMPILER_VERSION}'")
|
|
||||||
|
|
||||||
# Print CXX FLAGS
|
# Print CXX FLAGS
|
||||||
message (STATUS "CMAKE_CXX_FLAGS '${CMAKE_CXX_FLAGS}'")
|
message (STATUS "CMAKE_CXX_FLAGS '${CMAKE_CXX_FLAGS}'")
|
||||||
|
@ -124,6 +124,16 @@ TEST(Statement, executeStep) {
|
|||||||
|
|
||||||
// Step after "the end" throw an exception
|
// Step after "the end" throw an exception
|
||||||
EXPECT_THROW(query.executeStep(), SQLite::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) {
|
TEST(Statement, bindings) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user