Enlightenment CVS committal

Author  : ningerso
Project : e17
Module  : libs/ewl

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


Modified Files:
        ewl_label.c 


Log Message:
Add basic unit tests for labels.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/label/ewl_label.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_label.c 4 Jun 2007 18:46:34 -0000       1.2
+++ ewl_label.c 8 Nov 2007 07:02:59 -0000       1.3
@@ -5,11 +5,23 @@
 #include "ewl_label.h"
 
 #include <stdio.h>
+#include <string.h>
 
 static int counter = 0;
 static int create_test(Ewl_Container *win);
 static void cb_click(Ewl_Widget *w, void *ev, void *data);
 
+static int label_null_test_get(char *buf, int len);
+static int label_null_test_set_get(char *buf, int len);
+static int label_test_set_get(char *buf, int len);
+
+static Ewl_Unit_Test label_unit_tests[] = {
+               {"label null get", label_null_test_get, -1, NULL},
+               {"label null set/get", label_null_test_set_get, -1, NULL},
+               {"label set/get", label_test_set_get, -1, NULL},
+               {NULL, NULL, -1, NULL}
+       };
+
 void
 test_info(Ewl_Test *test)
 {
@@ -18,6 +30,7 @@
        test->filename = __FILE__;
        test->func = create_test;
        test->type = EWL_TEST_TYPE_SIMPLE;
+       test->unit_tests = label_unit_tests;
 }
 
 static int
@@ -55,4 +68,65 @@
        counter ++;
 }
 
+static int
+label_null_test_get(char *buf, int len)
+{
+       Ewl_Widget *label;
+       int ret = 0;
+
+       label = ewl_label_new();
+
+       if (ewl_label_text_get(EWL_LABEL(label)))
+               snprintf(buf, len, "text_get not NULL");
+       else
+               ret = 1;
+
+       ewl_widget_destroy(label);
+
+       return ret;
+}
+
+static int
+label_null_test_set_get(char *buf, int len)
+{
+       Ewl_Widget *label;
+       const char *val;
+       int ret = 0;
+
+       label = ewl_label_new();
+
+       ewl_label_text_set(EWL_LABEL(label), "some text");
+       ewl_label_text_set(EWL_LABEL(label), NULL);
+
+       val = ewl_label_text_get(EWL_LABEL(label));
+       if (val)
+               snprintf(buf, len, "text_set_get %s instead of NULL", val);
+       else
+               ret = 1;
 
+       ewl_widget_destroy(label);
+
+       return ret;
+}
+
+static int
+label_test_set_get(char *buf, int len)
+{
+       Ewl_Widget *label;
+       const char *val;
+       int ret = 0;
+
+       label = ewl_label_new();
+
+       ewl_label_text_set(EWL_LABEL(label), "some text");
+
+       val = ewl_label_text_get(EWL_LABEL(label));
+       if (strcmp(val, "some text"))
+               snprintf(buf, len, "text_get not NULL");
+       else
+               ret = 1;
+
+       ewl_widget_destroy(label);
+
+       return ret;
+}



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to