soylent r249 - trunk/libsoylent/test



Author: svenp
Date: Wed Jul 30 09:47:41 2008
New Revision: 249
URL: http://svn.gnome.org/viewvc/soylent?rev=249&view=rev

Log:
added test-utility functions for printing attributes

Modified:
   trunk/libsoylent/test/test.c
   trunk/libsoylent/test/test.h

Modified: trunk/libsoylent/test/test.c
==============================================================================
--- trunk/libsoylent/test/test.c	(original)
+++ trunk/libsoylent/test/test.c	Wed Jul 30 09:47:41 2008
@@ -38,11 +38,13 @@
 SlBook *
 test_setup_testbook (void)
 {
-  GError *error = NULL;
-  /*const gchar *testbookname = "testbook";
-  SlBook *testbook = sl_book_create (testbookname, &error);*/
   /* workaround for known bug 3 */
-  SlBook *testbook = sl_book_open_default (&error);
+  SlBook *t = SL_BOOK_DEFAULT;
+  return t;
+  
+  GError *error = NULL;
+  const gchar *testbookname = "testbook";
+  SlBook *testbook = sl_book_create (testbookname, &error);
   if (testbook == NULL)
     {
       /* TODO: quit test here...*/
@@ -64,3 +66,32 @@
     }
   g_object_unref (testbook);
 }
+
+void
+test_print_attributes (SlPerson *person)
+{
+  test_print ("--- %s ---", sl_person_get_nick (person));
+  GList *attributes = sl_entity_get_attributes (SL_ENTITY (person));
+  for (; attributes != NULL; attributes = attributes->next)
+    {
+      SlAttribute *attr = attributes->data;
+      test_print_attribute (attr);
+    }
+}
+
+void
+test_print_attribute (SlAttribute *attr)
+{
+  test_print (" * %s", sl_attribute_get_name (attr));
+  GList *values = sl_attribute_get_all (attr);
+  int i = 0;
+  int length = g_list_length (values);
+  for (i = 0; i < length; i++)
+    {
+      /* TODO: this is only possible because we know all attributes are
+       * strings. In future some to_string () functionality is needed?
+       */
+      test_print ("   * %s", (gchar *) values->data);
+      values = values->next;
+    }
+}

Modified: trunk/libsoylent/test/test.h
==============================================================================
--- trunk/libsoylent/test/test.h	(original)
+++ trunk/libsoylent/test/test.h	Wed Jul 30 09:47:41 2008
@@ -46,5 +46,7 @@
 void test_soylent_init (void);
 SlBook *test_setup_testbook (void);
 void test_clean_testbook (SlBook *testbook);
+void test_print_attributes (SlPerson *person);
+void test_print_attribute (SlAttribute *attr);
 
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]