-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathstd_optional.cc
More file actions
31 lines (25 loc) · 818 Bytes
/
std_optional.cc
File metadata and controls
31 lines (25 loc) · 818 Bytes
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
#include <iostream>
#include <sqlite_modern_cpp.h>
#include <catch2/catch.hpp>
using namespace sqlite;
using namespace std;
#ifdef MODERN_SQLITE_STD_OPTIONAL_SUPPORT
TEST_CASE("std::optional works", "[optional]") {
database db(":memory:");
db << "drop table if exists test";
db <<
"create table if not exists test ("
" id integer primary key,"
" val int"
");";
db << "insert into test(id,val) values(?,?)" << 1 << 5;
db << "select id,val from test" >> [&](long long, sqlite::optional<int> val) {
REQUIRE(val);
};
db << "delete from test where id = 1";
db << "insert into test(id,val) values(?,?)" << 1 << nullptr;
db << "select id,val from test" >> [&](long long, sqlite::optional<int> val) {
REQUIRE(!val);
};
}
#endif