Enlightenment CVS committal

Author  : ningerso
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/bin/tests/widget


Modified Files:
        ewl_widget.c 


Log Message:
Unit tests for accessing widget specific data.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/widget/ewl_widget.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_widget.c        4 Jan 2007 05:09:45 -0000       1.2
+++ ewl_widget.c        4 Jan 2007 07:49:23 -0000       1.3
@@ -13,9 +13,13 @@
                                                                void *data);
 
 static int appearance_test_set_get(char *buf, int len);
+static int data_test_set_get(char *buf, int len);
+static int data_test_set_remove(char *buf, int len);
 
 static Ewl_Unit_Test widget_unit_tests[] = {
                {"widget appearance set/get", appearance_test_set_get}, 
+               {"widget data set/get", data_test_set_get},     
+               {"widget data set/remove", data_test_set_remove},       
                {NULL, NULL}
        };
 
@@ -146,3 +150,56 @@
        return ret;
 }
 
+static int
+data_test_set_get(char *buf, int len)
+{
+       Ewl_Widget *w;
+       int ret = 0;
+       char *key, *value, *found;
+
+       w = calloc(1, sizeof(Ewl_Widget));
+       ewl_widget_init(w);
+
+       key = strdup("Data key");
+       value = strdup("Data value");
+
+       ewl_widget_data_set(w, key, value);
+       found = ewl_widget_data_get(w, key);
+
+       if (!found)
+               snprintf(buf, len, "could not find set data");
+       else if (found != value)
+               snprintf(buf, len, "found value does not match set data");
+       else 
+               ret = 1;
+
+       return ret;
+}
+
+static int
+data_test_set_remove(char *buf, int len)
+{
+       Ewl_Widget *w;
+       int ret = 0;
+       char *key, *value, *found;
+
+       w = calloc(1, sizeof(Ewl_Widget));
+       ewl_widget_init(w);
+
+       key = strdup("Data key");
+       value = strdup("Data value");
+
+       ewl_widget_data_set(w, key, value);
+       found = ewl_widget_data_del(w, key);
+
+       if (!found)
+               snprintf(buf, len, "could not find set data");
+       else if (found != value)
+               snprintf(buf, len, "removed value does not match set data");
+       else if (ewl_widget_data_get(w, key))
+               snprintf(buf, len, "data value present after remove");
+       else 
+               ret = 1;
+
+       return ret;
+}



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to