• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Ensure we reject connections when SQLite is in single-threaded mode, as it
2 //! would violate safety if multiple Rust threads tried to use connections.
3 
4 use rusqlite::ffi;
5 use rusqlite::Connection;
6 
7 #[test]
8 #[should_panic]
test_error_when_singlethread_mode()9 fn test_error_when_singlethread_mode() {
10     // put SQLite into single-threaded mode
11     unsafe {
12         if ffi::sqlite3_config(ffi::SQLITE_CONFIG_SINGLETHREAD) != ffi::SQLITE_OK {
13             return;
14         }
15         if ffi::sqlite3_initialize() != ffi::SQLITE_OK {
16             return;
17         }
18     }
19 
20     let _ = Connection::open_in_memory().unwrap();
21 }
22