1 | #include "catch.hpp" |
---|---|
2 | #include "duckdb.h" |
3 | |
4 | using namespace std; |
5 | |
6 | TEST_CASE("Simple In-Memory DB Start Up and Shutdown", "[simplestartup]") { |
7 | duckdb_database database; |
8 | duckdb_connection connection; |
9 | |
10 | // open and close a database in in-memory mode |
11 | REQUIRE(duckdb_open(NULL, &database) == DuckDBSuccess); |
12 | REQUIRE(duckdb_connect(database, &connection) == DuckDBSuccess); |
13 | duckdb_disconnect(&connection); |
14 | duckdb_close(&database); |
15 | } |
16 | |
17 | TEST_CASE("Multiple In-Memory DB Start Up and Shutdown", "[multiplestartup]") { |
18 | duckdb_database database[10]; |
19 | duckdb_connection connection[100]; |
20 | |
21 | // open and close 10 databases |
22 | // and open 10 connections per database |
23 | for (size_t i = 0; i < 10; i++) { |
24 | REQUIRE(duckdb_open(NULL, &database[i]) == DuckDBSuccess); |
25 | for (size_t j = 0; j < 10; j++) { |
26 | REQUIRE(duckdb_connect(database[i], &connection[i * 10 + j]) == DuckDBSuccess); |
27 | } |
28 | } |
29 | for (size_t i = 0; i < 10; i++) { |
30 | for (size_t j = 0; j < 10; j++) { |
31 | duckdb_disconnect(&connection[i * 10 + j]); |
32 | } |
33 | duckdb_close(&database[i]); |
34 | } |
35 | } |
36 |