| 17 | }; |
| 18 | |
| 19 | int 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 | } |
nothing calls this directly
no test coverage detected