Skip to content

Commit d0c5119

Browse files
committed
Fixed typo | added test
1 parent 9d22b0c commit d0c5119

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

hdr/sqlite_modern_cpp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ template <typename BoostOptionalT> database_binder::chain_type& operator <<(data
471471
exceptions::throw_sqlite_error(hresult);
472472
}
473473

474-
++db._inx;
474+
++db->_inx;
475475
return db;
476476
}
477477

tests/shared_connection.cc

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <iostream>
2+
#include <cstdlib>
3+
#include <unistd.h>
4+
#include <sqlite_modern_cpp.h>
5+
6+
using namespace sqlite;
7+
using namespace std;
8+
9+
struct TmpFile {
10+
string fname;
11+
12+
TmpFile() {
13+
char f[] = "/tmp/sqlite_modern_cpp_test_XXXXXX";
14+
int fid = mkstemp(f);
15+
close(fid);
16+
17+
fname = f;
18+
}
19+
20+
~TmpFile() {
21+
unlink(fname.c_str());
22+
}
23+
};
24+
25+
int main() {
26+
try {
27+
28+
TmpFile file;
29+
database db(file.fname);
30+
31+
{
32+
33+
auto con = db.get_sqlite3_connection();
34+
35+
{
36+
database db2(con);
37+
int test = 0;
38+
db2 << "select 1" >> test;
39+
if(test != 1) exit(EXIT_FAILURE);
40+
}
41+
42+
int test = 0;
43+
db << "select 1" >> test;
44+
if(test != 1) exit(EXIT_FAILURE);
45+
46+
}
47+
48+
49+
} catch(sqlite_exception e) {
50+
cout << "Unexpected error " << e.what() << endl;
51+
exit(EXIT_FAILURE);
52+
} catch(...) {
53+
cout << "Unknown error\n";
54+
exit(EXIT_FAILURE);
55+
}
56+
57+
cout << "OK\n";
58+
exit(EXIT_SUCCESS);
59+
}

0 commit comments

Comments
 (0)