diff --git a/Tests/LibSQL/TestSqlDatabase.cpp b/Tests/LibSQL/TestSqlDatabase.cpp index 1128f8f6f8..f5738af391 100644 --- a/Tests/LibSQL/TestSqlDatabase.cpp +++ b/Tests/LibSQL/TestSqlDatabase.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2021, Jan de Visser + * Copyright (c) 2023, Jelle Raaijmakers * * SPDX-License-Identifier: BSD-2-Clause */ @@ -7,6 +8,8 @@ #include #include +#include +#include #include #include #include @@ -15,21 +18,15 @@ #include #include -NonnullRefPtr setup_schema(SQL::Database&); -NonnullRefPtr setup_table(SQL::Database&); -void insert_into_table(SQL::Database&, int); -void verify_table_contents(SQL::Database&, int); -void insert_and_verify(int); -void commit(SQL::Database&); - -NonnullRefPtr setup_schema(SQL::Database& db) +static NonnullRefPtr setup_schema(SQL::Database& db) { auto schema = SQL::SchemaDef::construct("TestSchema"); MUST(db.add_schema(schema)); return schema; } -NonnullRefPtr setup_table(SQL::Database& db) +// FIXME: using the return value for SQL::TableDef to insert a row results in a segfault +static NonnullRefPtr setup_table(SQL::Database& db) { auto schema = setup_schema(db); auto table = SQL::TableDef::construct(schema, "TestTable"); @@ -40,7 +37,7 @@ NonnullRefPtr setup_table(SQL::Database& db) return table; } -void insert_into_table(SQL::Database& db, int count) +static void insert_into_table(SQL::Database& db, int count) { auto table = MUST(db.get_table("TestSchema", "TestTable")); @@ -55,7 +52,7 @@ void insert_into_table(SQL::Database& db, int count) } } -void verify_table_contents(SQL::Database& db, int expected_count) +static void verify_table_contents(SQL::Database& db, int expected_count) { auto table = MUST(db.get_table("TestSchema", "TestTable")); @@ -73,12 +70,12 @@ void verify_table_contents(SQL::Database& db, int expected_count) EXPECT_EQ(sum, (expected_count * (expected_count - 1)) / 2); } -void commit(SQL::Database& db) +static void commit(SQL::Database& db) { TRY_OR_FAIL(db.commit()); } -void insert_and_verify(int count) +static void insert_and_verify(int count) { ScopeGuard guard([]() { unlink("/tmp/test.db"); }); {