blob: de9a566fd504ac43dfff0843b9a7acda4ca9c5cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "googletest.h"
#include <sqlitefunctionregistry.h>
namespace {
class SqliteFunctionRegistry : public testing::Test
{
public:
SqliteFunctionRegistry() { Sqlite::FunctionRegistry::registerPathExists(database); }
protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
};
TEST_F(SqliteFunctionRegistry, PathExists)
{
std::lock_guard lock{database};
Sqlite::ReadStatement<1> statement{"SELECT pathExists('" TESTDATA_DIR "/sqlite_database.db')",
database};
auto pathExists = statement.value<bool>();
ASSERT_TRUE(pathExists);
}
TEST_F(SqliteFunctionRegistry, PathDoesntExists)
{
std::lock_guard lock{database};
Sqlite::ReadStatement<1> statement{"SELECT pathExists('" TESTDATA_DIR "/sqlite_database2.db')",
database};
auto pathExists = statement.value<bool>();
ASSERT_FALSE(pathExists);
}
} // namespace
|