diff options
Diffstat (limited to 'src/util/test_json_validations.c')
-rw-r--r-- | src/util/test_json_validations.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/util/test_json_validations.c b/src/util/test_json_validations.c new file mode 100644 index 000000000..a5747c94a --- /dev/null +++ b/src/util/test_json_validations.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | (C) 2014 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file util/test_json_validations.c | ||
19 | * @brief Tests for JSON validations | ||
20 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
21 | */ | ||
22 | |||
23 | #include "platform.h" | ||
24 | #include "taler_util.h" | ||
25 | #include "taler_json_lib.h" | ||
26 | |||
27 | static const char * const json_wire_str = | ||
28 | "{ \"type\":\"SEPA\", \ | ||
29 | \"IBAN\":\"DE67830654080004822650\", \ | ||
30 | \"name\":\"GNUnet e.V.\", \ | ||
31 | \"bic\":\"GENODEF1SLR\", \ | ||
32 | \"edate\":\"1449930207000\", \ | ||
33 | \"r\":123456789, \ | ||
34 | \"address\": \"foobar\"}"; | ||
35 | |||
36 | int main(int argc, const char *const argv[]) | ||
37 | { | ||
38 | json_t *wire; | ||
39 | json_error_t error; | ||
40 | int ret; | ||
41 | |||
42 | GNUNET_log_setup ("test-json-validations", "WARNING", NULL); | ||
43 | (void) memset(&error, 0, sizeof(error)); | ||
44 | wire = json_loads (json_wire_str, 0, &error); | ||
45 | if (NULL == wire) | ||
46 | { | ||
47 | TALER_JSON_warn (error); | ||
48 | return 2; | ||
49 | } | ||
50 | ret = TALER_JSON_validate_wireformat ("SEPA", wire); | ||
51 | if (1 == ret) | ||
52 | return 0; | ||
53 | return 1; | ||
54 | } | ||