MCPcopy Create free account
hub / github.com/SqliteModernCpp/sqlite_modern_cpp / main

Function main

tests/functors.cc:19–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17};
18
19int main() {
20
21 try {
22 database db(":memory:");
23 db << "CREATE TABLE tbl (id integer, name string);";
24 db << "INSERT INTO tbl VALUES (?, ?);" << 1 << "hello";
25 db << "INSERT INTO tbl VALUES (?, ?);" << 2 << "world";
26
27 vector<pair<int,string> > vec;
28 db << "select id,name from tbl;" >> tbl_functor(vec);
29
30 if(vec.size() != 2) {
31 cout << "Bad result on line " << __LINE__ << endl;
32 exit(EXIT_FAILURE);
33 }
34
35 vec.clear();
36
37 tbl_functor functor(vec);
38 db << "select id,name from tbl;" >> functor;
39
40 if(vec.size() != 2 || vec[0].first != 1 || vec[0].second != "hello") {
41 cout << "Bad result on line " << __LINE__ << endl;
42 exit(EXIT_FAILURE);
43 }
44
45 }
46 catch(sqlite_exception e) {
47 cout << "Unexpected error " << e.what() << endl;
48 exit(EXIT_FAILURE);
49 }
50 catch(...) {
51 cout << "Unknown error\n";
52 exit(EXIT_FAILURE);
53 }
54
55 cout << "OK\n";
56 exit(EXIT_SUCCESS);
57}

Callers

nothing calls this directly

Calls 1

tbl_functorClass · 0.85

Tested by

no test coverage detected