From 9b81cdebba95f1b6e687191c630c1f8f6cf0df16 Mon Sep 17 00:00:00 2001
From: znone <glyc@sina.com.cn>
Date: Thu, 25 Mar 2021 12:44:30 +0000
Subject: [PATCH] PostgreSQL: Support asynchronous operation Fix bug in different versions of asio
---
test/TestPostgres.cpp | 44 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/test/TestPostgres.cpp b/test/TestPostgres.cpp
index eeab3f2..60ee70a 100644
--- a/test/TestPostgres.cpp
+++ b/test/TestPostgres.cpp
@@ -73,6 +73,10 @@
{
ASSERT_EXCEPTION(e);
}
+ catch (std::exception& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
}
void TestPostgres::test_select()
@@ -83,7 +87,7 @@
try
{
db.query("select * from test where id=$1", 0, id,
- [](const qtl::indicator<int32_t>& id, const std::string& name, const qtl::postgres::timestamp& create_time) {
+ [](const qtl::indicator<int32_t>& id, const std::string& name, const qtl::postgres::timestamp& create_time, const std::vector<int32_t>& v, const std::tuple<int, int>& pt) {
printf("ID=\"%d\", Name=\"%s\"\n",
id.data, name.data());
});
@@ -101,6 +105,10 @@
{
ASSERT_EXCEPTION(e);
}
+ catch (std::exception& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
}
void TestPostgres::test_insert()
@@ -110,10 +118,15 @@
try
{
- db.query_first("insert into test(Name, CreateTime) values($1, LOCALTIMESTAMP) returning ID",
- "test_user", id);
+ int32_t va[] = { 200, 300, 400 };
+ db.query_first("insert into test(Name, CreateTime, va, percent) values($1, LOCALTIMESTAMP, $2, $3) returning ID",
+ std::forward_as_tuple("test_user", va, std::make_pair(11, 22)), id);
}
catch (qtl::postgres::error& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
+ catch (std::exception& e)
{
ASSERT_EXCEPTION(e);
}
@@ -136,6 +149,10 @@
{
ASSERT_EXCEPTION(e);
}
+ catch (std::exception& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
}
void TestPostgres::test_update()
@@ -152,7 +169,10 @@
{
ASSERT_EXCEPTION(e);
}
- TEST_ASSERT_MSG(id > 0, "insert failture.");
+ catch (std::exception& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
}
void TestPostgres::test_clear()
@@ -165,6 +185,10 @@
db.simple_execute("delete from test");
}
catch (qtl::postgres::error& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
+ catch (std::exception& e)
{
ASSERT_EXCEPTION(e);
}
@@ -185,6 +209,10 @@
}
}
catch (qtl::postgres::error& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
+ catch (std::exception& e)
{
ASSERT_EXCEPTION(e);
}
@@ -233,6 +261,10 @@
{
ASSERT_EXCEPTION(e);
}
+ catch (std::bad_cast& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
}
void TestPostgres::test_select_blob()
@@ -271,6 +303,10 @@
{
ASSERT_EXCEPTION(e);
}
+ catch (std::bad_cast& e)
+ {
+ ASSERT_EXCEPTION(e);
+ }
}
void TestPostgres::test_any()
--
Gitblit v1.9.3