diff options
-rw-r--r-- | libdbpp/unittests/Jamfile.jam | 6 | ||||
-rw-r--r-- | libdbpp/unittests/dollarQuote.sql | 1 | ||||
-rw-r--r-- | libdbpp/unittests/scriptDir.sql | 1 | ||||
-rw-r--r-- | libdbpp/unittests/stringParse.sql | 1 | ||||
-rw-r--r-- | libdbpp/unittests/testConnection.cpp | 37 | ||||
-rw-r--r-- | libdbpp/unittests/unterminatedComment.sql | 4 | ||||
-rw-r--r-- | libdbpp/unittests/unterminatedDollarQuote.sql | 1 | ||||
-rw-r--r-- | libdbpp/unittests/unterminatedString.sql | 1 |
8 files changed, 52 insertions, 0 deletions
diff --git a/libdbpp/unittests/Jamfile.jam b/libdbpp/unittests/Jamfile.jam index cee679f..b7b2170 100644 --- a/libdbpp/unittests/Jamfile.jam +++ b/libdbpp/unittests/Jamfile.jam @@ -13,6 +13,12 @@ run <library>..//adhocutil <library>boost_utf <dependency>parseTest.sql + <dependency>unterminatedComment.sql + <dependency>unterminatedString.sql + <dependency>unterminatedDollarQuote.sql + <dependency>dollarQuote.sql + <dependency>scriptDir.sql + <dependency>stringParse.sql : testConnection ; diff --git a/libdbpp/unittests/dollarQuote.sql b/libdbpp/unittests/dollarQuote.sql new file mode 100644 index 0000000..5b52274 --- /dev/null +++ b/libdbpp/unittests/dollarQuote.sql @@ -0,0 +1 @@ +CREATE TABLE $a$dollarQuotes$a$( a text ); diff --git a/libdbpp/unittests/scriptDir.sql b/libdbpp/unittests/scriptDir.sql new file mode 100644 index 0000000..4d3e461 --- /dev/null +++ b/libdbpp/unittests/scriptDir.sql @@ -0,0 +1 @@ +INSERT INTO dollarQuotes(a) VALUES('$SCRIPTDIR'); diff --git a/libdbpp/unittests/stringParse.sql b/libdbpp/unittests/stringParse.sql new file mode 100644 index 0000000..e764da9 --- /dev/null +++ b/libdbpp/unittests/stringParse.sql @@ -0,0 +1 @@ +INSERT INTO dollarQuotes(a) VALUES('apos''trophe'); diff --git a/libdbpp/unittests/testConnection.cpp b/libdbpp/unittests/testConnection.cpp index 6d9cd05..ed727de 100644 --- a/libdbpp/unittests/testConnection.cpp +++ b/libdbpp/unittests/testConnection.cpp @@ -78,6 +78,43 @@ BOOST_AUTO_TEST_CASE( parse ) delete mock; } +BOOST_AUTO_TEST_CASE( parse2 ) +{ + auto mock = DB::ConnectionPtr(DB::ConnectionFactory::createNew("MockDb", "doesn't matter")); + std::fstream s; + + s.open((rootDir / "dollarQuote.sql").string()); + mock->executeScript(s, rootDir); + s.close(); + + s.open((rootDir / "scriptDir.sql").string()); + mock->executeScript(s, rootDir); + s.close(); + + s.open((rootDir / "stringParse.sql").string()); + mock->executeScript(s, rootDir); + s.close(); + + BOOST_REQUIRE_THROW({ + s.open((rootDir / "unterminatedComment.sql").string()); + mock->executeScript(s, rootDir); + }, std::runtime_error); + s.close(); + + BOOST_REQUIRE_THROW({ + s.open((rootDir / "unterminatedDollarQuote.sql").string()); + mock->executeScript(s, rootDir); + }, std::runtime_error); + s.close(); + + BOOST_REQUIRE_THROW({ + s.open((rootDir / "unterminatedString.sql").string()); + mock->executeScript(s, rootDir); + }, std::runtime_error); + s.close(); +} + + BOOST_AUTO_TEST_CASE( savepoints ) { auto mock = DB::ConnectionFactory::createNew("MockDb", "doesn't matter"); diff --git a/libdbpp/unittests/unterminatedComment.sql b/libdbpp/unittests/unterminatedComment.sql new file mode 100644 index 0000000..299e639 --- /dev/null +++ b/libdbpp/unittests/unterminatedComment.sql @@ -0,0 +1,4 @@ +/* + * I + * don't + * end diff --git a/libdbpp/unittests/unterminatedDollarQuote.sql b/libdbpp/unittests/unterminatedDollarQuote.sql new file mode 100644 index 0000000..06fe430 --- /dev/null +++ b/libdbpp/unittests/unterminatedDollarQuote.sql @@ -0,0 +1 @@ +CREATE TABLE $a$dollarQuote diff --git a/libdbpp/unittests/unterminatedString.sql b/libdbpp/unittests/unterminatedString.sql new file mode 100644 index 0000000..cdd4b49 --- /dev/null +++ b/libdbpp/unittests/unterminatedString.sql @@ -0,0 +1 @@ +INSERT INTO dollarQuotes(a) VALUES('i don''t end |