1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add a test for the (failure) case of client-level code calling the oo1.Stmt constructor directly.

FossilOrigin-Name: 6a37874db04f3b4842994ad17fc74cb6222f8ea0fa1315a23aff1ffa69bcd12a
This commit is contained in:
stephan
2022-12-24 13:46:27 +00:00
parent 4b4ae86445
commit 0db1c90137
4 changed files with 26 additions and 17 deletions

View File

@@ -1219,7 +1219,7 @@ self.sqlite3InitModule = sqlite3InitModule;
})
////////////////////////////////////////////////////////////////////
.t('DB.Stmt', function(S){
.t('DB.Stmt', function(sqlite3){
let st = this.db.prepare(
new TextEncoder('utf-8').encode("select 3 as a")
);
@@ -1274,6 +1274,12 @@ self.sqlite3InitModule = sqlite3InitModule;
}
T.assert(!st.pointer)
.assert(0===this.db.openStatementCount());
T.mustThrowMatching(()=>new sqlite3.oo1.Stmt("hi"), function(err){
return (err instanceof sqlite3.SQLite3Error)
&& capi.SQLITE_MISUSE === err.resultCode
&& 0 < err.message.indexOf("Do not call the Stmt constructor directly.")
});
})
////////////////////////////////////////////////////////////////////////