summaryrefslogtreecommitdiffstats
path: root/tests/utils/utils_test.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-02 13:55:00 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-02 13:59:10 +0100
commitb79a148eca01ff8f101662f389b8032ea2d9a535 (patch)
tree0696169aab1d3f3e7674ef54c929a7eb3443b678 /tests/utils/utils_test.c
parentb7d0f4686b4aa55fd9b69884e6cc0c4c79ea1cd5 (diff)
utils: Add a simple testcase for osmo_hexdump
This code makes a simple dump and tests for the corner case
Diffstat (limited to 'tests/utils/utils_test.c')
-rw-r--r--tests/utils/utils_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c
new file mode 100644
index 00000000..b21b074b
--- /dev/null
+++ b/tests/utils/utils_test.c
@@ -0,0 +1,47 @@
+/* tests for utilities of libmsomcore */
+/*
+ * (C) 2014 Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <osmocom/core/utils.h>
+
+#include <stdio.h>
+
+static void hexdump_test(void)
+{
+ uint8_t data[4098];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(data); ++i)
+ data[i] = i & 0xff;
+
+ printf("Plain dump\n");
+ printf("%s\n", osmo_hexdump(data, 4));
+
+ printf("Corner case\n");
+ printf("%s\n", osmo_hexdump(data, ARRAY_SIZE(data)));
+ printf("%s\n", osmo_hexdump_nospc(data, ARRAY_SIZE(data)));
+}
+
+int main(int argc, char **argv)
+{
+ hexdump_test();
+ return 0;
+}