From c5ea1d47da471505bc8cbe377f8893d2ef27766c Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 11 Jan 2024 14:57:24 +0100 Subject: [PATCH] Add test to make sure unset pg_result_t behaves sensibly --- tests/test-pgsql.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test-pgsql.cpp b/tests/test-pgsql.cpp index a38fac374..b92f61b52 100644 --- a/tests/test-pgsql.cpp +++ b/tests/test-pgsql.cpp @@ -135,3 +135,13 @@ TEST_CASE("create table and insert something") REQUIRE(result.num_tuples() == 0); REQUIRE(result.affected_rows() == 2); } + +TEST_CASE("empty result object should return fatal status") +{ + pg_result_t result; + REQUIRE(result.status() == PGRES_FATAL_ERROR); + REQUIRE_FALSE(result); + REQUIRE(result.num_fields() == 0); + REQUIRE(result.num_tuples() == 0); + REQUIRE(result.affected_rows() == 0); +}