summaryrefslogtreecommitdiff
path: root/tests/libtracker-common
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2020-08-12 23:15:45 +0200
committerSam Thursfield <sam@afuera.me.uk>2020-08-12 23:15:45 +0200
commitbbf5b19f9862b4bd78f41a49308976ff84769acc (patch)
tree8d1711caf9a4eae75160246c9a2fe63915316e60 /tests/libtracker-common
parentdfe542d94fa7190a4965561cd460685fba6196b2 (diff)
downloadtracker-bbf5b19f9862b4bd78f41a49308976ff84769acc.tar.gz
tests: Use g_assert_true() instead of g_assert()
This fixes the tests when -DG_DISABLE_ASSERT is passed at compile time. See https://gitlab.gnome.org/GNOME/tracker/-/issues/240
Diffstat (limited to 'tests/libtracker-common')
-rw-r--r--tests/libtracker-common/tracker-date-time-test.c22
-rw-r--r--tests/libtracker-common/tracker-file-utils-test.c42
-rw-r--r--tests/libtracker-common/tracker-parser-test.c2
-rw-r--r--tests/libtracker-common/tracker-type-utils-test.c46
-rw-r--r--tests/libtracker-common/tracker-utils-test.c22
5 files changed, 67 insertions, 67 deletions
diff --git a/tests/libtracker-common/tracker-date-time-test.c b/tests/libtracker-common/tracker-date-time-test.c
index f51c36830..268cac58a 100644
--- a/tests/libtracker-common/tracker-date-time-test.c
+++ b/tests/libtracker-common/tracker-date-time-test.c
@@ -139,7 +139,7 @@ test_date_to_string (void)
#endif
result = tracker_date_to_string (input, 0);
- g_assert (result != NULL && strncmp (result, "2008-06-16T23:53:10Z", 19) == 0);
+ g_assert_true (result != NULL && strncmp (result, "2008-06-16T23:53:10Z", 19) == 0);
g_free (result);
result = tracker_date_to_string (input, 7200);
@@ -186,44 +186,44 @@ test_date_time_from_string ()
g_value_init (&value, TRACKER_TYPE_DATE_TIME);
tracker_date_time_set_from_string (&value, "2011-10-28T17:43:00+03:00", &error);
- g_assert (!error);
+ g_assert_true (!error);
g_assert_cmpint (tracker_date_time_get_time (&value), ==, 1319812980);
g_assert_cmpint (tracker_date_time_get_offset (&value), ==, 10800);
/* Negative offset */
tracker_date_time_set_from_string (&value, "2011-10-28T17:43:00-03:00", &error);
- g_assert (!error);
+ g_assert_true (!error);
g_assert_cmpint (tracker_date_time_get_time (&value), ==, 1319834580);
g_assert_cmpint (tracker_date_time_get_offset (&value), ==, -10800);
/* No offset */
tracker_date_time_set_from_string (&value, "2011-10-28T17:43:00Z", &error);
- g_assert (!error);
+ g_assert_true (!error);
g_assert_cmpint (tracker_date_time_get_time (&value), ==, 1319823780);
g_assert_cmpint (tracker_date_time_get_offset (&value), ==, 0);
/* Invalid format */
tracker_date_time_set_from_string (&value, "2011-10-28T17:43:00Z0900", &error);
- g_assert (error);
+ g_assert_true (error);
g_error_free (error);
error = NULL;
/* There are no 28 months... */
tracker_date_time_set_from_string (&value, "2011-28-10T17:43:00Z0900", &error);
- g_assert (error);
+ g_assert_true (error);
g_error_free (error);
error = NULL;
/* ... nor more than +-12 offsets */
tracker_date_time_set_from_string (&value, "2011-28-10T17:43:00+17:00", &error);
- g_assert (error);
+ g_assert_true (error);
g_error_free (error);
error = NULL;
/* ... the same for the glory of the branch % */
tracker_date_time_set_from_string (&value, "2011-28-10T17:43:00-17:00", &error);
- g_assert (error);
+ g_assert_true (error);
g_error_free (error);
error = NULL;
}
@@ -237,7 +237,7 @@ test_date_time_get_local_date ()
g_value_init (&value, TRACKER_TYPE_DATE_TIME);
tracker_date_time_set_from_string (&value, "2011-10-28T17:43:00+03:00", &error);
- g_assert (!error);
+ g_assert_true (!error);
g_assert_cmpint (tracker_date_time_get_local_date (&value), ==, 15275);
}
@@ -251,7 +251,7 @@ test_date_time_get_local_time ()
g_value_init (&value, TRACKER_TYPE_DATE_TIME);
tracker_date_time_set_from_string (&value, "2011-10-28T17:43:00+03:00", &error);
- g_assert (!error);
+ g_assert_true (!error);
g_assert_cmpint (tracker_date_time_get_local_time (&value), ==, 63780);
}
@@ -268,7 +268,7 @@ test_date_time_conversions (void)
date_str = "2011-10-28T17:43:00+03:00";
time = tracker_string_to_date (date_str, &offset, &error);
- g_assert (!error);
+ g_assert_true (!error);
g_assert_cmpint (time, ==, 1319812980);
g_assert_cmpint (offset, ==, 10800);
diff --git a/tests/libtracker-common/tracker-file-utils-test.c b/tests/libtracker-common/tracker-file-utils-test.c
index a41bead43..aa6cbf29f 100644
--- a/tests/libtracker-common/tracker-file-utils-test.c
+++ b/tests/libtracker-common/tracker-file-utils-test.c
@@ -46,7 +46,7 @@ ensure_file_exists (const gchar *filename)
static void
remove_file (const gchar *filename)
{
- g_assert (g_file_test (filename, G_FILE_TEST_EXISTS));
+ g_assert_true (g_file_test (filename, G_FILE_TEST_EXISTS));
g_assert_cmpint (g_remove (filename), ==, 0);
}
@@ -93,9 +93,9 @@ test_path_list_filter_duplicates (void)
result = tracker_path_list_filter_duplicates (input_as_list, ".", TRUE);
g_assert_cmpint (3, ==, g_slist_length (result));
- g_assert (string_in_list (result, "/home"));
- g_assert (string_in_list (result, "/tmp"));
- g_assert (string_in_list (result, "/usr"));
+ g_assert_true (string_in_list (result, "/home"));
+ g_assert_true (string_in_list (result, "/tmp"));
+ g_assert_true (string_in_list (result, "/usr"));
g_slist_foreach (input_as_list, (GFunc) g_free, NULL);
g_slist_foreach (result, (GFunc) g_free, NULL);
@@ -114,15 +114,15 @@ test_path_list_filter_duplicates_with_exceptions ()
result = tracker_path_list_filter_duplicates (input_as_list, "/home/user/MyDocs", FALSE);
g_assert_cmpint (g_slist_length (result), ==, 3);
- g_assert (string_in_list (result, "/home/user/MyDocs"));
- g_assert (string_in_list (result, "/home/user/MyDocs/.sounds"));
- g_assert (string_in_list (result, "/home/user/MyDocs/visible"));
+ g_assert_true (string_in_list (result, "/home/user/MyDocs"));
+ g_assert_true (string_in_list (result, "/home/user/MyDocs/.sounds"));
+ g_assert_true (string_in_list (result, "/home/user/MyDocs/visible"));
g_slist_foreach (result, (GFunc) g_free, NULL);
result = tracker_path_list_filter_duplicates (input_as_list, "/home/user/MyDocs", TRUE);
g_assert_cmpint (g_slist_length (result), ==, 1);
- g_assert (string_in_list (result, "/home/user/MyDocs"));
+ g_assert_true (string_in_list (result, "/home/user/MyDocs"));
g_slist_foreach (result, (GFunc) g_free, NULL);
g_slist_foreach (input_as_list, (GFunc) g_free, NULL);
@@ -200,16 +200,16 @@ test_path_evaluate_name (void)
g_free (expected);
result = tracker_path_evaluate_name ("");
- g_assert (!result);
+ g_assert_true (!result);
g_free (result);
result = tracker_path_evaluate_name (NULL);
- g_assert (!result);
+ g_assert_true (!result);
g_free (result);
g_setenv ("HOME", "", TRUE);
result = tracker_path_evaluate_name ("~/but-no-home.txt");
- g_assert (!result);
+ g_assert_true (!result);
g_free (result);
g_setenv ("HOME", home, TRUE);
@@ -284,15 +284,15 @@ test_file_utils_open_close ()
FILE *f;
f = tracker_file_open (TEST_FILENAME);
- g_assert (f);
+ g_assert_true (f);
tracker_file_close (f, TRUE);
f = tracker_file_open (TEST_FILENAME);
- g_assert (f);
+ g_assert_true (f);
tracker_file_close (f, FALSE);
f = tracker_file_open ("./file-does-NOT-exist");
- g_assert (!f);
+ g_assert_true (!f);
}
static void
@@ -368,11 +368,11 @@ static void
test_file_system_has_enough_space ()
{
/* Hopefully we will always have 1 byte free... */
- g_assert (tracker_file_system_has_enough_space ("/home", 1, FALSE));
- g_assert (tracker_file_system_has_enough_space ("/home", 1, TRUE));
+ g_assert_true (tracker_file_system_has_enough_space ("/home", 1, FALSE));
+ g_assert_true (tracker_file_system_has_enough_space ("/home", 1, TRUE));
/* gulong goes only up to 4Gb. Cannot ask for unreasonable amount of space */
- //g_assert (!tracker_file_system_has_enough_space ("/home", G_MAXULONG, FALSE));
+ //g_assert_true (!tracker_file_system_has_enough_space ("/home", G_MAXULONG, FALSE));
}
static void
@@ -383,11 +383,11 @@ test_file_utils_is_hidden ()
ensure_file_exists ("./non-hidden-test-file");
f = g_file_new_for_path (TEST_HIDDEN_FILENAME);
- g_assert (tracker_file_is_hidden (f));
+ g_assert_true (tracker_file_is_hidden (f));
g_object_unref (f);
f = g_file_new_for_path ("./non-hidden-test-file");
- g_assert (!tracker_file_is_hidden (f));
+ g_assert_true (!tracker_file_is_hidden (f));
g_object_unref (f);
remove_file ("./non-hidden-test-file");
@@ -402,8 +402,8 @@ test_file_utils_cmp ()
two = g_file_new_for_path (TEST_FILENAME);
three = g_file_new_for_path (TEST_HIDDEN_FILENAME);
- g_assert (!tracker_file_cmp (one, two));
- g_assert (tracker_file_cmp (two, three));
+ g_assert_true (!tracker_file_cmp (one, two));
+ g_assert_true (tracker_file_cmp (two, three));
}
int
diff --git a/tests/libtracker-common/tracker-parser-test.c b/tests/libtracker-common/tracker-parser-test.c
index 954c212bd..656e6ec53 100644
--- a/tests/libtracker-common/tracker-parser-test.c
+++ b/tests/libtracker-common/tracker-parser-test.c
@@ -142,7 +142,7 @@ expected_nwords_check (TrackerParserTestFixture *fixture,
g_assert_cmpuint (nwords, == , testdata->expected_nwords);
else
/* We'll assert if both expected number of words fail */
- g_assert ((nwords == testdata->expected_nwords) ||
+ g_assert_true ((nwords == testdata->expected_nwords) ||
(nwords == testdata->alternate_expected_nwords));
}
diff --git a/tests/libtracker-common/tracker-type-utils-test.c b/tests/libtracker-common/tracker-type-utils-test.c
index 5fce83406..7508efd2e 100644
--- a/tests/libtracker-common/tracker-type-utils-test.c
+++ b/tests/libtracker-common/tracker-type-utils-test.c
@@ -71,11 +71,11 @@ test_string_in_gslist (void)
input = g_slist_prepend (input, g_strdup ("three"));
input = g_slist_prepend (input, g_strdup ("four"));
- g_assert (tracker_string_in_gslist ("one", input));
- g_assert (tracker_string_in_gslist ("two", input));
- g_assert (tracker_string_in_gslist ("three", input));
- g_assert (tracker_string_in_gslist ("four", input));
- g_assert (!tracker_string_in_gslist ("five", input));
+ g_assert_true (tracker_string_in_gslist ("one", input));
+ g_assert_true (tracker_string_in_gslist ("two", input));
+ g_assert_true (tracker_string_in_gslist ("three", input));
+ g_assert_true (tracker_string_in_gslist ("four", input));
+ g_assert_true (!tracker_string_in_gslist ("five", input));
g_slist_foreach (input, (GFunc)g_free, NULL);
g_slist_free (input);
@@ -102,7 +102,7 @@ test_gslist_to_string_list (void)
g_strfreev (result);
result = tracker_gslist_to_string_list (NULL);
- g_assert (result != NULL);
+ g_assert_true (result != NULL);
g_strfreev (result);
}
@@ -113,26 +113,26 @@ test_string_list_to_gslist (void)
GSList *result = NULL;
result = tracker_string_list_to_gslist ((gchar **)input, -1);
- g_assert (result);
+ g_assert_true (result);
g_assert_cmpint (g_slist_length (result), ==, 4);
/* This function is tested in other test, so it should work or fail there also */
- g_assert (tracker_string_in_gslist ("one", result));
- g_assert (tracker_string_in_gslist ("two", result));
- g_assert (tracker_string_in_gslist ("three", result));
- g_assert (tracker_string_in_gslist ("four", result));
+ g_assert_true (tracker_string_in_gslist ("one", result));
+ g_assert_true (tracker_string_in_gslist ("two", result));
+ g_assert_true (tracker_string_in_gslist ("three", result));
+ g_assert_true (tracker_string_in_gslist ("four", result));
g_slist_foreach (result, (GFunc)g_free, NULL);
g_slist_free (result);
result = tracker_string_list_to_gslist ((gchar **)input, 2);
- g_assert (result);
+ g_assert_true (result);
g_assert_cmpint (g_slist_length (result), ==, 2);
- g_assert (tracker_string_in_gslist ("one", result));
- g_assert (tracker_string_in_gslist ("two", result));
- g_assert (!tracker_string_in_gslist ("three", result));
- g_assert (!tracker_string_in_gslist ("four", result));
+ g_assert_true (tracker_string_in_gslist ("one", result));
+ g_assert_true (tracker_string_in_gslist ("two", result));
+ g_assert_true (!tracker_string_in_gslist ("three", result));
+ g_assert_true (!tracker_string_in_gslist ("four", result));
}
static void
@@ -159,23 +159,23 @@ test_gslist_with_string_data_equal (void)
list1 = g_slist_prepend (list1, g_strdup ("two"));
list1 = g_slist_prepend (list1, g_strdup ("three"));
- g_assert (tracker_gslist_with_string_data_equal (list1, list1));
+ g_assert_true (tracker_gslist_with_string_data_equal (list1, list1));
shorty = g_slist_prepend (shorty, g_strdup ("one"));
- g_assert (!tracker_gslist_with_string_data_equal (list1, shorty));
- g_assert (!tracker_gslist_with_string_data_equal (shorty, list1));
+ g_assert_true (!tracker_gslist_with_string_data_equal (list1, shorty));
+ g_assert_true (!tracker_gslist_with_string_data_equal (shorty, list1));
list2 = g_slist_prepend (list2, g_strdup ("one"));
list2 = g_slist_prepend (list2, g_strdup ("two"));
list2 = g_slist_prepend (list2, g_strdup ("three"));
- g_assert (tracker_gslist_with_string_data_equal (list1, list2));
- g_assert (tracker_gslist_with_string_data_equal (list2, list1));
+ g_assert_true (tracker_gslist_with_string_data_equal (list1, list2));
+ g_assert_true (tracker_gslist_with_string_data_equal (list2, list1));
list3 = g_slist_prepend (list3, g_strdup ("one"));
list3 = g_slist_prepend (list3, g_strdup ("something different"));
list3 = g_slist_prepend (list3, g_strdup ("three"));
- g_assert (!tracker_gslist_with_string_data_equal (list1, list3));
- g_assert (!tracker_gslist_with_string_data_equal (list3, list1));
+ g_assert_true (!tracker_gslist_with_string_data_equal (list1, list3));
+ g_assert_true (!tracker_gslist_with_string_data_equal (list3, list1));
g_slist_foreach (list1, (GFunc)g_free, NULL);
g_slist_foreach (list2, (GFunc)g_free, NULL);
diff --git a/tests/libtracker-common/tracker-utils-test.c b/tests/libtracker-common/tracker-utils-test.c
index 8025af8c7..c98b45083 100644
--- a/tests/libtracker-common/tracker-utils-test.c
+++ b/tests/libtracker-common/tracker-utils-test.c
@@ -78,22 +78,22 @@ test_seconds_estimate_to_string ()
static void
test_is_empty_string ()
{
- g_assert (tracker_is_empty_string (NULL));
- g_assert (tracker_is_empty_string (""));
- g_assert (!tracker_is_empty_string ("Eeeeepa not empty"));
+ g_assert_true (tracker_is_empty_string (NULL));
+ g_assert_true (tracker_is_empty_string (""));
+ g_assert_true (!tracker_is_empty_string ("Eeeeepa not empty"));
}
static void
test_is_blank_string ()
{
- g_assert (tracker_is_blank_string (NULL));
- g_assert (tracker_is_blank_string (""));
- g_assert (tracker_is_blank_string (" "));
- g_assert (tracker_is_blank_string (" "));
- g_assert (!tracker_is_blank_string (" - "));
- g_assert (!tracker_is_blank_string (" -"));
- g_assert (!tracker_is_blank_string ("- "));
- g_assert (!tracker_is_blank_string ("nonono"));
+ g_assert_true (tracker_is_blank_string (NULL));
+ g_assert_true (tracker_is_blank_string (""));
+ g_assert_true (tracker_is_blank_string (" "));
+ g_assert_true (tracker_is_blank_string (" "));
+ g_assert_true (!tracker_is_blank_string (" - "));
+ g_assert_true (!tracker_is_blank_string (" -"));
+ g_assert_true (!tracker_is_blank_string ("- "));
+ g_assert_true (!tracker_is_blank_string ("nonono"));
}