FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlite_orm/tests/simple_query.cpp at master · fnc12/sqlite_orm · GitHub
fnc12
/
sqlite_orm
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
343
Star
2.7k
Code
Issues
13
Pull requests
3
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlite_orm
/
tests
/
simple_query.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (48 loc) · 1.46 KB
Breadcrumbs
sqlite_orm
/
tests
/
simple_query.cpp
Copy path
File metadata and controls
51 lines (48 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
42
43
44
45
46
47
48
49
50
51
#
include
<
sqlite_orm/sqlite_orm.h
>
#
include
<
catch2/catch_all.hpp
>
using
namespace
sqlite_orm
;
TEST_CASE
(
"
Simple query
"
) {
auto
storage =
make_storage
(
"
"
);
{
//
SELECT 1
auto
one = storage.
select
(
1
);
REQUIRE
(one.
size
() ==
1
);
REQUIRE
(one.
front
() ==
1
);
}
{
//
SELECT 'ototo'
auto
ototo = storage.
select
(
"
ototo
"
);
REQUIRE
(ototo.
size
() ==
1
);
REQUIRE
(ototo.
front
() ==
"
ototo
"
);
}
{
//
SELECT 1 + 1
auto
two = storage.
select
(
c
(
1
) +
1
);
REQUIRE
(two.
size
() ==
1
);
REQUIRE
(two.
front
() ==
2
);
auto
twoAgain = storage.
select
(
add
(
1
,
1
));
REQUIRE
(two == twoAgain);
}
{
//
SELECT 10 / 5, 2 * 4
auto
math = storage.
select
(
columns
(
sqlite_orm::div
(
10
,
5
),
mul
(
2
,
4
)));
REQUIRE
(math.
size
() ==
1
);
REQUIRE
(math.
front
() ==
std::make_tuple
(
2
,
8
));
}
{
//
SELECT 1, 2
auto
twoRows = storage.
select
(
columns
(
1
,
2
));
REQUIRE
(twoRows.
size
() ==
1
);
REQUIRE
(std::get<
0
>(twoRows.
front
()) ==
1
);
REQUIRE
(std::get<
1
>(twoRows.
front
()) ==
2
);
}
{
//
SELECT 1, 2
//
UNION ALL
//
SELECT 3, 4;
auto
twoRowsUnion = storage.
select
(
union_all
(
select
(
columns
(
1
,
2
)),
select
(
columns
(
3
,
4
))));
REQUIRE
(twoRowsUnion.
size
() ==
2
);
REQUIRE
(twoRowsUnion[
0
] ==
std::make_tuple
(
1
,
2
));
REQUIRE
(twoRowsUnion[
1
] ==
std::make_tuple
(
3
,
4
));
}
}
Back
|
FazBrowse Home
|
New Git URL