File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < cstdlib>
3+ #include < sqlite_modern_cpp.h>
4+ #include < catch.hpp>
5+
6+
7+ #ifdef MODERN_SQLITE_STRINGVIEW_SUPPORT
8+ #include < string_view>
9+
10+ using namespace sqlite ;
11+ using namespace std ;
12+ TEST_CASE (" std::string_view works" , " [string_view]" ) {
13+ database db (" :memory:" );;
14+ db << " CREATE TABLE foo (a integer, b string);\n " ;
15+ const std::string_view test1 = " null terminated string view" ;
16+ db << " INSERT INTO foo VALUES (?, ?)" << 1 << test1;
17+ std::string str;
18+ db << " SELECT b from FOO where a=?;" << 1 >> str;
19+ REQUIRE (test1 == str);
20+ const char s[] = " hello world" ;
21+ std::string_view test2 (&s[0 ], 2 );
22+ db << " INSERT INTO foo VALUES (?,?)" << 2 << test2;
23+ db << " SELECT b from FOO where a=?" << 2 >> str;
24+ REQUIRE (str == " he" );
25+ }
26+ #endif
You can’t perform that action at this time.
0 commit comments