fix a direction error spotted by ray. add a boat load of unit tests and fix up the other issues
This commit is contained in:
parent
370de0ba71
commit
c70412f140
@ -277,6 +277,9 @@ pk_task_filter_check_part (const gchar *filter)
|
||||
if (strlen (filter) == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
if (strcmp (filter, "none") == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
if (strcmp (filter, "installed") == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -309,12 +312,24 @@ pk_task_filter_check (const gchar *filter)
|
||||
guint length;
|
||||
gboolean ret;
|
||||
|
||||
if (filter == NULL) {
|
||||
pk_warning ("filter null");
|
||||
return FALSE;
|
||||
}
|
||||
if (strlen (filter) == 0) {
|
||||
pk_warning ("filter zero length");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* split by delimeter ';' */
|
||||
sections = g_strsplit (filter, ";", 0);
|
||||
length = g_strv_length (sections);
|
||||
ret = FALSE;
|
||||
for (i=0; i>length; i++) {
|
||||
for (i=0; i<length; i++) {
|
||||
/* only one wrong part is enough to fail the filter */
|
||||
if (strlen (sections[i]) == 0) {
|
||||
goto out;
|
||||
}
|
||||
if (pk_task_filter_check_part (sections[i]) == FALSE) {
|
||||
goto out;
|
||||
}
|
||||
@ -365,6 +380,11 @@ pk_task_action_contains (const gchar *actions, PkTaskAction action)
|
||||
guint i;
|
||||
guint ret = FALSE;
|
||||
|
||||
if (actions == NULL) {
|
||||
pk_warning ("actions null");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* split by delimeter ';' */
|
||||
sections = g_strsplit (actions, ";", 0);
|
||||
|
||||
@ -389,11 +409,115 @@ libst_task_utils (LibSelfTest *test)
|
||||
{
|
||||
gboolean ret;
|
||||
gchar *text;
|
||||
const gchar *temp;
|
||||
|
||||
if (libst_start (test, "PkTaskUtils", CLASS_AUTO) == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
**************** FILTERS ******************
|
||||
************************************************************/
|
||||
temp = NULL;
|
||||
libst_title (test, "test a fail filter (null)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == FALSE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "passed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "";
|
||||
libst_title (test, "test a fail filter ()");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == FALSE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "passed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = ";";
|
||||
libst_title (test, "test a fail filter (;)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == FALSE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "passed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "moo";
|
||||
libst_title (test, "test a fail filter (invalid)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == FALSE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "passed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "moo;foo";
|
||||
libst_title (test, "test a fail filter (invalid, multiple)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == FALSE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "passed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "gui;;";
|
||||
libst_title (test, "test a fail filter (valid then zero length)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == FALSE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "passed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "none";
|
||||
libst_title (test, "test a pass filter (none)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == TRUE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "failed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "gui";
|
||||
libst_title (test, "test a pass filter (single)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == TRUE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "failed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "devel;~gui";
|
||||
libst_title (test, "test a pass filter (multiple)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == TRUE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "failed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
temp = "~gui;~installed";
|
||||
libst_title (test, "test a pass filter (multiple2)");
|
||||
ret = pk_task_filter_check (temp);
|
||||
if (ret == TRUE) {
|
||||
libst_success (test, NULL);
|
||||
} else {
|
||||
libst_failed (test, "failed the filter '%s'", temp);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
**************** ACTIONS ******************
|
||||
************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user