[tracker/libtracker-common-cleanup: 15/16] libtracker-common: Removed all unused type utils functions
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-common-cleanup: 15/16] libtracker-common: Removed all unused type utils functions
- Date: Wed, 8 Oct 2014 16:19:24 +0000 (UTC)
commit c7ee2498b6b202b16cb169d286c16a8383631d47
Author: Martyn Russell <martyn lanedo com>
Date: Sun Sep 28 19:49:49 2014 +0100
libtracker-common: Removed all unused type utils functions
Includes:
gchar * tracker_glong_to_string (glong i);
gchar * tracker_gint_to_string (gint i);
gchar * tracker_guint_to_string (guint i);
gchar * tracker_gint32_to_string (gint32 i);
gchar * tracker_guint32_to_string (guint32 i);
gboolean tracker_string_to_uint (const gchar *s,
guint *ret);
gchar * tracker_string_list_to_string (gchar **strv,
gsize length,
gchar sep);
GList * tracker_glist_copy_with_string_data (GList *list);
gchar * tracker_string_boolean_to_string_gint (const gchar *value);
src/libtracker-common/tracker-type-utils.c | 127 ----------
src/libtracker-common/tracker-type-utils.h | 12 -
tests/libtracker-common/tracker-type-utils-test.c | 255 ---------------------
3 files changed, 0 insertions(+), 394 deletions(-)
---
diff --git a/src/libtracker-common/tracker-type-utils.c b/src/libtracker-common/tracker-type-utils.c
index 7b22166..63f89dc 100644
--- a/src/libtracker-common/tracker-type-utils.c
+++ b/src/libtracker-common/tracker-type-utils.c
@@ -34,63 +34,6 @@
#include "tracker-utils.h"
#include "tracker-type-utils.h"
-gchar *
-tracker_glong_to_string (glong i)
-{
- return g_strdup_printf ("%ld", i);
-}
-
-gchar *
-tracker_gint_to_string (gint i)
-{
- return g_strdup_printf ("%d", i);
-}
-
-gchar *
-tracker_guint_to_string (guint i)
-{
- return g_strdup_printf ("%u", i);
-}
-
-gchar *
-tracker_gint32_to_string (gint32 i)
-{
- return g_strdup_printf ("%" G_GINT32_FORMAT, i);
-}
-
-gchar *
-tracker_guint32_to_string (guint32 i)
-{
- return g_strdup_printf ("%" G_GUINT32_FORMAT, i);
-}
-
-gboolean
-tracker_string_to_uint (const gchar *s,
- guint *value)
-{
- unsigned long int n;
- gchar *end;
-
- g_return_val_if_fail (s != NULL, FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
-
- n = (guint) strtoul (s, &end, 10);
-
- if (end == s) {
- *value = 0;
- return FALSE;
- }
-
- if (n > G_MAXUINT) {
- *value = 0;
- return FALSE;
-
- } else {
- *value = (guint) n;
- return TRUE;
- }
-}
-
gint
tracker_string_in_string_list (const gchar *str,
gchar **strv)
@@ -161,41 +104,6 @@ tracker_string_list_to_gslist (gchar **strv,
return g_slist_reverse (list);
}
-gchar *
-tracker_string_list_to_string (gchar **strv,
- gsize size,
- gchar sep)
-{
- GString *string;
- gsize i;
- gsize size_used;
-
- if (!strv) {
- return NULL;
- }
-
- if (size < 1) {
- size_used = g_strv_length (strv);
- } else {
- size_used = size;
- }
-
- string = g_string_new ("");
-
- for (i = 0; i < size_used; i++) {
- if (strv[i]) {
- if (i > 0) {
- g_string_append_c (string, sep);
- }
-
- string = g_string_append (string, strv[i]);
- } else {
- break;
- }
- }
-
- return g_string_free (string, FALSE);
-}
gchar **
tracker_string_to_string_list (const gchar *str)
@@ -309,38 +217,3 @@ tracker_gslist_copy_with_string_data (GSList *list)
return new_list;
}
-
-GList *
-tracker_glist_copy_with_string_data (GList *list)
-{
- GList *l;
- GList *new_list;
-
- if (!list) {
- return NULL;
- }
-
- new_list = NULL;
-
- for (l = list; l; l = l->next) {
- new_list = g_list_prepend (new_list, g_strdup (l->data));
- }
-
- new_list = g_list_reverse (new_list);
-
- return new_list;
-}
-
-gchar *
-tracker_string_boolean_to_string_gint (const gchar *value)
-{
- g_return_val_if_fail (value != NULL, NULL);
-
- if (g_ascii_strcasecmp (value, "true") == 0) {
- return g_strdup ("1");
- } else if (g_ascii_strcasecmp (value, "false") == 0) {
- return g_strdup ("0");
- } else {
- return g_strdup (value);
- }
-}
diff --git a/src/libtracker-common/tracker-type-utils.h b/src/libtracker-common/tracker-type-utils.h
index 6197ab7..e73142f 100644
--- a/src/libtracker-common/tracker-type-utils.h
+++ b/src/libtracker-common/tracker-type-utils.h
@@ -29,30 +29,18 @@ G_BEGIN_DECLS
#error "only <libtracker-common/tracker-common.h> must be included directly."
#endif
-gchar * tracker_glong_to_string (glong i);
-gchar * tracker_gint_to_string (gint i);
-gchar * tracker_guint_to_string (guint i);
-gchar * tracker_gint32_to_string (gint32 i);
-gchar * tracker_guint32_to_string (guint32 i);
-gboolean tracker_string_to_uint (const gchar *s,
- guint *ret);
gint tracker_string_in_string_list (const gchar *str,
gchar **strv);
gboolean tracker_string_in_gslist (const gchar *str,
GSList *list);
GSList * tracker_string_list_to_gslist (gchar **strv,
gsize length);
-gchar * tracker_string_list_to_string (gchar **strv,
- gsize length,
- gchar sep);
gchar ** tracker_string_to_string_list (const gchar *str);
gchar ** tracker_gslist_to_string_list (GSList *list);
gchar ** tracker_glist_to_string_list (GList *list);
gboolean tracker_gslist_with_string_data_equal (GSList *list1,
GSList *list2);
GSList * tracker_gslist_copy_with_string_data (GSList *list);
-GList * tracker_glist_copy_with_string_data (GList *list);
-gchar * tracker_string_boolean_to_string_gint (const gchar *value);
G_END_DECLS
diff --git a/tests/libtracker-common/tracker-type-utils-test.c
b/tests/libtracker-common/tracker-type-utils-test.c
index 1f9559b..808c780 100644
--- a/tests/libtracker-common/tracker-type-utils-test.c
+++ b/tests/libtracker-common/tracker-type-utils-test.c
@@ -25,125 +25,6 @@
#include <libtracker-common/tracker-type-utils.h>
static void
-test_long_to_string (void)
-{
- glong n;
- gchar *result;
-
- n = 10050;
- result = tracker_glong_to_string (n);
- g_assert_cmpstr (result, ==, "10050");
- g_free (result);
-
- n = -9950;
- result = tracker_glong_to_string (n);
- g_assert_cmpstr (result, ==, "-9950");
- g_free (result);
-}
-
-static void
-test_int_to_string (void)
-{
- gint n;
- gchar *result;
-
- n = 654;
- result = tracker_gint_to_string (n);
- g_assert_cmpstr (result, ==, "654");
- g_free (result);
-
- n = -963;
- result = tracker_gint_to_string (n);
- g_assert_cmpstr (result, ==, "-963");
- g_free (result);
-
-}
-
-static void
-test_uint_to_string (void)
-{
- guint n;
- gchar *result;
-
- n = 100;
- result = tracker_guint_to_string (n);
- g_assert_cmpstr (result, ==, "100");
- g_free (result);
-}
-
-static void
-test_gint32_to_string (void)
-{
- gint32 n;
- gchar *result;
-
- n = 100;
- result = tracker_gint32_to_string (n);
- g_assert_cmpstr (result, ==, "100");
- g_free (result);
-
- n = -96;
- result = tracker_gint32_to_string (n);
- g_assert_cmpstr (result, ==, "-96");
- g_free (result);
-
-}
-
-static void
-test_guint32_to_string (void)
-{
- guint32 n;
- gchar *result;
-
- n = 100;
- result = tracker_guint32_to_string (n);
- g_assert_cmpstr (result, ==, "100");
- g_free (result);
-
-}
-
-static void
-test_string_to_uint_failures_subprocess_1 (void)
-{
- guint num = 10;
-
- tracker_string_to_uint (NULL, &num);
-}
-
-static void
-test_string_to_uint_failures_subprocess_2 (void)
-{
- tracker_string_to_uint ("199", NULL);
-}
-
-static void
-test_string_to_uint_failures (void)
-{
- g_test_trap_subprocess ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/1",
0, 0);
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*assertion 's != NULL' failed*");
-
- g_test_trap_subprocess ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/2",
0, 0);
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*assertion 'value != NULL' failed*");
-}
-
-static void
-test_string_to_uint (void)
-{
- guint num_result, rc;
-
- rc = tracker_string_to_uint ("10", &num_result);
-
- g_assert (rc);
- g_assert_cmpint (num_result, ==, 10);
-
- rc = tracker_string_to_uint ("i am not a number", &num_result);
- g_assert (!rc);
- g_assert_cmpint (rc, ==, 0);
-}
-
-static void
test_string_in_string_list_failures_subprocess (void)
{
const gchar *complete = "This is an extract of text with different terms an props like Audio:Title
...";
@@ -251,38 +132,6 @@ test_string_list_to_gslist (void)
g_assert (tracker_string_in_gslist ("two", result));
g_assert (!tracker_string_in_gslist ("three", result));
g_assert (!tracker_string_in_gslist ("four", result));
-
-}
-
-static void
-test_string_list_to_string (void)
-{
- const gchar *input = "one two three four";
- gchar **pieces;
- gchar *result;
-
- pieces = g_strsplit (input, " ", 4);
-
- result = tracker_string_list_to_string (pieces, 4, ' ');
- g_assert_cmpstr (input, ==, result);
- g_free (result);
-
- result = tracker_string_list_to_string (pieces, 3, '_');
- g_assert_cmpstr ("one_two_three", ==, result);
- g_free (result);
-
- result = tracker_string_list_to_string (NULL, 6, 'x');
- g_assert (result == NULL);
-
- result = tracker_string_list_to_string (pieces, -1, ' ');
- g_assert_cmpstr (input, ==, result);
- g_free (result);
-
- result = tracker_string_list_to_string (pieces, 6, ' ');
- g_assert_cmpstr (input, ==, result);
- g_free (result);
-
- g_strfreev (pieces);
}
static void
@@ -297,66 +146,6 @@ test_string_to_string_list (void)
}
static void
-test_boolean_as_text_to_number_failures_subprocess (void)
-{
- tracker_string_boolean_to_string_gint (NULL);
-}
-
-static void
-test_boolean_as_text_to_number_failures (void)
-{
- g_test_trap_subprocess
("/libtracker-common/tracker-type-utils/boolean_as_text_to_number_failures/subprocess", 0, 0);
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*assertion 'value != NULL' failed*");
-}
-
-static void
-test_boolean_as_text_to_number (void)
-{
- gchar *result;
-
- /* Correct true values */
- result = tracker_string_boolean_to_string_gint ("True");
- g_assert_cmpstr (result, ==, "1");
- g_free (result);
-
-
- result = tracker_string_boolean_to_string_gint ("TRUE");
- g_assert_cmpstr (result, ==, "1");
- g_free (result);
-
- result = tracker_string_boolean_to_string_gint ("true");
- g_assert_cmpstr (result, ==, "1");
- g_free (result);
-
- /* Correct false values */
- result = tracker_string_boolean_to_string_gint ("False");
- g_assert_cmpstr (result, ==, "0");
- g_free (result);
-
- result = tracker_string_boolean_to_string_gint ("FALSE");
- g_assert_cmpstr (result, ==, "0");
- g_free (result);
-
- result = tracker_string_boolean_to_string_gint ("false");
- g_assert_cmpstr (result, ==, "0");
- g_free (result);
-
- /* Invalid values */
- result = tracker_string_boolean_to_string_gint ("Thrue");
- g_assert_cmpstr (result, ==, "Thrue");
- g_free (result);
-
- result = tracker_string_boolean_to_string_gint ("Falsez");
- g_assert_cmpstr (result, ==, "Falsez");
- g_free (result);
-
- result = tracker_string_boolean_to_string_gint ("Other invalid value");
- g_assert_cmpstr (result, ==, "Other invalid value");
- g_free (result);
-}
-
-static void
test_gslist_with_string_data_equal (void)
{
GSList *list1 = NULL;
@@ -397,22 +186,6 @@ test_gslist_with_string_data_equal (void)
g_slist_free (list3);
}
-static void
-test_glist_copy_with_string_data (void)
-{
- GList *input = NULL;
- GList *result = NULL;
-
- input = g_list_prepend (input, g_strdup ("one"));
- input = g_list_prepend (input, g_strdup ("two"));
-
- result = tracker_glist_copy_with_string_data (input);
- g_assert (result != input);
- g_assert_cmpint (g_list_length (result), ==, 2);
-
- /* Further checks... that the contents are actually the same */
-}
-
int
main (int argc, char **argv)
{
@@ -420,14 +193,6 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/libtracker-common/tracker-type-utils/boolean_as_text_to_number",
- test_boolean_as_text_to_number);
- g_test_add_func ("/libtracker-common/tracker-type-utils/boolean_as_text_to_number_failures",
- test_boolean_as_text_to_number_failures);
- g_test_add_func
("/libtracker-common/tracker-type-utils/boolean_as_text_to_number_failures/subprocess",
- test_boolean_as_text_to_number_failures_subprocess);
- g_test_add_func ("/libtracker-common/tracker-type-utils/string_list_as_list",
- test_string_list_to_string);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_list_as_list",
test_string_to_string_list);
g_test_add_func ("/libtracker-common/tracker-type-utils/gslist_to_string_list",
@@ -442,28 +207,8 @@ main (int argc, char **argv)
test_string_in_gslist);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_list_to_gslist",
test_string_list_to_gslist);
- g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint",
- test_string_to_uint);
- g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint_failures",
- test_string_to_uint_failures);
- g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/1",
- test_string_to_uint_failures_subprocess_1);
- g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/2",
- test_string_to_uint_failures_subprocess_2);
- g_test_add_func ("/libtracker-common/tracker-type-utils/guint32_to_string",
- test_guint32_to_string);
- g_test_add_func ("/libtracker-common/tracker-type-utils/gint32_to_string",
- test_gint32_to_string);
- g_test_add_func ("/libtracker-common/tracker-type-utils/uint_to_string",
- test_uint_to_string);
- g_test_add_func ("/libtracker-common/tracker-type-utils/int_to_string",
- test_int_to_string);
- g_test_add_func ("/libtracker-common/tracker-type-utils/long_to_string",
- test_long_to_string);
g_test_add_func ("/libtracker-common/tracker-type-utils/gslist_with_string_data_equal",
test_gslist_with_string_data_equal);
- g_test_add_func ("/libtracker-common/tracker-type-utils/glist_copy_with_string_data",
- test_glist_copy_with_string_data);
result = g_test_run ();
return result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]