aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_mhd_version.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/test_mhd_version.c')
-rw-r--r--src/microhttpd/test_mhd_version.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/microhttpd/test_mhd_version.c b/src/microhttpd/test_mhd_version.c
index 654acf30..bd91d64d 100644
--- a/src/microhttpd/test_mhd_version.c
+++ b/src/microhttpd/test_mhd_version.c
@@ -18,7 +18,7 @@
18*/ 18*/
19 19
20/** 20/**
21 * @file microhttpd/test_mhd_version.h 21 * @file microhttpd/test_mhd_version.с
22 * @brief Tests for MHD versions identifiers 22 * @brief Tests for MHD versions identifiers
23 * @author Karlson2k (Evgeny Grin) 23 * @author Karlson2k (Evgeny Grin)
24 */ 24 */
@@ -103,16 +103,22 @@ test_macro2_vs_func_str (void)
103static int 103static int
104test_func_str_vs_macro_bin (void) 104test_func_str_vs_macro_bin (void)
105{ 105{
106#ifdef HAVE_SNPRINTF 106 char bin_print[64];
107 char bin_print[10];
108 int res; 107 int res;
109 const char *str_func = MHD_get_version (); 108 const char *str_func = MHD_get_version ();
110 109
111 printf ("Checking MHD_get_version() function vs MHD_VERSION macro.\n"); 110 printf ("Checking MHD_get_version() function vs MHD_VERSION macro.\n");
111#ifdef HAVE_SNPRINTF
112 res = snprintf (bin_print, sizeof(bin_print), "%X.%X.%X", 112 res = snprintf (bin_print, sizeof(bin_print), "%X.%X.%X",
113 (unsigned int) ((bin_macro >> 24) & 0xFF), 113 (unsigned int) ((bin_macro >> 24) & 0xFF),
114 (unsigned int) ((bin_macro >> 16) & 0xFF), 114 (unsigned int) ((bin_macro >> 16) & 0xFF),
115 (unsigned int) ((bin_macro >> 8) & 0xFF)); 115 (unsigned int) ((bin_macro >> 8) & 0xFF));
116#else /* ! HAVE_SNPRINTF */
117 res = sprintf (bin_print, "%X.%X.%X",
118 (unsigned int) ((bin_macro >> 24) & 0xFF),
119 (unsigned int) ((bin_macro >> 16) & 0xFF),
120 (unsigned int) ((bin_macro >> 8) & 0xFF));
121#endif /* ! HAVE_SNPRINTF */
116 if ((9 < res) || (0 >= res)) 122 if ((9 < res) || (0 >= res))
117 { 123 {
118 fprintf (stderr, "snprintf() error.\n"); 124 fprintf (stderr, "snprintf() error.\n");
@@ -132,11 +138,6 @@ test_func_str_vs_macro_bin (void)
132 bin_macro, 138 bin_macro,
133 bin_print); 139 bin_print);
134 return 0; 140 return 0;
135#else /* ! HAVE_SNPRINTF */
136 fprintf (stderr, "snprintf() function is not available. "
137 "Cannot check binary/string match.\n");
138 return 0;
139#endif /* ! HAVE_SNPRINTF */
140} 141}
141 142
142 143
@@ -219,5 +220,11 @@ main (void)
219 res += test_macro_vs_func_bin (); 220 res += test_macro_vs_func_bin ();
220 res += test_func_bin_format (); 221 res += test_func_bin_format ();
221 222
222 return 0 == res ? 0 : 1; 223 if (0 != res)
224 {
225 fprintf (stderr, "Test failed. Number of errors: %d\n", res);
226 return 1;
227 }
228 printf ("Test succeed.\n");
229 return 0;
223} 230}