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

Function main

tests/simple_examples.cc:20–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18};
19
20int main()
21{
22 try
23 {
24 TmpFile file;
25 database db(file.fname);
26
27 db << "CREATE TABLE foo (a integer, b string);";
28 db << "INSERT INTO foo VALUES (?, ?)" << 1 << "hello";
29 db << "INSERT INTO foo VALUES (?, ?)" << 2 << "world";
30
31 string str;
32 db << "SELECT b from FOO where a=?;" << 2L >> str;
33
34 if(str != "world")
35 {
36 cout << "Bad result on line " << __LINE__ << endl;
37 exit(EXIT_FAILURE);
38 }
39
40 std::string sql("select 1+1");
41 long test = 0;
42 db << sql >> test;
43
44 if(test != 2) exit(EXIT_FAILURE);
45
46 }
47 catch(sqlite_exception e)
48 {
49 cout << "Unexpected error " << e.what() << endl;
50 exit(EXIT_FAILURE);
51 }
52 catch(...)
53 {
54 cout << "Unknown error\n";
55 exit(EXIT_FAILURE);
56 }
57
58 cout << "OK\n";
59 exit(EXIT_SUCCESS);
60}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected