Files
Library/tests/package/SqliteOnly/main.cpp

20 lines
657 B
C++

#include <Void/Sqlite/Sqlite.hpp>
int main()
{
Void::Sqlite::OpenOptions opts;
auto db = Void::Sqlite::open_database(":memory:", opts);
if (!db) return 1;
if (!db->exec("CREATE TABLE t(id INTEGER PRIMARY KEY)").has_value()) return 2;
auto tx = db->begin(Void::Sqlite::BeginMode::Immediate);
if (!tx) return 3;
auto st = db->prepare("INSERT INTO t(id) VALUES(?)");
if (!st) return 4;
if (!st->bind_checked(1, Void::Sqlite::ValueView{7}).has_value()) return 5;
if (!st->step().has_value()) return 6;
if (!st->finalize_checked().has_value()) return 7;
if (!tx->commit().has_value()) return 8;
if (!db->close().has_value()) return 9;
return 0;
}