[Galago-commits] r2642 - in trunk/libgalago: . libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Thu Mar 30 16:44:56 PST 2006
Author: chipx86
Date: 2006-03-30 16:44:50 -0800 (Thu, 30 Mar 2006)
New Revision: 2642
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-service.c
trunk/libgalago/tests/check-libgalago.c
Log:
Add unit tests for galago_service_normalize().
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-03-30 23:37:50 UTC (rev 2641)
+++ trunk/libgalago/ChangeLog 2006-03-31 00:44:50 UTC (rev 2642)
@@ -1,3 +1,9 @@
+Thu Mar 30 16:44:29 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-service.c:
+ * tests/check-libgalago.c:
+ - Add unit tests for galago_service_normalize().
+
Thu Mar 30 15:34:06 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-account.c:
Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c 2006-03-30 23:37:50 UTC (rev 2641)
+++ trunk/libgalago/libgalago/galago-service.c 2006-03-31 00:44:50 UTC (rev 2642)
@@ -619,14 +619,13 @@
g_return_val_if_fail(GALAGO_IS_SERVICE(service), NULL);
flags = galago_service_get_flags(service);
+ str = g_string_new("");
- str = g_string_new("");
-
for (c = username;
*c != '\0' && (!(flags & GALAGO_STRIP_SLASH) || *c != '/');
c++)
{
- if (*c == ' ' && (flags & GALAGO_PRESERVE_SPACES) == 0)
+ if (*c == ' ' && !(flags & GALAGO_PRESERVE_SPACES))
{
while (*c == ' ')
c++;
@@ -635,7 +634,7 @@
g_string_append_c(str, *c);
}
- if ((flags & GALAGO_PRESERVE_CASE) == 0)
+ if (!(flags & GALAGO_PRESERVE_CASE))
g_string_ascii_down(str);
buffer = g_string_free(str, FALSE);
Modified: trunk/libgalago/tests/check-libgalago.c
===================================================================
--- trunk/libgalago/tests/check-libgalago.c 2006-03-30 23:37:50 UTC (rev 2641)
+++ trunk/libgalago/tests/check-libgalago.c 2006-03-31 00:44:50 UTC (rev 2642)
@@ -296,7 +296,47 @@
}
END_TEST
+
/**************************************************************************
+ * Test the Service object
+ **************************************************************************/
+static void
+test_service_normalize_with(GalagoServiceFlags flags, const char *expectedStr)
+{
+ GalagoService *service;
+ char *username;
+
+ service = galago_create_service("test-service", "Test Service", flags);
+ username = galago_service_normalize(service, "JoeBob Smith/Home");
+ fail_unless(!strcmp(username, expectedStr),
+ "Service normalization failed with flags %d. Resulting string "
+ "\"%s\" didn't match expected string \"%s\".",
+ flags, username, expectedStr);
+ g_free(username);
+ g_object_unref(G_OBJECT(service));
+}
+
+START_TEST(test_service_normalize)
+{
+ galago_init("check-libgalago", FALSE);
+
+ test_service_normalize_with(0,
+ "joebobsmith/home");
+ test_service_normalize_with(GALAGO_PRESERVE_SPACES,
+ "joebob smith/home");
+ test_service_normalize_with(GALAGO_PRESERVE_CASE,
+ "JoeBobSmith/Home");
+ test_service_normalize_with(GALAGO_STRIP_SLASH,
+ "joebobsmith");
+ test_service_normalize_with(GALAGO_PRESERVE_SPACES |
+ GALAGO_PRESERVE_CASE |
+ GALAGO_STRIP_SLASH,
+ "JoeBob Smith");
+}
+END_TEST
+
+
+/**************************************************************************
* Core tests
**************************************************************************/
START_TEST(test_core)
@@ -341,6 +381,9 @@
/* Test the Person object */
ADD_TCASE("person_priority_accounts", test_person_priority_accounts);
+ /* Test the Service object */
+ ADD_TCASE("service_normalize", test_service_normalize);
+
return s;
}
More information about the galago-commits
mailing list