diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/util/test_strings_to_data.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/util/test_strings_to_data.c')
-rw-r--r-- | src/util/test_strings_to_data.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/util/test_strings_to_data.c b/src/util/test_strings_to_data.c index f7d20441f..d719e950a 100644 --- a/src/util/test_strings_to_data.c +++ b/src/util/test_strings_to_data.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file util/test_strings_to_data.c | 21 | * @file util/test_strings_to_data.c |
22 | * @brief testcase for strings.c | 22 | * @brief testcase for strings.c |
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | 27 | ||
28 | int | 28 | int |
29 | main (int argc, char *argv[]) | 29 | main(int argc, char *argv[]) |
30 | { | 30 | { |
31 | char buf[1024]; | 31 | char buf[1024]; |
32 | char *end; | 32 | char *end; |
@@ -35,26 +35,27 @@ main (int argc, char *argv[]) | |||
35 | unsigned int i; | 35 | unsigned int i; |
36 | int ret = 0; | 36 | int ret = 0; |
37 | 37 | ||
38 | GNUNET_log_setup ("util", "DEBUG", NULL); | 38 | GNUNET_log_setup("util", "DEBUG", NULL); |
39 | for (i=0;i<sizeof(src);i++) | 39 | for (i = 0; i < sizeof(src); i++) |
40 | { | ||
41 | memset (src, i, sizeof (src)); | ||
42 | memset (dst, i+1, sizeof (dst)); | ||
43 | |||
44 | end = GNUNET_STRINGS_data_to_string (&src, i, buf, sizeof (buf)); | ||
45 | GNUNET_assert (NULL != end); | ||
46 | end[0] = '\0'; | ||
47 | if (GNUNET_OK != | ||
48 | GNUNET_STRINGS_string_to_data (buf, strlen (buf), dst, i)) | ||
49 | { | ||
50 | fprintf (stderr, "%u failed decode (%u bytes)\n", i, (unsigned int) strlen (buf)); | ||
51 | ret = 1; | ||
52 | } else if (0 != memcmp (src, dst, i)) | ||
53 | { | 40 | { |
54 | fprintf (stderr, "%u wrong decode (%u bytes)\n", i, (unsigned int) strlen (buf)); | 41 | memset(src, i, sizeof(src)); |
55 | ret = 1; | 42 | memset(dst, i + 1, sizeof(dst)); |
43 | |||
44 | end = GNUNET_STRINGS_data_to_string(&src, i, buf, sizeof(buf)); | ||
45 | GNUNET_assert(NULL != end); | ||
46 | end[0] = '\0'; | ||
47 | if (GNUNET_OK != | ||
48 | GNUNET_STRINGS_string_to_data(buf, strlen(buf), dst, i)) | ||
49 | { | ||
50 | fprintf(stderr, "%u failed decode (%u bytes)\n", i, (unsigned int)strlen(buf)); | ||
51 | ret = 1; | ||
52 | } | ||
53 | else if (0 != memcmp(src, dst, i)) | ||
54 | { | ||
55 | fprintf(stderr, "%u wrong decode (%u bytes)\n", i, (unsigned int)strlen(buf)); | ||
56 | ret = 1; | ||
57 | } | ||
56 | } | 58 | } |
57 | } | ||
58 | return ret; | 59 | return ret; |
59 | } | 60 | } |
60 | 61 | ||