summaryrefslogtreecommitdiff
path: root/src/pq/test_pq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pq/test_pq.c')
-rw-r--r--src/pq/test_pq.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c
index c89313b64..bda227587 100644
--- a/src/pq/test_pq.c
+++ b/src/pq/test_pq.c
@@ -13,7 +13,6 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
-
/**
* @file pq/test_pq.c
* @brief Tests for Postgres convenience API
@@ -61,10 +60,14 @@ postgres_prepare (PGconn *db_conn)
",namount_frac"
",namount_curr"
",vsize"
+ ",u16"
+ ",u32"
+ ",u64"
+ ",json"
") VALUES "
"($1, $2, $3, $4, $5, $6,"
- "$7, $8, $9, $10, $11, $12);",
- 11, NULL);
+ "$7, $8, $9, $10, $11, $12, $13, $14, $15, $16);",
+ 16, NULL);
PREPARE ("test_select",
"SELECT"
" pub"
@@ -79,6 +82,10 @@ postgres_prepare (PGconn *db_conn)
",namount_frac"
",namount_curr"
",vsize"
+ ",u16"
+ ",u32"
+ ",u64"
+ ",json"
" FROM test_pq"
" ORDER BY abs_time DESC "
" LIMIT 1;",
@@ -116,6 +123,14 @@ run_queries (PGconn *conn)
char msg[] = "Hello";
void *msg2;
size_t msg2_len;
+ uint16_t u16;
+ uint16_t u162;
+ uint32_t u32;
+ uint32_t u322;
+ uint64_t u64;
+ uint64_t u642;
+ json_t *json;
+ json_t *json2;
priv = GNUNET_CRYPTO_rsa_private_key_create (1024);
pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv);
@@ -130,6 +145,12 @@ run_queries (PGconn *conn)
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount ("EUR:4.4",
&hamount));
+ u16 = 16;
+ u32 = 32;
+ u64 = 64;
+ json = json_object ();
+ json_object_set (json, "foo", json_integer (42));
+ GNUNET_assert (NULL != json);
/* FIXME: test TALER_PQ_result_spec_variable_size */
{
struct TALER_PQ_QueryParam params_insert[] = {
@@ -141,6 +162,10 @@ run_queries (PGconn *conn)
TALER_PQ_query_param_amount (&hamount),
TALER_PQ_query_param_amount_nbo (&namount),
TALER_PQ_query_param_fixed_size (msg, strlen (msg)),
+ TALER_PQ_query_param_uint16 (&u16),
+ TALER_PQ_query_param_uint32 (&u32),
+ TALER_PQ_query_param_uint64 (&u64),
+ TALER_PQ_query_param_json (json),
TALER_PQ_query_param_end
};
struct TALER_PQ_QueryParam params_select[] = {
@@ -155,6 +180,10 @@ run_queries (PGconn *conn)
TALER_PQ_result_spec_amount ("hamount", &hamount2),
TALER_PQ_result_spec_amount_nbo ("namount", &namount2),
TALER_PQ_result_spec_variable_size ("vsize", &msg2, &msg2_len),
+ TALER_PQ_result_spec_uint16 ("u16", &u162),
+ TALER_PQ_result_spec_uint32 ("u32", &u322),
+ TALER_PQ_result_spec_uint64 ("u64", &u642),
+ TALER_PQ_result_spec_json ("json", &json2),
TALER_PQ_result_spec_end
};
@@ -219,7 +248,11 @@ run_queries (PGconn *conn)
strncmp (msg,
msg2,
msg2_len));
-
+ GNUNET_break (16 == u162);
+ GNUNET_break (32 == u322);
+ GNUNET_break (64 == u642);
+ GNUNET_break (42 == json_integer_value (json_object_get (json2, "foo")));
+ json_decref (json2);
TALER_PQ_cleanup_result (results_select);
PQclear (result);
}
@@ -269,6 +302,10 @@ main(int argc,
",namount_frac INT4 NOT NULL"
",namount_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
",vsize VARCHAR NOT NULL"
+ ",u16 INT2 NOT NULL"
+ ",u32 INT4 NOT NULL"
+ ",u64 INT8 NOT NULL"
+ ",json VARCHAR NOT NULL"
")");
if (PGRES_COMMAND_OK != PQresultStatus (result))
{