@@ -32,7 +32,8 @@ TEST(Database, ctorExecCreateDropExist) {
3232 remove (" test.db3" );
3333 {
3434 // Try to open an unexisting database
35- EXPECT_THROW (SQLite::Database not_found (" test.db3" ), SQLite::Exception);
35+ std::string filename = " test.db3" ;
36+ EXPECT_THROW (SQLite::Database not_found (filename), SQLite::Exception);
3637
3738 // Create a new database
3839 SQLite::Database db (" test.db3" , SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
@@ -92,20 +93,31 @@ TEST(Database, inMemory) {
9293 } // Close an destroy DB
9394}
9495
95- #if SQLITE_VERSION_NUMBER >= 3007015 // first version with PRAGMA busy_timeout
96+ #if SQLITE_VERSION_NUMBER >= 3007015 // SQLite v3.7.15 is first version with PRAGMA busy_timeout
9697TEST (Database, busyTimeout) {
97- // Create a new database
98- SQLite::Database db (" :memory:" );
99- // Busy timeout default to 0ms: any contention between threads or process leads to SQLITE_BUSY error
100- EXPECT_EQ (0 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
98+ {
99+ // Create a new database with default timeout of 0ms
100+ SQLite::Database db (" :memory:" );
101+ // Busy timeout default to 0ms: any contention between threads or process leads to SQLITE_BUSY error
102+ EXPECT_EQ (0 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
101103
102- // Set a non null busy timeout: any contention between threads will leads to as much retry as possible during the time
103- db.setBusyTimeout (5000 );
104- EXPECT_EQ (5000 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
104+ // Set a non null busy timeout: any contention between threads will leads to as much retry as possible during the time
105+ db.setBusyTimeout (5000 );
106+ EXPECT_EQ (5000 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
105107
106- // Reset timeout to null
107- db.setBusyTimeout (0 );
108- EXPECT_EQ (0 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
108+ // Reset timeout to 0
109+ db.setBusyTimeout (0 );
110+ EXPECT_EQ (0 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
111+ }
112+ {
113+ // Create a new database with a non null busy timeout
114+ SQLite::Database db (" :memory:" , SQLITE_OPEN_READWRITE, 5000 );
115+ EXPECT_EQ (5000 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
116+
117+ // Reset timeout to null
118+ db.setBusyTimeout (0 );
119+ EXPECT_EQ (0 , db.execAndGet (" PRAGMA busy_timeout" ).getInt ());
120+ }
109121}
110122#endif // SQLITE_VERSION_NUMBER >= 3007015
111123
0 commit comments