really working unit testcd ../test/ :), avoid using of DefaultTestValue, test unparse...
authorJan Pospíšil <honik@ntc.zcu.cz>
Sun, 16 Sep 2007 22:26:26 +0000 (22:26 +0000)
committerJan Pospíšil <honik@ntc.zcu.cz>
Sun, 16 Sep 2007 22:26:26 +0000 (22:26 +0000)
org.glite.lb.common/test/parse.cpp.T

index 5cb783f..ef8ddd9 100644 (file)
@@ -10,8 +10,6 @@
 class EventParseTest: public  CppUnit::TestFixture
 {
        CPPUNIT_TEST_SUITE(EventParseTest);
-       CPPUNIT_TEST(regJob);
-/*
 @@@{
         for my $e ($event->getTypesOrdered) {
                 my $u = lcfirst $e;
@@ -21,12 +19,9 @@ class EventParseTest: public  CppUnit::TestFixture
                 gen "\tCPPUNIT_TEST($u);\n";
         }
 @@@}
-*/
        CPPUNIT_TEST_SUITE_END();
 
 public:
-       void regJob();
-/*
 @@@{
         for my $e ($event->getTypesOrdered) {
                 my $u = lcfirst $e;
@@ -36,23 +31,25 @@ public:
                 gen "\tvoid $u();\n";
         }
 @@@}
-*/
 
 };
 
-void EventParseTest::regJob()
-{
-       edg_wll_Context ctx;
-       edg_wll_Event   *e1,*e2;
-       char    *line,*et,*ed;
+@@@{
+        for my $e ($event->getTypesOrdered) {
+                my $l = lcfirst $e;
+               if ($l =~ m/^pBS/) { $l = ucfirst $l; }
+               if ($l =~ m/^condor/) { $l = ucfirst $l; }
+                my $u = uc $e;
+                my $c = getTypeComment $event $e;
+                gen qq{
+void EventParseTest::$l()
+\{
+       edg_wll_Context ctx;
+       edg_wll_Event   *e1,*e2;
+       char    *line,*et,*ed;
 
        edg_wll_InitContext(&ctx);
-       e1 = edg_wll_InitEvent(EDG_WLL_EVENT_REGJOB);
-
-       e1->regJob.jdl = strdup("very long job = \"blabla\" \\\\ \n hugh\t;");
-       e1->regJob.ns = strdup("ns address");
-       e1->regJob.jobtype = EDG_WLL_REGJOB_SIMPLE;
-       e1->regJob.seed = strdup("some seed");
+       e1 = edg_wll_InitEvent(EDG_WLL_EVENT_$u);
 
        gettimeofday(&e1->any.timestamp,NULL);
        
@@ -65,61 +62,39 @@ void EventParseTest::regJob()
        e1->any.source = EDG_WLL_SOURCE_USER_INTERFACE;
        e1->any.src_instance = strdup("");
 
-       line = edg_wll_UnparseEvent(ctx,e1);
-       std::cerr << line << std::endl;
-       
-       if (!line) {
-               edg_wll_Error(ctx,&et,&ed);
-               CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_UnparseEvent():") + et + " " + ed, line);
-       }
-
-       if (edg_wll_ParseEvent(ctx,line,&e2)) {
-               edg_wll_Error(ctx,&et,&ed);
-               CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_ParseEvent():") + et + " " + ed, 0);
-       }
-
-       if ((edg_wll_CompareEvents(ctx,e1,e2))) {
-               edg_wll_Error(ctx,&et,&ed);
-               CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0);
-       }
-}
-
-/*
-@@@{
-        for my $e ($event->getTypesOrdered) {
-                my $l = lcfirst $e;
-               if ($l =~ m/^pBS/) { $l = ucfirst $l; }
-               if ($l =~ m/^condor/) { $l = ucfirst $l; }
-                my $u = uc $e;
-                my $c = getTypeComment $event $e;
-                gen "
-void EventParseTest::$l(){
-       edg_wll_Context ctx;
-       edg_wll_Event   *e1,*e2;
-       char    *line,*et,*ed;
-
-       edg_wll_InitContext(&ctx);
-       e1 = edg_wll_InitEvent(EDG_WLL_EVENT_$u);
-";
+};
 
-               selectType $event '_common_';
+               selectType $event "$e";
                for ($event->getFieldsOrdered) {
                        my $f = selectField $event $_;
                        my $fn = getName $f;
-                       my $value = getDefaultTestValue $f;
+
                        if (!$f->{codes}) {
-                               if (!$f->hasAlias('ULM')) {
-                                       my $fu = uc $fn;
-                                       gen "\te1->any.$fn = $value;\n";
-#                                      gen "\tif (". $f->isNULL("e1->any.$fn") .") MISSING(EDG_WLL\_COMMON\_$fu)\n";
-                               } else {
-                                       my $fa = $f->getName('ULM');
-                                       my $fu = uc $fa;
-#                                      gen "\tif (". $f->isNULL("e1->any.$fn") .") MISSING(ULM\_$fu)\n";
+                               my $value = '';
+#                              $value = "e1->$l.$fn = value;";
+#                              $value = $f->fromString('value',"e1->$l.$fn");
+                               if (($f->{type} eq "int") || ($f->{type} eq "port")) { 
+                                       $value = "e1->$l.$fn = 654;";
+                               } elsif (($f->{type} eq "float") || ($f->{type} eq "double")) { 
+                                       $value = "e1->$l.$fn = 3.1415;";
+                               } elsif ($f->{type} eq "string") { 
+                                       $value = "e1->$l.$fn = strdup(\"teststring\");";
+                               } elsif ($f->{type} eq "logsrc") { 
+                                       $value = "e1->$l.$fn = EDG_WLL_SOURCE_APPLICATION;";
+                               } elsif ($f->{type} eq "jobid") { 
+                                       $value = "edg_wlc_JobIdParse(\"https://some.host:1234/x67qr549qc\",&e1->$l.$fn);";
+                               } elsif ($f->{type} eq "notifid") { 
+                                       $value = "edg_wll_NotifIdParse(\"https://some.host:1234/NOTIF:x67qr549qc\",&e1->$l.$fn);";
+                               } else { 
+                                       gen "% FIXME: unknown type $f->{type} for $fn \n"; 
                                }
+                               gen "\t$value\n";
                        }
                }
                gen '
+       line = edg_wll_UnparseEvent(ctx,e1);
+       std::cerr << line << std::endl;
+       
        if (!line) {
                edg_wll_Error(ctx,&et,&ed);
                CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_UnparseEvent():") + et + " " + ed, line);
@@ -135,12 +110,10 @@ void EventParseTest::$l(){
                CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0);
        }
 }
-
 ';
 
         }
 @@@}
-*/
 
 CPPUNIT_TEST_SUITE_REGISTRATION( EventParseTest );