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

Function main

tests/flags.cc:27–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25#endif
26
27int main()
28{
29 try
30 {
31 TmpFile file;
32 sqlite::sqlite_config cfg;
33 std::string enc;
34 {
35 database db(":memory:", cfg);
36 db << "PRAGMA encoding;" >> enc;
37 if(enc != "UTF-8") {
38 cout << "Unexpected encoding on line " << __LINE__ << '\n';
39 exit(EXIT_FAILURE);
40 }
41 }
42 {
43 database db(u":memory:", cfg);
44 db << "PRAGMA encoding;" >> enc;
45 if(enc != OUR_UTF16) {
46 cout << "Unexpected encoding on line " << __LINE__ << '\n';
47 exit(EXIT_FAILURE);
48 }
49 }
50 {
51 cfg.encoding = Encoding::UTF8;
52 database db(u":memory:", cfg);
53 db << "PRAGMA encoding;" >> enc;
54 if(enc != "UTF-8") {
55 cout << "Unexpected encoding on line " << __LINE__ << '\n';
56 exit(EXIT_FAILURE);
57 }
58 }
59 {
60 cfg.encoding = Encoding::UTF16;
61 database db(u":memory:", cfg);
62 db << "PRAGMA encoding;" >> enc;
63 if(enc != OUR_UTF16) {
64 cout << "Unexpected encoding on line " << __LINE__ << '\n';
65 exit(EXIT_FAILURE);
66 }
67 }
68 {
69 database db(file.fname, cfg);
70 db << "PRAGMA encoding;" >> enc;
71 if(enc != OUR_UTF16) {
72 cout << "Unexpected encoding on line " << __LINE__ << '\n';
73 exit(EXIT_FAILURE);
74 }
75
76 db << "CREATE TABLE foo (a string);";
77 db << "INSERT INTO foo VALUES (?)" << "hello";
78 }
79 {
80 cfg.flags = sqlite::OpenFlags::READONLY;
81 database db(file.fname, cfg);
82
83 string str;
84 db << "SELECT a FROM foo;" >> str;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected