summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2012-08-31 15:33:08 +0200
committerSjoerd Simons <sjoerd@luon.net>2012-08-31 15:33:08 +0200
commit8c682d0122b066ad69cc7106884f383563c2ba6d (patch)
tree762486a92a21b83b331e48c9f4d7b2811f15c536 /tests/lib
parentf59f0ef8f7966733385e545c4c2d702425d1efd1 (diff)
downloadtelepathy-glib-8c682d0122b066ad69cc7106884f383563c2ba6d.tar.gz
tls-certificate test: GBytes aren't 0 terminated
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/util.c20
-rw-r--r--tests/lib/util.h6
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/util.c b/tests/lib/util.c
index 21d385502..9510cb025 100644
--- a/tests/lib/util.c
+++ b/tests/lib/util.c
@@ -176,6 +176,26 @@ _tp_tests_assert_strv_equals (const char *file,
}
void
+_tp_tests_assert_bytes_equal (const gchar *file, int line,
+ GBytes *actual, gconstpointer expected_data,
+ gsize expected_length)
+{
+ if (expected_length != g_bytes_get_size (actual))
+ {
+ g_error ("%s:%d: assertion failed: expected %"G_GSIZE_FORMAT
+ " bytes, got %"G_GSIZE_FORMAT,
+ file, line, expected_length, g_bytes_get_size (actual));
+ }
+ else if (memcmp (g_bytes_get_data (actual, NULL),
+ expected_data, expected_length) != 0)
+ {
+ g_error (
+ "%s:%d: assertion failed: expected data didn't match the actual data",
+ file, line);
+ }
+}
+
+void
tp_tests_create_conn (GType conn_type,
const gchar *account,
gboolean connect,
diff --git a/tests/lib/util.h b/tests/lib/util.h
index d58138ea9..ce19d666a 100644
--- a/tests/lib/util.h
+++ b/tests/lib/util.h
@@ -36,6 +36,12 @@ void _tp_tests_assert_strv_equals (const char *file, int line,
const char *actual_desc, gconstpointer actual_strv,
const char *expected_desc, gconstpointer expected_strv);
+#define tp_tests_assert_bytes_equals(actual, expected, expected_length) \
+ _tp_tests_assert_bytes_equal (__FILE__, __LINE__, \
+ actual, expected, expected_length)
+void _tp_tests_assert_bytes_equal (const gchar *file, int line,
+ GBytes *actual, gconstpointer expected_data, gsize expected_length);
+
void tp_tests_create_conn (GType conn_type,
const gchar *account,
gboolean connect,