summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-11-08 14:33:50 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-11-08 15:10:36 +0000
commitb7b07d16c144a1c1e699091d0913d3568c6d8b46 (patch)
tree52bda3b7ca17f9c27038cf56bf319b41a5c73d83
parentAdd tests over col count and ordinal (diff)
downloadlibdbpp-b7b07d16c144a1c1e699091d0913d3568c6d8b46.tar.bz2
libdbpp-b7b07d16c144a1c1e699091d0913d3568c6d8b46.tar.xz
libdbpp-b7b07d16c144a1c1e699091d0913d3568c6d8b46.zip
Add tests over parser error handling and more complex cases
-rw-r--r--libdbpp/unittests/Jamfile.jam6
-rw-r--r--libdbpp/unittests/dollarQuote.sql1
-rw-r--r--libdbpp/unittests/scriptDir.sql1
-rw-r--r--libdbpp/unittests/stringParse.sql1
-rw-r--r--libdbpp/unittests/testConnection.cpp37
-rw-r--r--libdbpp/unittests/unterminatedComment.sql4
-rw-r--r--libdbpp/unittests/unterminatedDollarQuote.sql1
-rw-r--r--libdbpp/unittests/unterminatedString.sql1
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