gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: fix test_mustach_jansson and act


From: gnunet
Subject: [taler-merchant] branch master updated: fix test_mustach_jansson and actually run it during test suite
Date: Sat, 29 Aug 2020 11:50:49 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new eed3d0d  fix test_mustach_jansson and actually run it during test suite
eed3d0d is described below

commit eed3d0d330ff6ce9462b913777c3aa121370ac8a
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Aug 29 11:50:47 2020 +0200

    fix test_mustach_jansson and actually run it during test suite
---
 .../taler-merchant-httpd_private-get-tips-ID.c     |  21 +--
 src/mustach/Makefile.am                            |   2 +-
 src/mustach/test_mustach_jansson.c                 | 142 +++++++++++++--------
 3 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-tips-ID.c 
b/src/backend/taler-merchant-httpd_private-get-tips-ID.c
index ba4e2f6..881012e 100644
--- a/src/backend/taler-merchant-httpd_private-get-tips-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-tips-ID.c
@@ -123,15 +123,18 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler 
*rh,
     GNUNET_assert (NULL != pickups_json);
     for (unsigned int i = 0; i<pickups_length; i++)
     {
-      json_array_append_new (
-        pickups_json,
-        json_pack ("{s:o,s:I,s:o}",
-                   "pickup_id",
-                   GNUNET_JSON_from_data_auto (&pickups[i].pickup_id),
-                   "num_planchets",
-                   (json_int_t) pickups[i].num_planchets,
-                   "requested_amount",
-                   TALER_JSON_from_amount (&pickups[i].requested_amount)));
+      GNUNET_assert (0 ==
+                     json_array_append_new (
+                       pickups_json,
+                       json_pack ("{s:o,s:I,s:o}",
+                                  "pickup_id",
+                                  GNUNET_JSON_from_data_auto (
+                                    &pickups[i].pickup_id),
+                                  "num_planchets",
+                                  (json_int_t) pickups[i].num_planchets,
+                                  "requested_amount",
+                                  TALER_JSON_from_amount (
+                                    &pickups[i].requested_amount))));
     }
   }
   GNUNET_array_grow (pickups,
diff --git a/src/mustach/Makefile.am b/src/mustach/Makefile.am
index ac9f284..b43476a 100644
--- a/src/mustach/Makefile.am
+++ b/src/mustach/Makefile.am
@@ -26,4 +26,4 @@ check_PROGRAMS = \
 check_SCRIPTS = \
   run-original-tests.sh
 
-TESTS = $(check_SCRIPTS)
+TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
diff --git a/src/mustach/test_mustach_jansson.c 
b/src/mustach/test_mustach_jansson.c
index ed49983..93ef05f 100644
--- a/src/mustach/test_mustach_jansson.c
+++ b/src/mustach/test_mustach_jansson.c
@@ -25,74 +25,109 @@
 #include "platform.h"
 #include "mustach-jansson.h"
 
-void
-assert_template (const char *template, json_t *root, const char *expected)
+
+static void
+assert_template (const char *template,
+                 json_t *root,
+                 const char *expected)
 {
   char *r;
   size_t sz;
 
-  GNUNET_assert (0 == mustach_jansson (template, root, &r, &sz));
-  GNUNET_assert (0 == strcmp (r, expected));
+  GNUNET_assert (0 == mustach_jansson (template,
+                                       root,
+                                       &r,
+                                       &sz));
+  GNUNET_assert (0 == strcmp (r,
+                              expected));
   GNUNET_free (r);
 }
 
+
 int
 main (int argc,
       char *const *argv)
 {
   json_t *root = json_object ();
   json_t *arr = json_array ();
-  json_t *obj = json_object();
+  json_t *obj = json_object ();
   json_t *contract;
   /* test 1 */
-  char *t1 = "hello world";
-  char *x1 = "hello world";
+  const char *t1 = "hello world";
+  const char *x1 = "hello world";
   /* test 2 */
-  char *t2 = "hello {{ v1 }}";
-  char *x2 = "hello world";
+  const char *t2 = "hello {{ v1 }}";
+  const char *x2 = "hello world";
   /* test 3 */
-  char *t3 = "hello {{ v3.x }}";
-  char *x3 = "hello baz";
+  const char *t3 = "hello {{ v3.x }}";
+  const char *x3 = "hello baz";
   /* test 4 */
-  char *t4 = "hello {{# v2 }}{{ . }}{{/ v2 }}";
-  char *x4 = "hello foobar";
+  const char *t4 = "hello {{# v2 }}{{ . }}{{/ v2 }}";
+  const char *x4 = "hello foobar";
   /* test 5 */
-  char *t5 = "hello {{# v3 }}{{ y }}/{{ x }}{{ z }}{{/ v3 }}";
-  char *x5 = "hello quux/baz";
+  const char *t5 = "hello {{# v3 }}{{ y }}/{{ x }}{{ z }}{{/ v3 }}";
+  const char *x5 = "hello quux/baz";
   /* test 6 */
-  char *t6 = "hello {{ v2!stringify }}";
-  char *x6 = "hello [\n  \"foo\",\n  \"bar\"\n]";
+  const char *t6 = "hello {{ v2!stringify }}";
+  const char *x6 = "hello [\n  \"foo\",\n  \"bar\"\n]";
   /* test 7 */
-  char *t7 = "amount: {{ amt!amount_decimal }} {{ amt!amount_currency }}";
-  char *x7 = "amount: 123.00 EUR";
+  const char *t7 = "amount: {{ amt!amount_decimal }} {{ amt!amount_currency 
}}";
+  const char *x7 = "amount: 123.00 EUR";
   /* test 8 */
-  char *t8 = "{{^ v4 }}fallback{{/ v4 }}";
-  char *x8 = "fallback";
+  const char *t8 = "{{^ v4 }}fallback{{/ v4 }}";
+  const char *x8 = "fallback";
 
   /* contract test 8 (contract) */
-  char *tc = "summary: {{ summary!i18n }}";
-  char *xc_en = "summary: ENGLISH";
-  char *xc_de = "summary: DEUTSCH";
-  char *xc_fr = "summary: FRANCAISE";
-
-  json_object_set_new (root, "v1", json_string ("world"));
-  json_object_set_new (root, "v4", json_array ());
-  json_array_append_new (arr, json_string ("foo"));
-  json_array_append_new (arr, json_string ("bar"));
-  json_object_set_new (root, "v2", arr);
-  json_object_set_new (root, "v3", obj);
-  json_object_set_new (root, "amt", json_string("EUR:123.00"));
-  json_object_set_new (obj, "x", json_string ("baz"));
-  json_object_set_new (obj, "y", json_string ("quux"));
-
-  contract = json_pack("{ s:s, s:{s:s, s:s}}",
-                       "summary",
-                       "ENGLISH",
-                       "summary_i18n",
-                       "de",
-                       "DEUTSCH",
-                       "fr",
-                       "FRANCAISE");
+  const char *tc = "summary: {{ summary!i18n }}";
+  const char *xc_en = "summary: ENGLISH";
+  const char *xc_de = "summary: DEUTSCH";
+  const char *xc_fr = "summary: FRANCAISE";
+
+  GNUNET_assert (NULL != root);
+  GNUNET_assert (NULL != arr);
+  GNUNET_assert (NULL != obj);
+  GNUNET_assert (0 ==
+                 json_object_set_new (root,
+                                      "v1",
+                                      json_string ("world")));
+  GNUNET_assert (0 ==
+                 json_object_set_new (root,
+                                      "v4",
+                                      json_array ()));
+  GNUNET_assert (0 ==
+                 json_array_append_new (arr,
+                                        json_string ("foo")));
+  GNUNET_assert (0 ==
+                 json_array_append_new (arr,
+                                        json_string ("bar")));
+  GNUNET_assert (0 ==
+                 json_object_set_new (root,
+                                      "v2",
+                                      arr));
+  GNUNET_assert (0 ==
+                 json_object_set_new (root,
+                                      "v3",
+                                      obj));
+  GNUNET_assert (0 ==
+                 json_object_set_new (root,
+                                      "amt",
+                                      json_string ("EUR:123.00")));
+  GNUNET_assert (0 ==
+                 json_object_set_new (obj,
+                                      "x",
+                                      json_string ("baz")));
+  GNUNET_assert (0 ==
+                 json_object_set_new (obj,
+                                      "y",
+                                      json_string ("quux")));
+  contract = json_pack ("{ s:s, s:{s:s, s:s}}",
+                        "summary",
+                        "ENGLISH",
+                        "summary_i18n",
+                        "de",
+                        "DEUTSCH",
+                        "fr",
+                        "FRANCAISE");
   GNUNET_assert (NULL != contract);
 
   assert_template (t1, root, x1);
@@ -103,21 +138,26 @@ main (int argc,
   assert_template (t6, root, x6);
   assert_template (t7, root, x7);
   assert_template (t8, root, x8);
-
   assert_template (tc, contract, xc_en);
 
-  json_object_set_new (contract, "$language", json_string ("de"));
+  GNUNET_assert (0 ==
+                 json_object_set_new (contract,
+                                      "$language",
+                                      json_string ("de")));
   assert_template (tc, contract, xc_de);
 
-  json_object_set_new (contract, "$language", json_string ("fr"));
+  GNUNET_assert (0 ==
+                 json_object_set_new (contract,
+                                      "$language",
+                                      json_string ("fr")));
   assert_template (tc, contract, xc_fr);
 
-  json_object_set_new (contract, "$language", json_string ("it"));
+  GNUNET_assert (0 ==
+                 json_object_set_new (contract,
+                                      "$language",
+                                      json_string ("it")));
   assert_template (tc, contract, xc_en);
-
   json_decref (root);
   json_decref (contract);
-
   return 0;
 }
-

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]