Skip to content

Commit 94a098a

Browse files
committed
Merge pull request #27 from aminroosta/fix25
Changed tests and README
2 parents 72af939 + d82cfc9 commit 94a098a

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ You can use transactions with `begin;`, `commit;` and `rollback;` commands.
105105

106106
Dealing with NULL values
107107
=====
108-
If you have databases where some rows may be null, you can use boost::optional to retain the NULL value between C++ variables and the database. Note that you must enable the boost support by including the type extension for it.
108+
If you have databases where some rows may be null, you can use boost::optional to retain the NULL value between C++ variables and the database. Note that you must enable the boost support by defining _MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT befor importing the header.
109109

110110
```c++
111111

112+
#define _MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT
112113
#include <sqlite_modern_cpp.h>
113-
#include <sqlite_modern_cpp/extensions/boost_optional.h>
114114

115115
struct User {
116116
long long _id;

tests/boost_optional.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ void select(database& db, bool should_be_null) {
1919
db << "select id,val from test" >> [&](long long id, boost::optional<int> val) {
2020
id = id;
2121
if(should_be_null) {
22-
if(val) exit(1);
22+
if(val) exit(EXIT_FAILURE);
2323
} else {
24-
if(!val) exit(1);
24+
if(!val) exit(EXIT_FAILURE);
2525
}
2626
};
2727
}
@@ -51,7 +51,7 @@ int main() {
5151
db << "drop table if exists test";
5252
db <<
5353
"create table if not exists test ("
54-
" id integer primary key autoincrement not null,"
54+
" id integer primary key,"
5555
" val int"
5656
");";
5757

@@ -63,6 +63,7 @@ int main() {
6363

6464
} catch(exception& e) {
6565
cout << e.what() << endl;
66+
exit(EXIT_FAILURE);
6667
}
67-
return 0;
68+
exit(EXIT_SUCCESS);
6869
}

tests/simple_examples.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,22 @@ int main()
4141
if(str != "world")
4242
{
4343
cout << "Bad result on line " << __LINE__ << endl;
44-
exit(1);
44+
exit(EXIT_FAILURE);
4545
}
4646

4747

4848
}
4949
catch(sqlite_exception e)
5050
{
5151
cout << "Unexpected error " << e.what() << endl;
52-
exit(1);
52+
exit(EXIT_FAILURE);
5353
}
5454
catch(...)
5555
{
5656
cout << "Unknown error\n";
57-
exit(1);
57+
exit(EXIT_FAILURE);
5858
}
5959

6060
cout << "OK\n";
61+
exit(EXIT_SUCCESS);
6162
}

0 commit comments

Comments
 (0)