summaryrefslogtreecommitdiff
path: root/tests/util.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2009-03-17 14:44:10 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2009-03-17 14:44:10 +0000
commit85aa079ae7e85f5e7ea4486e0d9c39440506dbef (patch)
tree16e4568be48945e03ec73a6a07d0148099abe1a3 /tests/util.c
parent07a1c96e574ce45fd82f4919c78df11ddc16f683 (diff)
tests: remove test- prefix from all sources
As well as making tab completion work better, this means .gitignore can be much simpler.
Diffstat (limited to 'tests/util.c')
-rw-r--r--tests/util.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/util.c b/tests/util.c
new file mode 100644
index 00000000..d4b67f1e
--- /dev/null
+++ b/tests/util.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+
+#include <glib.h>
+
+#include <telepathy-glib/util.h>
+
+void test_strv_contains (void);
+
+void
+test_strv_contains (void)
+{
+ const gchar * const strv[] = {
+ "Pah",
+ "Pah",
+ "Pah-pah-pah",
+ "Patrick!",
+ NULL
+ };
+
+ g_assert (tp_strv_contains (strv, "Patrick!"));
+ g_assert (!tp_strv_contains (strv, "Snakes!"));
+}
+
+int main (int argc, char **argv)
+{
+ GPtrArray *ptrarray;
+ gchar *string;
+
+ g_assert (!tp_strdiff (NULL, NULL));
+ g_assert (tp_strdiff ("badger", NULL));
+ g_assert (tp_strdiff (NULL, "badger"));
+ g_assert (!tp_strdiff ("badger", "badger"));
+ g_assert (tp_strdiff ("badger", "mushroom"));
+
+ ptrarray = g_ptr_array_new ();
+ g_ptr_array_add (ptrarray, GINT_TO_POINTER (23));
+ g_ptr_array_add (ptrarray, GINT_TO_POINTER (42));
+ g_assert (tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (23)));
+ g_assert (tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (42)));
+ g_assert (!tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (666)));
+ g_ptr_array_free (ptrarray, TRUE);
+
+ string = tp_escape_as_identifier ("");
+ g_assert (!tp_strdiff (string, "_"));
+ g_free (string);
+
+ string = tp_escape_as_identifier ("badger");
+ g_assert (!tp_strdiff (string, "badger"));
+ g_free (string);
+
+ string = tp_escape_as_identifier ("0123abc_xyz\x01\xff");
+ g_assert (!tp_strdiff (string, "_30123abc_5fxyz_01_ff"));
+ g_free (string);
+
+ test_strv_contains ();
+
+ return 0;
+}