--- a/test/database.c Wed Jan 21 18:02:19 2026 +0100 +++ b/test/database.c Wed Jan 21 18:19:31 2026 +0100 @@ -176,24 +176,6 @@ } } -CX_TEST(testConnectionExec) { - CX_TEST_DO { - CX_TEST_ASSERT(conn); - - int t1 = dbuConnectionExec(conn, "create table ExecTest1(a int);"); - CX_TEST_ASSERT(t1 == 0); - - int t2 = dbuConnectionExec(conn, "insert into ExecTest1(a) values (1);"); - CX_TEST_ASSERT(t2 == 0); - - int t3 = dbuConnectionExec(conn, "drop table ExecTest1;"); - CX_TEST_ASSERT(t3 == 0); - - int fail = dbuConnectionExec(conn, "select * from Fail;"); - CX_TEST_ASSERT(fail != 0); - } -} - CX_TEST(testSingleValueQuery) { CX_TEST_DO { CX_TEST_ASSERT(conn); @@ -246,13 +228,29 @@ } } -CX_TEST(testSqlExecParam) { +CX_TEST(testSqlExec) { CX_TEST_DO { + CX_TEST_ASSERT(conn); + + int t1 = dbuSqlExec(conn, "create table ExecTest1(a int);"); + CX_TEST_ASSERT(t1 == 0); + + int t2 = dbuSqlExec(conn, "insert into ExecTest1(a) values (1);"); + CX_TEST_ASSERT(t2 == 0); + + int t3 = dbuSqlExec(conn, "drop table ExecTest1;"); + CX_TEST_ASSERT(t3 == 0); + + int fail = dbuSqlExec(conn, "select * from Fail;"); + CX_TEST_ASSERT(fail != 0); + + CX_TEST_ASSERT(dbuSqlExec(conn, "PRAGMA foreign_keys = ON;") == 0); CX_TEST_ASSERT(dbuSqlExec(conn, "create table ExecTest3( " "test1_id integer primary key autoincrement, " - "value int);") == 0); + "value int, " + "str text);") == 0); CX_TEST_ASSERT(dbuSqlExec(conn, "create table ExecTest4( " "test2_id integer primary key autoincrement, " @@ -262,6 +260,21 @@ // fail test CX_TEST_ASSERT(dbuSqlExec(conn, "insert into ExecTest4(exectest1_id, value) values (-999, 123);") != 0); + + // param tests + CX_TEST_ASSERT(dbuSqlExecParamInt32(conn, "insert into ExecTest3(value) values (?);", 11) == 0); + CX_TEST_ASSERT(dbuSqlExecParamUInt32(conn, "insert into ExecTest3(value) values (?);", 12) == 0); + CX_TEST_ASSERT(dbuSqlExecParamInt64(conn, "insert into ExecTest3(value) values (?);", 4000000000L) == 0); + CX_TEST_ASSERT(dbuSqlExecParamUInt64(conn, "insert into ExecTest3(value) values (?);", 5000000000L) == 0); + CX_TEST_ASSERT(dbuSqlExecParamString(conn, "insert into ExecTest3(str) values (?);", "str1") == 0); + CX_TEST_ASSERT(dbuSqlExecParamCxString(conn, "insert into ExecTest3(str) values (?);", cx_str("str2")) == 0); + CX_TEST_ASSERT(dbuSqlExecParamCxMutStr(conn, "insert into ExecTest3(str) values (?);", cx_mutstr("str3")) == 0); + + // param macro test + CX_TEST_ASSERT(dbuSqlExecParam(conn, "insert into ExecTest3(value) values (?);", 111) == 0); + CX_TEST_ASSERT(dbuSqlExecParam(conn, "insert into ExecTest3(str) values (?);", "str4") == 0); + CX_TEST_ASSERT(dbuSqlExecParam(conn, "insert into ExecTest3(str) values (?);", cx_str("str5")) == 0); + CX_TEST_ASSERT(dbuSqlExecParam(conn, "insert into ExecTest3(str) values (?);", cx_mutstr("str6")) == 0); } }