From efcea3a80da7c4479d5fe168435ecc9fd06bdc72 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 14 Sep 2025 00:16:10 -0400 Subject: Squashed 'subprojects/boost-sqlite/' content from commit 3378e35 git-subtree-dir: subprojects/boost-sqlite git-subtree-split: 3378e353705271e569cf4ba15c467b840a39798c --- test/backup.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/backup.cpp (limited to 'test/backup.cpp') diff --git a/test/backup.cpp b/test/backup.cpp new file mode 100644 index 0000000..5a42c50 --- /dev/null +++ b/test/backup.cpp @@ -0,0 +1,46 @@ +// +// Copyright (c) 2022 Klemens Morgenstern (klemens.morgenstern@gmx.net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + + +#include +#include + +#include +#include + +#include "test.hpp" + +using namespace boost; + +BOOST_AUTO_TEST_CASE(backup) +{ + sqlite::connection conn1{":memory:"}; + conn1.execute( +#include "test-db.sql" + ); + // language=sqlite + conn1.query("select * from author;"); + + + sqlite::connection conn2{":memory:"}; + sqlite::backup(conn1, conn2); + + std::vector names1, names2; + + // language=sqlite + for (auto r : conn1.query("select first_name from author;")) + names1.emplace_back(r.at(0u).get_text()); + + // language=sqlite + for (auto r : conn2.query("select first_name from author;")) + names2.emplace_back(r.at(0u).get_text()); + + BOOST_CHECK(!names1.empty()); + BOOST_CHECK(!names2.front().empty()); + BOOST_CHECK(names1 == names2); + BOOST_CHECK_THROW(sqlite::backup(conn1, conn2, "foo", "bar"), boost::system::system_error); +} \ No newline at end of file -- cgit v1.2.3