summaryrefslogtreecommitdiff
path: root/unit/util.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2011-06-29 00:11:54 +0300
committerMarcel Holtmann <marcel@holtmann.org>2012-12-04 22:21:57 +0100
commitd455694af22896a1a3608f44352eb5caa388a57c (patch)
treeed0aa00faafd389f9a48da37a16a84eed337cca3 /unit/util.c
parentb105277b9726903f1eea33d6b0046e832406d539 (diff)
downloadbluez-d455694af22896a1a3608f44352eb5caa388a57c.tar.gz
gobex: Split unit tests into separate modules
Diffstat (limited to 'unit/util.c')
-rw-r--r--unit/util.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/unit/util.c b/unit/util.c
new file mode 100644
index 000000000..7045e4f38
--- /dev/null
+++ b/unit/util.c
@@ -0,0 +1,61 @@
+/*
+ *
+ * OBEX library with GLib integration
+ *
+ * Copyright (C) 2011 Intel Corporation. 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 version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "util.h"
+
+GQuark test_error_quark(void)
+{
+ return g_quark_from_static_string("test-error-quark");
+}
+
+static void dump_bytes(const uint8_t *buf, size_t buf_len)
+{
+ size_t i;
+
+ for (i = 0; i < buf_len; i++)
+ g_printerr("%02x ", buf[i]);
+
+ g_printerr("\n");
+}
+
+void dump_bufs(const void *mem1, size_t len1, const void *mem2, size_t len2)
+{
+ g_printerr("\nExpected: ");
+ dump_bytes(mem1, len1);
+ g_printerr("Got: ");
+ dump_bytes(mem2, len2);
+}
+
+void assert_memequal(const void *mem1, size_t len1,
+ const void *mem2, size_t len2)
+{
+ if (len1 == len2 && memcmp(mem1, mem2, len1) == 0)
+ return;
+
+ dump_bufs(mem1, len1, mem2, len2);
+
+ g_assert(0);
+}