You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2007/02/02 16:57:01 UTC

svn commit: r502640 - in /webservices/axis2/trunk/c/guththila/tests: s test.c test.h test_attribute.c

Author: dinesh
Date: Fri Feb  2 07:57:00 2007
New Revision: 502640

URL: http://svn.apache.org/viewvc?view=rev&rev=502640
Log:
guththila unit testing added

Added:
    webservices/axis2/trunk/c/guththila/tests/test.h
    webservices/axis2/trunk/c/guththila/tests/test_attribute.c
Modified:
    webservices/axis2/trunk/c/guththila/tests/s
    webservices/axis2/trunk/c/guththila/tests/test.c

Modified: webservices/axis2/trunk/c/guththila/tests/s
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/tests/s?view=diff&rev=502640&r1=502639&r2=502640
==============================================================================
--- webservices/axis2/trunk/c/guththila/tests/s (original)
+++ webservices/axis2/trunk/c/guththila/tests/s Fri Feb  2 07:57:00 2007
@@ -3,11 +3,11 @@
 
 if ($ARGV[0] == 1)
 {
-    print "compiling reader\n";
-    system "gcc -Wall -g3 -O0  -o reader test.c \-L\$AXIS2C_HOME/lib \-I\$AXIS2C_HOME/include -lcheck -lguththila \-laxis2_util";
+    print "compiling writer\n";
+    system "gcc -Wall -g3 -O0  -o writer guththila_writer_main.c -L\$AXIS2C_HOME/lib -I\$AXIS2C_HOME/include -lguththila -laxis2_util";
 }
 else
 {
-    print "compiling writer\n";
-    system "gcc -Wall -g3 -O0  -o writer guththila_writer_main.c -L\$AXIS2C_HOME/lib -I\$AXIS2C_HOME/include -lguththila -laxis2_util";
+    print "compiling reader tests \n";
+    system "gcc -Wall -g3 -O0  -o reader *.c \-L\$AXIS2C_HOME/lib \-I\$AXIS2C_HOME/include -lcheck -lguththila \-laxis2_util";
 }

Modified: webservices/axis2/trunk/c/guththila/tests/test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/tests/test.c?view=diff&rev=502640&r1=502639&r2=502640
==============================================================================
--- webservices/axis2/trunk/c/guththila/tests/test.c (original)
+++ webservices/axis2/trunk/c/guththila/tests/test.c Fri Feb  2 07:57:00 2007
@@ -1,11 +1,8 @@
 #include <check.h>
 #include <guththila.h>
 #include "guththila_defines.h"
+#include "test.h"
 
-axis2_allocator_t *allocator;
-guththila_reader_t *red;
-axis2_env_t *environment;
-guththila_t *parser;
 
 void
 setup (void)
@@ -38,16 +35,130 @@
 	red = guththila_reader_create_for_file(environment, "resources/om/axis.xml");
     parser = guththila_create(environment, red);
 	guththila_read (environment, parser);
-    while ((c = guththila_next(environment, parser)) != -1)
-    {
-        switch (c)
-        {
-            case GUTHTHILA_START_ELEMENT:
-                p = guththila_get_name(environment, parser);
-				break;
-		}
+	c = guththila_next (environment, parser);
+
+    while ((c != GUTHTHILA_START_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_START_ELEMENT), "no start element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "root"), "root element differed");
+	c = 0;
+
+    while ((c != GUTHTHILA_START_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_START_ELEMENT), "no start element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "a"), "a element differed");
+
+	c = 0;
+    while ((c != GUTHTHILA_START_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless (!strcmp (p, "b"), "b element differed");
+}
+END_TEST
+
+START_TEST (test_guththila_empty_element)
+{
+	int c = 0;
+	char *p;
+	red = guththila_reader_create_for_file(environment, "resources/om/axis.xml");
+    parser = guththila_create(environment, red);
+	guththila_read (environment, parser);
+	c = guththila_next (environment, parser);
+
+    while ((c != GUTHTHILA_EMPTY_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_EMPTY_ELEMENT), "no empty element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "a.1"), "a.1 element differed");
+
+	c = 0;
+
+    while ((c != GUTHTHILA_EMPTY_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_EMPTY_ELEMENT), "no empty element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "a.2"), "a.2 element differed");
+
+	c = 0;
+    while ((c != GUTHTHILA_START_ELEMENT))
+		c = guththila_next (environment, parser);
+
+	c = 0;
+    while ((c != GUTHTHILA_EMPTY_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_EMPTY_ELEMENT), "no empty element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "b.1"), "b.1 element differed");
+}
+END_TEST
+
+START_TEST (test_guththila_end_element)
+{
+	int c = 0;
+	char *p;
+	red = guththila_reader_create_for_file(environment, "resources/om/axis.xml");
+    parser = guththila_create(environment, red);
+	guththila_read (environment, parser);
+	c = guththila_next (environment, parser);
+
+    while ((c != GUTHTHILA_END_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_END_ELEMENT), "no end element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "a"), "a element differed");
+
+	c = 0;
+    while ((c != GUTHTHILA_END_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_END_ELEMENT), "no endelement found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "b"), "b element differed");
+
+	c = 0;
+    while ((c != GUTHTHILA_END_ELEMENT))
+		c = guththila_next (environment, parser);
+	p = guththila_get_name(environment, parser);
+	fail_unless ((c == GUTHTHILA_END_ELEMENT), "no empty element found");
+	fail_if ((p == NULL), "no name found");
+	fail_unless (!strcmp (p, "root"), "root element differed");
+}
+END_TEST
+
+START_TEST (test_guththila_character)
+{
+	int c = 0;
+	int i = 0;
+	char *p;
+	red = guththila_reader_create_for_file(environment, "resources/om/numbers.xml");
+    parser = guththila_create(environment, red);
+	guththila_read (environment, parser);
+	c = guththila_next (environment, parser);
+    while (i < 3)
+	{
+		if (c == GUTHTHILA_START_ELEMENT)
+			i++;
+		c = guththila_next (environment, parser);
 	}
-	fail_unless (strcmp (p, "root"), "root element differed");
+
+	if (c == GUTHTHILA_CHARACTER)
+		p = guththila_get_value(environment, parser);
+	fail_unless (!strcmp (p, "3"), "3 not found");
+
+	c = 0;
+	while ((c != GUTHTHILA_CHARACTER) || (parser->is_whitespace))
+		c = guththila_next (environment, parser);
+	p = guththila_get_value(environment, parser);
+	fail_unless (!strcmp (p, "24"), "24 not found");
+
 }
 END_TEST
 
@@ -61,6 +172,9 @@
   tcase_add_checked_fixture (tc_core, setup, teardown);
   tcase_add_test (tc_core, test_guththila);
   tcase_add_test (tc_core, test_guththila_start_element);
+  tcase_add_test (tc_core, test_guththila_empty_element);
+  tcase_add_test (tc_core, test_guththila_end_element);
+  tcase_add_test (tc_core, test_guththila_character);
   suite_add_tcase (s, tc_core);
   return s;
 }
@@ -71,7 +185,10 @@
 {
   int number_failed;
   Suite *s = guththila_suite ();
+  Suite *att = guththila_attribute_suite ();
   SRunner *sr = srunner_create (s);
+  srunner_add_suite (sr, att);
+  srunner_set_log (sr, "guththila.log");
   srunner_run_all (sr, CK_NORMAL);
   number_failed = srunner_ntests_failed (sr);
   srunner_free (sr);

Added: webservices/axis2/trunk/c/guththila/tests/test.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/tests/test.h?view=auto&rev=502640
==============================================================================
--- webservices/axis2/trunk/c/guththila/tests/test.h (added)
+++ webservices/axis2/trunk/c/guththila/tests/test.h Fri Feb  2 07:57:00 2007
@@ -0,0 +1,24 @@
+#ifndef _GUTHTHILA_TESTS_
+#define _GUTHTHILA_TESTS_
+#include <check.h>
+#include <guththila.h>
+#include "guththila_defines.h"
+
+axis2_allocator_t *allocator;
+guththila_reader_t *red;
+axis2_env_t *environment;
+guththila_t *parser;
+
+void
+setup (void);
+void
+teardown (void);
+
+Suite *
+guththila_suite (void);
+
+Suite *
+guththila_attribute_suite (void);
+
+
+#endif 

Added: webservices/axis2/trunk/c/guththila/tests/test_attribute.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/tests/test_attribute.c?view=auto&rev=502640
==============================================================================
--- webservices/axis2/trunk/c/guththila/tests/test_attribute.c (added)
+++ webservices/axis2/trunk/c/guththila/tests/test_attribute.c Fri Feb  2 07:57:00 2007
@@ -0,0 +1,26 @@
+#include <guththila.h>
+#include <check.h>
+#include "test.h"
+
+START_TEST (test_attribute)
+{
+	red = guththila_reader_create_for_file(environment, "resources/om/axis.xml");
+    parser = guththila_create(environment, red);
+	fail_if (red == NULL, "guththila reader failed");
+	fail_if (parser == NULL, "guththila parser failed");
+}
+END_TEST
+
+
+Suite *
+guththila_attribute_suite (void)
+{
+  Suite *s = suite_create ("Guththila_attribute");
+
+  /* Core test case */
+  TCase *tc_core = tcase_create ("attribute");
+  tcase_add_checked_fixture (tc_core, setup, teardown);
+  tcase_add_test (tc_core, test_attribute);
+  suite_add_tcase (s, tc_core);
+  return s;
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org