Ignore:
Timestamp:
Jun 7, 2008, 6:08:51 PM (17 years ago)
Author:
cinc
Message:

Improvements to test classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nom/class_c/nomtestcase.c

    r356 r358  
    4949
    5050#include "nomarray.h"
     51#include "nomstring.h"
     52#include "nomtestresult.h"
    5153#include "nomtestcase.ih"
    52 #include "nomstring.ih"
    53 #include "nommethod.ih"
     54#include "nommethod.h"
    5455
    55 typedef void* NOMLINK nomProc(void*, void*);
     56typedef boolean NOMLINK nomProc(void*, void*);
    5657
    5758NOMDLLEXPORT NOM_Scope void NOMLINK impl_NOMTestCase_setUp(NOMTestCase* nomSelf,
     
    8687    if(0==strstr( methodName, "test"))
    8788    {
     89      NOMTestResult* nResult=NOMTestResultNew();
    8890      nomProc* nProc=_queryMethodToken(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL);
    8991     
    9092      _setUp(nomSelf, NULL);
    9193     
     94      /* The name of this test */
     95      _setName(nResult, _getName(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL), NULL);
     96     
     97      /* Call the test method */
    9298      if(NULL!=nProc)
    93         nProc(nomSelf, NULL);
     99        _setSuccess(nResult, nProc(nomSelf, NULL), NULL); /* TRUE if success */
    94100     
    95       _tearDown(nomSelf, NULL);     
    96     }
    97    
     101      /* Clean up */
     102      _tearDown(nomSelf, NULL);
     103      NOMArray_append(resultArray, nResult, NULL);
     104    }   
    98105  }
    99106 
     
    101108}
    102109
    103 NOMDLLEXPORT NOM_Scope void NOMLINK impl_NOMTestCase_runSingleTest(NOMTestCase* nomSelf,
     110NOMDLLEXPORT NOM_Scope NOMTestResult* NOMLINK impl_NOMTestCase_runSingleTest(NOMTestCase* nomSelf,
    104111                                                                   const CORBA_char* chrTestName,
    105112                                                                   CORBA_Environment *ev)
    106113{
     114  NOMTestResult* nResult=NOMTestResultNew();
     115  NOMString* nsName;
     116  NOMArray* methodArray=NULL;
     117  int a;
     118 
    107119  /* NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf); */
    108120
    109   _setUp(nomSelf, NULL);
     121  /* Get list of all methods of this class */
     122  methodArray=_nomGetMethodList(nomSelf, FALSE, NULL);
     123
     124  /* The name of this test */
     125  nsName=NOMStringNew();
     126  NOMString_assignString(nsName, chrTestName, NULL);
    110127 
    111   g_message("%s: This method is not yet implemented.", __FUNCTION__);
     128  _setName(nResult, nsName, NULL);
     129
     130  for(a=0; a<NOMArray_length(methodArray, NULL); a++)
     131  {
     132    char* methodName=_queryString(_getName(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL), NULL);
     133   
     134    if(0==strcmp( methodName, chrTestName))
     135    {
     136      nomProc* nProc=_queryMethodToken(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL);
     137     
     138      _setUp(nomSelf, NULL);
     139           
     140      /* Call the test method */
     141      if(NULL!=nProc)
     142        _setSuccess(nResult, nProc(nomSelf, NULL), NULL); /* TRUE if success */
     143     
     144      /* Clean up */
     145      _tearDown(nomSelf, NULL);
     146    }   
     147  }
    112148 
    113   _tearDown(nomSelf, NULL); 
     149  return nResult;
    114150}
    115151
Note: See TracChangeset for help on using the changeset viewer.