3 #include "../sqlite3_helper.hpp"
4 #include "test_cxx_gen.hpp"
5 #include <boost/foreach.hpp>
11 typedef sqlgg
<sqlite3_traits
> gen
;
14 void to_console(const wchar_t* s)
16 HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
19 WriteConsoleW(console, s, wcslen(s), &ignore, NULL);
22 void to_console(const std::wstring& s)
24 to_console(s.c_str());
28 void explain(char const* msg
, sqlite3
* db
)
30 cout
<< msg
<< " : " /*<< sqlite3_errcode(db) << " "*/ << sqlite3_errmsg(db
) << endl
;
36 int nResult
= SQLITE_OK
;
38 nResult
= sqlite3_open("test.db", &db
);
41 nResult
= sqlite3_exec(db
,"DROP TABLE test;",NULL
,NULL
,NULL
);
43 nResult
= sqlite3_exec(db
,"DROP TABLE loc;",NULL
,NULL
,NULL
);
45 nResult
= sqlite3_exec(db
,"DROP TABLE zuzu;",NULL
,NULL
,NULL
);
48 nResult
= gen::create(db
);
55 nResult = gen::Add(db,t);
56 cout << "insert : " << nResult << " " << sqlite3_errmsg(db) << endl;
58 nResult
= gen::Add(db
,"c++","ugly");
61 nResult
= gen::Add(db
,"c","hard");
64 nResult
= gen::Add(db
,"ocaml","wonderful");
67 nResult
= gen::Exaggerate(db
,"really");
70 std::vector
<gen::data_1
> all
;
71 nResult
= gen::select_all(db
,all
);
74 BOOST_FOREACH(gen::data_1
const& q
, all
)
76 std::cout
<< q
.id
<< ") " << q
.name
<< " is " << q
.descr
<< std::endl
;
80 explain("create_loc",db
);
82 nResult
= gen::create_zuzu(db
,"qq");
83 explain("create_zuzu",db
);
85 nResult
= sqlite3_close(db
);
86 cout
<< "close : " << nResult
<< endl
;