File: test_parameterized.cxx

package info (click to toggle)
libpqxx 4.0.1%2Bdfsg3-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,012 kB
  • ctags: 9,469
  • sloc: sh: 11,289; cpp: 10,801; xml: 1,256; makefile: 287; ansic: 195; python: 159
file content (29 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "test_helpers.hxx"

#include "pqxx/config-internal-libpq.h"

using namespace PGSTD;
using namespace pqxx;

namespace
{
void test_exec_params(transaction_base &trans)
{
  if (!trans.conn().supports(connection_base::cap_parameterized_statements))
    return;

  result r = trans.parameterized("SELECT $1 + 1")(12).exec();
  PQXX_CHECK_EQUAL(
	r[0][0].as<int>(),
	13,
	"Bad outcome from parameterized statement.");

  r = trans.parameterized("SELECT $1 || 'bar'")("foo").exec();
  PQXX_CHECK_EQUAL(
	r[0][0].as<string>(),
	"foobar",
	"Incorrect string result from parameterized statement.");
}
} // namespace

PQXX_REGISTER_TEST(test_exec_params)