Beispiel #1
0
TST_tpCondRet TST_EfetuarComando( char * CmdTeste )
{
	int argc, Ret, ExpectedRet, iGraph, iData;

	if(! strcmp( CmdTeste , 		GRAPHNEW_CMD) ){


      		argc = LER_LerParametros ( "i", &iGraph );
		
		if ( argc != 1 
			|| iGraph < 0 || iGraph > MAXGRAPHS)
			return TST_CondRetParm;
		vGraph[iGraph] = GRA_New ( DelData );
            	return TST_CompararPonteiroNulo( 1 , vGraph[iGraph],
			"Erro: Ponteiro para novo grafo e' nulo." );


#ifdef _DEBUG

	}else if(! strcmp( CmdTeste , 		SHOW_MEMSPACES) ){


		CED_ExibirTodosEspacos( CED_ExibirTodos );
		return TST_CondRetOK;
#endif


	}else if(! strcmp( CmdTeste , 		GRAPHDEL_CMD) ){


      		argc = LER_LerParametros ( "i", &iGraph );
		
		if ( argc != 1 
			|| iGraph < 0 || iGraph > MAXGRAPHS)
			return TST_CondRetParm;
		GRA_Del ( vGraph[iGraph] );
		vGraph[iGraph] = NULL;

            	return TST_CondRetOK;


	}else if(! strcmp( CmdTeste , 		GRAPHCCUR_CMD) ){


      		argc = LER_LerParametros ( "iii", &iGraph, &iData,
			&ExpectedRet);
		
		if ( argc != 3 
			|| iGraph < 0 || iGraph > MAXGRAPHS
			|| iData  < 0 || iData  > MAXDATAS )
			return TST_CondRetParm;
		Ret = GRA_CCurrent ( vGraph[iGraph],  vData[iData] );

		
		return TST_CompararInt( ExpectedRet , Ret ,
			"Erro: Condicao de retorno errada em CCurent.");


	}else if(! strcmp( CmdTeste , 		GRAPHNEWNODE_CMD) ){


      		argc = LER_LerParametros ( "iii", &iGraph, &iData,
			&ExpectedRet);
		
		if ( argc != 3
			|| iGraph < 0 || iGraph > MAXGRAPHS
			|| iData  < 0 || iData  > MAXDATAS )
			return TST_CondRetParm;
		Ret = GRA_NewNode ( vGraph[iGraph],  vData[iData] );

		
		return TST_CompararInt( ExpectedRet , Ret ,
			"Erro: Condicao de retorno errada em NewNode.");


	}else if(! strcmp( CmdTeste , 		GRAPHDELNODE_CMD) ){


		argc = LER_LerParametros ( "i", &iGraph);
		if ( argc != 1
			|| iGraph < 0 || iGraph > MAXGRAPHS)
			return TST_CondRetParm;
		GRA_DelNode ( vGraph[iGraph] );

		
		return TST_CondRetOK;


	}else if(! strcmp( CmdTeste , 		GRAPHADDLINK_CMD) ){


      		argc = LER_LerParametros ( "iii", &iGraph, &iData,
			&ExpectedRet);
		
		if ( argc != 3 
			|| iGraph < 0 || iGraph > MAXGRAPHS
			|| iData  < 0 || iData  > MAXDATAS )
			return TST_CondRetParm;
		Ret = GRA_AddLink ( vGraph[iGraph],  vData[iData] );

		
		return TST_CompararInt( ExpectedRet , Ret ,
			"Erro: Condicao de retorno errada em AddLink.");


	}else if(! strcmp( CmdTeste , 		GRAPHREMLINK_CMD) ){


      		argc = LER_LerParametros ( "iii", &iGraph, &iData,
			&ExpectedRet);
		
		if ( argc != 3 
			|| iGraph < 0 || iGraph > MAXGRAPHS
			|| iData  < 0 || iData  > MAXDATAS )
			return TST_CondRetParm;
		Ret = GRA_RemLink ( vGraph[iGraph],  vData[iData] );

		
		return TST_CompararInt( ExpectedRet , Ret ,
			"Erro: Condicao de retorno errada em RemLink.");

	}else if(! strcmp( CmdTeste , 		GRAPHGETDATA_CMD) ){


      		argc = LER_LerParametros ( "ii", &iGraph, &iData);
		
		if ( argc != 2
			|| iGraph < 0 || iGraph > MAXGRAPHS
			|| iData  < 0 || iData  > MAXDATAS )
			return TST_CondRetParm;
		vData[iData] = GRA_GetData ( vGraph[iGraph]);

		return TST_CompararPonteiroNulo( 1 , vData[iData],
			"Erro: GetData retornou NULL. Ainda assim, NULL\
			foi armazenado" );
		

	}else if (! strcmp( CmdTeste ,		GRAPHNODESSTART_CMD) ){
Beispiel #2
0
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
{

    int inxLista  = -1 ,
        numLidos   = -1 ,
        CondRetEsp = -1  ;

    char   StringDado[  DIM_VALOR ] ;

    int ValEsp = -1 ;

    int i ;

    int numElem = -1 ;

    StringDado[ 0 ] = 0 ;

    /* Efetuar reset de teste de lista */

    if ( strcmp( ComandoTeste , RESET_LISTA_CMD ) == 0 )
    {

        for( i = 0 ; i < DIM_VT_LISTA ; i++ )
        {
            vtListas[ i ] = NULL ;
        } /* for */

        return TST_CondRetOK ;

    } /* fim ativa: Efetuar reset de teste de lista */

    /* Testar CriarLista */

    else if ( strcmp( ComandoTeste , CRIAR_LISTA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "i" ,
                                      &inxLista ) ;

        if ( ( numLidos != 1 )
                || ( ! ValidarInxLista( inxLista , VAZIO )))
        {
            return TST_CondRetParm ;
        } /* if */

        vtListas[ inxLista ] =
            LIS_CriarLista( DestruirValor ) ;

        return TST_CompararPonteiroNulo( 1 , vtListas[ inxLista ] ,
                                         "Erro em ponteiro de nova lista."  ) ;

    } /* fim ativa: Testar CriarLista */

    /* Testar Esvaziar lista lista */

    else if ( strcmp( ComandoTeste , ESVAZIAR_LISTA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "i" ,
                                      &inxLista ) ;

        if ( ( numLidos != 1 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )))
        {
            return TST_CondRetParm ;
        } /* if */

        LIS_EsvaziarLista( vtListas[ inxLista ] ) ;

        return TST_CondRetOK ;

    } /* fim ativa: Testar Esvaziar lista lista */

    /* Testar Destruir lista */

    else if ( strcmp( ComandoTeste , DESTRUIR_LISTA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "i" ,
                                      &inxLista ) ;

        if ( ( numLidos != 1 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )))
        {
            return TST_CondRetParm ;
        } /* if */

        LIS_DestruirLista( vtListas[ inxLista ] ) ;
        vtListas[ inxLista ] = NULL ;

        return TST_CondRetOK ;

    } /* fim ativa: Testar Destruir lista */

    /* Testar inserir elemento antes */

    else if ( strcmp( ComandoTeste , INS_ELEM_ANTES_CMD ) == 0 )
    {
        struct user *u = (struct user*) malloc (sizeof (struct user));
        LIS_tpCondRet lret;
        if (!u)
            return TST_CondRetMemoria;

        numLidos = LER_LerParametros( "isssi" ,
                                      &inxLista , u->nome, u->tel, u->ender , &CondRetEsp ) ;

        if ( ( numLidos != 5 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        lret = LIS_InserirElementoAntes( vtListas[ inxLista ] , u ) ;

        if ( lret != LIS_CondRetOK )
        {
            free( u ) ;
        } /* if */

        return TST_CompararInt( CondRetEsp , lret ,
                                "Condicao de retorno errada ao inserir antes."                   ) ;

    } /* fim ativa: Testar inserir elemento antes */

    /* Testar inserir elemento apos */

    else if ( strcmp( ComandoTeste , INS_ELEM_APOS_CMD ) == 0 )
    {
        struct user *u = (struct user *)malloc (sizeof (struct user));
        LIS_tpCondRet lret;
        if (!u)
            return TST_CondRetMemoria;

        numLidos = LER_LerParametros( "isssi",
                                      &inxLista, u->nome, u->tel, u->ender, &CondRetEsp ) ;

        if ( ( numLidos != 5 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        lret = LIS_InserirElementoApos( vtListas[ inxLista ] , u ) ;

        if ( lret != LIS_CondRetOK )
        {
            free( u ) ;
        } /* if */

        return TST_CompararInt( CondRetEsp , lret,
                                "Condicao de retorno errada ao inserir antes.") ;
    } /* fim ativa: Testar inserir elemento apos */

    /* Testar excluir simbolo */

    else if ( strcmp( ComandoTeste , EXC_ELEM_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "ii" ,
                                      &inxLista , &CondRetEsp ) ;

        if ( ( numLidos != 2 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        return TST_CompararInt( CondRetEsp ,
                                LIS_ExcluirElemento( vtListas[ inxLista ] ) ,
                                "Condição de retorno errada ao excluir."   ) ;

    } /* fim ativa: Testar excluir simbolo */

    /* Testar obter valor do elemento corrente */
    else if ( strcmp( ComandoTeste , OBTER_NOME_CMD ) == 0 )
    {
        struct user *u;
        numLidos = LER_LerParametros( "isi" ,
                                      &inxLista , StringDado , &ValEsp ) ;

        if ( ( numLidos != 3 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        u = (struct user*) LIS_ObterValor( vtListas[ inxLista ] ) ;

        if ( ValEsp == 0 )
        {
            return TST_CompararPonteiroNulo( 0 , u,
                                             "Valor não deveria existir." ) ;
        } /* if */

        if ( u == NULL )
        {
            return TST_CompararPonteiroNulo( 1 , u,
                                             "Dado tipo um deveria existir." ) ;
        } /* if */

        return TST_CompararString( StringDado , u->nome,
                                   "Valor nome do elemento esta' errado." ) ;
    } /* fim ativa: Testar obter valor do elemento corrente */

    /* Testar obter valor do elemento corrente */
    else if ( strcmp( ComandoTeste, OBTER_TEL_CMD ) == 0 )
    {
        struct user *u;
        numLidos = LER_LerParametros( "isi" ,
                                      &inxLista , StringDado , &ValEsp ) ;

        if ( ( numLidos != 3 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        u = (struct user*) LIS_ObterValor( vtListas[ inxLista ] ) ;

        if ( ValEsp == 0 )
        {
            return TST_CompararPonteiroNulo( 0 , u,
                                             "Valor não deveria existir." ) ;
        } /* if */

        if ( u == NULL )
        {
            return TST_CompararPonteiroNulo( 1 , u,
                                             "Dado tipo um deveria existir." ) ;
        } /* if */

        return TST_CompararString( StringDado , u->tel,
                                   "Valor nome do elemento esta' errado." ) ;
    } /* fim ativa: Testar obter valor do elemento corrente */
    /* Testar obter valor do elemento corrente */
    else if ( strcmp( ComandoTeste , OBTER_ENDER_CMD ) == 0 )
    {
        struct user *u;
        numLidos = LER_LerParametros( "isi" ,
                                      &inxLista , StringDado , &ValEsp ) ;

        if ( ( numLidos != 3 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        u = (struct user*) LIS_ObterValor( vtListas[ inxLista ] ) ;

        if ( ValEsp == 0 )
        {
            return TST_CompararPonteiroNulo( 0 , u,
                                             "Valor não deveria existir." ) ;
        } /* if */

        if ( u == NULL )
        {
            return TST_CompararPonteiroNulo( 1 , u,
                                             "Dado tipo um deveria existir." ) ;
        } /* if */

        return TST_CompararString( StringDado , u->ender,
                                   "Valor nome do elemento esta' errado." ) ;
    } /* fim ativa: Testar obter valor do elemento corrente */

    /* Testar ir para o elemento inicial */

    else if ( strcmp( ComandoTeste , IR_INICIO_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "i" , &inxLista ) ;

        if ( ( numLidos != 1 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        IrInicioLista( vtListas[ inxLista ] ) ;

        return TST_CondRetOK ;

    } /* fim ativa: Testar ir para o elemento inicial */

    /* LIS  &Ir para o elemento final */

    else if ( strcmp( ComandoTeste , IR_FIM_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "i" , &inxLista ) ;

        if ( ( numLidos != 1 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        IrFinalLista( vtListas[ inxLista ] ) ;

        return TST_CondRetOK ;

    } /* fim ativa: LIS  &Ir para o elemento final */

    /* LIS  &Avançar elemento */

    else if ( strcmp( ComandoTeste , AVANCAR_ELEM_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iii" , &inxLista , &numElem ,
                                      &CondRetEsp ) ;

        if ( ( numLidos != 3 )
                || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
        {
            return TST_CondRetParm ;
        } /* if */

        return TST_CompararInt( CondRetEsp ,
                                LIS_AvancarElementoCorrente( vtListas[ inxLista ] , numElem ) ,
                                "Condicao de retorno errada ao avancar" ) ;

    } /* fim ativa: LIS  &Avançar elemento */

    return TST_CondRetNaoConhec ;

} /* Fim função: TLIS &Testar lista */
Beispiel #3
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {

      int inxTabela  = -1 ,
          idTipo     = -1 ,
          numLidos   = -1 ,
          CondRetEsp = -1  ;

      TST_tpCondRet CondRet ;

      char StringDado[  DIM_SIMB ] ;
      char StringValor[ DIM_SIMB ] ;

      int i ;

      int tamTabela = -1 ;

      int ValInt = -1 ;

      tpTipo1 * pDado1 ;

      char ValChar = '\0' ;

      tpTipo2 * pDado2 ;

      tpTipo3 * pDado3 ;

      int ValIntEsp = -1 ;

      char ValCharEsp = '*' ;

      StringDado[ 0 ] = 0 ;

      /* Efetuar reset de teste de tabela */

         if ( strcmp( ComandoTeste , RESET_TAB_CMD ) == 0 )
         {

            for( i = 0 ; i < DIM_VT_TABELAS ; i++ )
            {
               vtTabelas[ i ] = NULL ;
            } /* for */

            return TST_CondRetOK ;

         } /* fim ativa: Efetuar reset de teste de tabela */

      /* Testar CriarTabela */

         else if ( strcmp( ComandoTeste , CRIAR_TAB_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" ,
                       &inxTabela , &tamTabela , &idTipo ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxTabela( inxTabela , VAZIO ))
              || ( ! ValidarIdTipo( idTipo ))
              || ( tamTabela <= 1 ))
            {
               return TST_CondRetParm ;
            } /* if */

            if ( idTipo == ID_TIPO_1 )
            {
               vtTabelas[ inxTabela ] =
                    TBS_CriarTabela( tamTabela , ObterSimboloTipoUm , NULL ) ;
            } else if ( idTipo == ID_TIPO_2 )
            {
               vtTabelas[ inxTabela ] =
                    TBS_CriarTabela( tamTabela , ObterSimboloTipoDois , NULL ) ;
            } else
            {
               vtTabelas[ inxTabela ] =
                    TBS_CriarTabela( tamTabela , ObterSimboloTipoTres ,
                                                 LiberarDadoTipoTres    ) ;
            } /* if */

            return TST_CompararPonteiroNulo( 1 , vtTabelas[ inxTabela ] ,
               "Erro em ponteiro de nova tabela."  ) ;

         } /* fim ativa: Testar CriarTabela */

      /* Testar Destruir tabela */

         else if ( strcmp( ComandoTeste , DESTRUIR_TAB_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxTabela ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            TBS_DestruirTabela( vtTabelas[ inxTabela ] ) ;
            vtTabelas[ inxTabela ] = NULL ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Destruir tabela */

      /* Testar Inserir simbolo tipo um */

         else if ( strcmp( ComandoTeste , INS_SIMB_UM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iisi" ,
                       &inxTabela , &ValInt , StringDado , &CondRetEsp ) ;

            if ( ( numLidos != 4 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado1 = ( tpTipo1 * ) malloc( sizeof( tpTipo1 )) ;
            if ( pDado1 == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */

            pDado1->Conta   = ValInt ;
            strcpy( pDado1->SimboloUm , StringDado ) ;


            CondRet = (TST_tpCondRet) TBS_InserirSimbolo( vtTabelas[ inxTabela ] , pDado1 ) ;

            if ( CondRet != TBS_CondRetOK )
            {
               free( pDado1 ) ;
            } /* if */

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condição de retorno errada em símbolo tipo um."                   ) ;

         } /* fim ativa: Testar Inserir simbolo tipo um */

      /* Testar Inserir simbolo tipo dois */

         else if ( strcmp( ComandoTeste , INS_SIMB_DOIS_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "icsi" ,
                       &inxTabela , &ValChar , StringDado , &CondRetEsp ) ;

            if ( ( numLidos != 4 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado2 = ( tpTipo2 * ) malloc( sizeof( tpTipo2 )) ;
            if ( pDado2 == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */
            pDado2->Id   = ValChar ;
            strcpy( pDado2->SimboloDois , StringDado ) ;

            return TST_CompararInt( CondRetEsp ,
                          TBS_InserirSimbolo( vtTabelas[ inxTabela ] , pDado2 ) ,
                     "Condição de retorno errada em símbolo tipo dois."                   ) ;

         } /* fim ativa: Testar Inserir simbolo tipo dois */

      /* Testar Inserir simbolo tipo tres */

         else if ( strcmp( ComandoTeste , INS_SIMB_TRES_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "issi" ,
                       &inxTabela , StringDado , StringValor , &CondRetEsp ) ;

            if ( ( numLidos != 4 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado3 = ( tpTipo3 * ) malloc( sizeof( tpTipo3 )) ;
            if ( pDado3 == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */

            pDado3->pString = (char*) malloc( strlen( StringValor ) + 1 ) ;
            strcpy( pDado3->pString , StringValor ) ;

            strcpy( pDado3->SimboloTres , StringDado ) ;

            return TST_CompararInt( CondRetEsp ,
                          TBS_InserirSimbolo( vtTabelas[ inxTabela ] , pDado3 ) ,
                     "Condição de retorno errada em símbolo tipo dois."                   ) ;

         } /* fim ativa: Testar Inserir simbolo tipo tres */

      /* Testar excluir simbolo */

         else if ( strcmp( ComandoTeste , EXC_SIMB_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( (char*)  "isi" ,
                  (char*) &inxTabela , (char*) StringDado , (char*) &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp ,
                      TBS_ExcluirSimbolo( vtTabelas[ inxTabela ] , StringDado ) ,
                     "Condição de retorno errada ao excluir."                   ) ;

         } /* fim ativa: Testar excluir simbolo */

      /* Testar procurar símbolo tipo 1 */

         else if ( strcmp( ComandoTeste , PROCURAR_SIMB_UM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isi" ,
                       &inxTabela , StringDado , &ValIntEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado1 = ( tpTipo1 * ) TBS_ProcurarSimbolo( vtTabelas[ inxTabela ] ,
                                            StringDado ) ;
            if ( ValIntEsp == -1 )
            {
               return TST_CompararPonteiroNulo( 0 , pDado1 ,
                         "Dado tipo um não deveria existir." ) ;
            } /* if */

            if ( pDado1 == NULL )
            {
               return TST_CompararPonteiroNulo( 1 , pDado1 ,
                         "Dado tipo um deveria existir." ) ;
            } /* if */

            return TST_CompararInt( ValIntEsp , pDado1->Conta ,
                         "Valor tipo um errado." ) ;

         } /* fim ativa: Testar procurar símbolo tipo 1 */

      /* Testar procurar símbolo tipo 2 */

         else if ( strcmp( ComandoTeste , PROCURAR_SIMB_DOIS_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isc" ,
                       &inxTabela , StringDado , &ValCharEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado2 = ( tpTipo2 * ) TBS_ProcurarSimbolo( vtTabelas[ inxTabela ] ,
                                            StringDado ) ;
            if ( ValCharEsp == '*' )
            {
               return TST_CompararPonteiroNulo( 0 , pDado2 ,
                         "Dado tipo dois não deveria existir." ) ;
            } /* if */

            if ( pDado2 == NULL )
            {
               return TST_CompararPonteiroNulo( 1 , pDado2 ,
                         "Dado tipo dois deveria existir." ) ;
            } /* if */

            return TST_CompararChar( ValCharEsp , pDado2->Id ,
                         "Valor tipo dois errado." ) ;

         } /* fim ativa: Testar procurar símbolo tipo 2 */

      /* Testar procurar símbolo tipo 3 */

         else if ( strcmp( ComandoTeste , PROCURAR_SIMB_TRES_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iss" ,
                       &inxTabela , StringDado , StringValor ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado3 = ( tpTipo3 * ) TBS_ProcurarSimbolo( vtTabelas[ inxTabela ] ,
                                            StringDado ) ;

            if ( pDado3 == NULL )
            {
               return TST_CompararPonteiroNulo( 1 , pDado3 ,
                         "Dado tipo três deveria existir." ) ;
            } /* if */

            return TST_CompararString( StringValor , pDado3->pString ,
                         "Valor tipo três errado." ) ;

         } /* fim ativa: Testar procurar símbolo tipo 3 */

      /* Testar validar Tabela de símbolos */
      #ifdef _DEBUG

         else if ( strcmp( ComandoTeste , VALIDAR_TAB_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxTabela ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxTabela( inxTabela , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            return TBS_ValidarTabela( vtTabelas[ inxTabela ] ) ;

         } /* fim ativa: Testar validar Tabela de símbolos */
      #endif

      return TST_CondRetNaoConhec ;

   } /* Fim função: TTBS &Testar tabela de símbolos */
Beispiel #4
0
TST_tpCondRet TST_EfetuarComando(char * ComandoTeste)
{
    int inxLista  = -1, numLidos   = -1, CondRetEsp = -1;

    TST_tpCondRet CondRet;

    char   StringDado[DIM_VALOR];
    char * pDado;

    int IntDado[DIM_VALOR_INT];
    int* pDadoInt;

    int ValEsp = -1;
    int i;
    int numElem = -1;

    int inxStoredPtr;

    for(i = 0; i < DIM_VT_LISTA; i++)
        storedPtr[i][0] = NULL;
    StringDado[0] = 0;

    /* Efetuar reset de teste de lista */
    if(strcmp(ComandoTeste, RESET_LISTA_CMD) == 0) {
        for(i = 0; i < DIM_VT_LISTA; i++) {
            vtListas[i] = NULL;
            storedPtrIndex[i] = 1;
        }

        return TST_CondRetOK;

    } /* fim ativa: Efetuar reset de teste de lista */

    /* Testar CriarLista */
    else if(strcmp(ComandoTeste, CRIAR_LISTA_CMD) == 0) {
        numLidos = LER_LerParametros("i", &inxLista);

        if((numLidos != 1) || (!ValidarInxLista(inxLista, VAZIO)))
            return TST_CondRetParm;

        vtListas[inxLista] = LIS_CriarLista(DestruirValor);

        return TST_CompararPonteiroNulo(1, vtListas[inxLista], "Erro em ponteiro de nova lista.");
    } /* fim ativa: Testar CriarLista */

    /* Testar Esvaziar lista lista */
    else if(strcmp(ComandoTeste, ESVAZIAR_LISTA_CMD) == 0) {
        numLidos = LER_LerParametros("i", &inxLista);

        if((numLidos != 1) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        LIS_EsvaziarLista(vtListas[inxLista]);
        return TST_CondRetOK;

    } /* fim ativa: Testar Esvaziar lista lista */

    /* Testar Destruir lista */
    else if(strcmp(ComandoTeste, DESTRUIR_LISTA_CMD) == 0) {
        numLidos = LER_LerParametros("i", &inxLista);

        if((numLidos != 1) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        LIS_DestruirLista(vtListas[inxLista]);
        vtListas[inxLista] = NULL;
        return TST_CondRetOK;

    } /* fim ativa: Testar Destruir lista */

    /* Testar inserir elemento antes */
    else if(strcmp(ComandoTeste, INS_ELEM_ANTES_CMD) == 0) {
        numLidos = LER_LerParametros("isi", &inxLista, StringDado, &CondRetEsp);

        if((numLidos != 3) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        if(!ValidarInxStoredPtr(storedPtrIndex[inxLista]))
            return TST_CondRetMemoria;

        pDado = (char *) malloc(strlen(StringDado) + 1);
        if(pDado == NULL)
            return TST_CondRetMemoria;

        storedPtr[inxLista][storedPtrIndex[inxLista]++] = pDado;
        strcpy(pDado, StringDado);

        CondRet = LIS_InserirElementoAntes(vtListas[inxLista], pDado);
        if(CondRet != LIS_CondRetOK)
            free(pDado);

        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir antes.");
    } /* fim ativa: Testar inserir elemento antes */

    /* Testar inserir elemento antes INTEIRO */
    else if(strcmp(ComandoTeste, INS_ELEM_ANTES_CMD_INT) == 0) {
        numLidos = LER_LerParametros("iiii", &inxLista, &IntDado[0], &IntDado[1], &CondRetEsp);

        if((numLidos != 4) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        if(!ValidarInxStoredPtr(storedPtrIndex[inxLista]))
            return TST_CondRetMemoria;

        pDadoInt = (int *) malloc(DIM_VALOR_INT*sizeof(int));
        if(pDadoInt == NULL)
            return TST_CondRetMemoria;

        storedPtr[inxLista][storedPtrIndex[inxLista]++] = pDadoInt;
        for(i=0;i<DIM_VALOR_INT;i++)
            pDadoInt[i]=IntDado[i];

        CondRet = LIS_InserirElementoAntes(vtListas[inxLista], pDadoInt);
        if(CondRet != LIS_CondRetOK)
            free(pDadoInt);

        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir antes.");
    } /* fim ativa: Testar inserir elemento antes INTEIRO*/

    /* Testar inserir elemento apos */
    else if(strcmp(ComandoTeste, INS_ELEM_APOS_CMD) == 0) {
        numLidos = LER_LerParametros("isi", &inxLista, StringDado, &CondRetEsp);

        if((numLidos != 3) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        if(!ValidarInxStoredPtr(storedPtrIndex[inxLista]))
            return TST_CondRetMemoria;

        pDado = (char*)malloc(strlen(StringDado) + 1);
        if(pDado == NULL)
            return TST_CondRetMemoria;

        storedPtr[inxLista][storedPtrIndex[inxLista]++] = pDado;
        strcpy(pDado, StringDado);

        CondRet = LIS_InserirElementoApos(vtListas[inxLista], pDado);
        if(CondRet != LIS_CondRetOK)
            free(pDado);

        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir apos.");
    } /* fim ativa: Testar inserir elemento apos */

    /* Testar inserir elemento apos INTEIRO*/
    else if(strcmp(ComandoTeste, INS_ELEM_APOS_CMD_INT) == 0) {
        numLidos = LER_LerParametros("iiii", &inxLista, &IntDado[0], &IntDado[1], &CondRetEsp);

        if((numLidos != 4) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        if(!ValidarInxStoredPtr(storedPtrIndex[inxLista]))
            return TST_CondRetMemoria;

        pDadoInt = (int *) malloc(DIM_VALOR_INT * sizeof(int));
        if(pDadoInt == NULL)
            return TST_CondRetMemoria;

        storedPtr[inxLista][storedPtrIndex[inxLista]++] = pDadoInt;
        for(i=0;i<DIM_VALOR_INT;i++)
            pDadoInt[i]=IntDado[i];

        CondRet = LIS_InserirElementoApos(vtListas[inxLista], pDadoInt);

        if(CondRet != LIS_CondRetOK)
            free(pDadoInt);

        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir apos.");
    } /* fim ativa: Testar inserir elemento apos INTEIRO*/

    /* Testar excluir simbolo */
    else if(strcmp(ComandoTeste, EXC_ELEM_CMD) == 0) {
        numLidos = LER_LerParametros("ii", &inxLista, &CondRetEsp);

        if((numLidos != 2) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        return TST_CompararInt(CondRetEsp, LIS_ExcluirElemento(vtListas[inxLista]),
                               "Condição de retorno errada ao excluir.");
    } /* fim ativa: Testar excluir simbolo */

    /* Testar obter valor do elemento corrente */
    else if(strcmp(ComandoTeste, OBTER_VALOR_CMD) == 0) {
        numLidos = LER_LerParametros("isi", &inxLista, StringDado, &ValEsp);

        if((numLidos != 3) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        pDado = (char *) LIS_ObterValor(vtListas[inxLista]);
        if(ValEsp == 0)
            return TST_CompararPonteiroNulo(0, pDado, "Valor não deveria existir.");

        if(pDado == NULL)
            return TST_CompararPonteiroNulo(1, pDado, "Dado tipo um deveria existir.");

        return TST_CompararString(StringDado, pDado, "Valor do elemento errado.");
    } /* fim ativa: Testar obter valor do elemento corrente */

    /* Testar obter valor do elemento corrente INTEIRO*/
    else if(strcmp(ComandoTeste, OBTER_VALOR_CMD_INT) == 0) {
        numLidos = LER_LerParametros("iiii", &inxLista, &IntDado[0], &IntDado[1], &ValEsp);

        if((numLidos != 4) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        pDadoInt = (int *)LIS_ObterValor(vtListas[inxLista]);
        if(ValEsp == 0)
            return TST_CompararPonteiroNulo(0, pDadoInt, "Valor não deveria existir.");

        if(pDadoInt == NULL)
            return TST_CompararPonteiroNulo(1, pDadoInt, "Dado tipo um deveria existir.");

        return TST_CompararEspaco(IntDado, pDadoInt, DIM_VALOR_INT * sizeof(int),
                                  "Valor do elemento errado.");
    } /* fim ativa: Testar obter valor do elemento corrente INTEIRO*/

    /* Testar ir para o elemento inicial */
    else if(strcmp(ComandoTeste, IR_INICIO_CMD) == 0) {
        numLidos = LER_LerParametros("i", &inxLista);

        if((numLidos != 1) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        LIS_IrInicioLista(vtListas[inxLista]);
        return TST_CondRetOK;
    } /* fim ativa: Testar ir para o elemento inicial */

    /* LIS  &Ir para o elemento final */
    else if(strcmp(ComandoTeste, IR_FIM_CMD) == 0) {
        numLidos = LER_LerParametros("i", &inxLista);

        if((numLidos != 1) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        LIS_IrFinalLista(vtListas[inxLista]);
        return TST_CondRetOK;
    } /* fim ativa: LIS  &Ir para o elemento final */

    /* LIS  &Avançar elemento */
    else if(strcmp(ComandoTeste, AVANCAR_ELEM_CMD) == 0) {
        numLidos = LER_LerParametros("iii", &inxLista, &numElem, &CondRetEsp);

        if((numLidos != 3) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        return TST_CompararInt(CondRetEsp,
                               LIS_AvancarElementoCorrente(vtListas[inxLista], numElem),
                               "Condicao de retorno errada ao avancar");

    } /* fim ativa: LIS  &Avançar elemento */

    /* Testar Ir Indice */
    else if(strcmp(ComandoTeste, IR_INDICE_CMD) == 0) {
        numLidos = LER_LerParametros("iii", &inxLista, &numElem, &CondRetEsp);
        if((numLidos != 3) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        return TST_CompararInt(CondRetEsp, LIS_IrIndice(vtListas[inxLista], numElem),
                               "Condicao de retorno errada ao ir para o índice");
    } /* fim ativa: Testar Ir Indice */

    /* Testar Setar Valor INTEIRO*/
    else if(strcmp(ComandoTeste, SETAR_VALOR_CMD_INT) == 0) {
        numLidos = LER_LerParametros("iiii", &inxLista, &IntDado[0], &IntDado[1], &CondRetEsp);
        if((numLidos != 4) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        if(!ValidarInxStoredPtr(storedPtrIndex[inxLista]))
            return TST_CondRetMemoria;

        pDadoInt = (int *) malloc(DIM_VALOR_INT * sizeof(int));
        if(pDadoInt == NULL)
            return TST_CondRetMemoria;

        storedPtr[inxLista][storedPtrIndex[inxLista]++] = pDadoInt;
        for(i=0;i<DIM_VALOR_INT;i++)
            pDadoInt[i]=IntDado[i];

        return TST_CompararInt(CondRetEsp, LIS_SetarValor(vtListas[inxLista], pDadoInt),
                               "Condicao de retorno errada ao ir marcar o valor");
    } /* fim ativa: LIS  Setar Valor INTEIRO*/

    /* Testar Procurar Valor */
    else if(strcmp(ComandoTeste, PROCURAR_VALOR_CMD) == 0) {
        numLidos = LER_LerParametros("iii", &inxLista, &inxStoredPtr, &CondRetEsp);
        if((numLidos != 3) || (!ValidarInxLista(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        if(!ValidarInxStoredPtr(inxStoredPtr))
            return TST_CondRetParm;

        return TST_CompararInt(CondRetEsp, LIS_ProcurarValor(vtListas[inxLista], storedPtr[inxLista][inxStoredPtr]),
                               "Condicao de retorno errada ao procurar valor");
    } /* fim ativa: LIS Procurar Valor */

    return TST_CondRetNaoConhec;
} /* Fim função: TLIS &Testar lista */
Beispiel #5
0
TST_tpCondRet TST_EfetuarComando(char *ComandoTeste)
{
    int inxLista  = -1;
    int numLidos   = -1;
    int CondRetEsp = -1;
    char StringDado[DIM_VALOR];
    int i;
    int CondRet;
    int tipo = -1;
    int caracter = -1;
    StringDado[0] = 0;

    /* Efetuar reset de teste de peca */
    if(strcmp(ComandoTeste, RESET_PECA_CMD) == 0) {
        for(i = 0; i < DIM_VT_PECA; i++)
            vtPecas[i] = NULL;

        return TST_CondRetOK;
    } /* fim ativa: Efetuar reset de teste de lista */

    /* Testar Criar peca */
    else if(strcmp(ComandoTeste, CRIAR_PECA_CMD) == 0) {
        numLidos = LER_LerParametros("iis", &inxLista, &tipo, StringDado);

        if((numLidos != 3) || (!ValidarInxPeca(inxLista, VAZIO)))
            return TST_CondRetParm;

        vtPecas[inxLista] = PEC_criar(tipo, StringDado[0]);
        return TST_CompararPonteiroNulo(1, vtPecas[inxLista], "Erro em ponteiro de nova peca.");
    } /* fim ativa: Testar Criar peca */

    /* Testar Destruir peca*/
    else if(strcmp(ComandoTeste, DESTRUIR_PECA_CMD) == 0) {
        numLidos = LER_LerParametros("ii", &inxLista, &CondRetEsp);

        if((numLidos != 2) || (!ValidarInxPeca(inxLista, INDIFERENTE)))
            return TST_CondRetParm;

        CondRet = PEC_destruir(vtPecas[inxLista]);
        vtPecas[inxLista] = NULL;
        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao destruir a peca.") ;
    } /* fim ativa: Testar Destruir peca */

    /* Testar Obter Tipo da peca*/
    else if(strcmp(ComandoTeste, OBTER_TIPO_CMD) == 0) {
        numLidos = LER_LerParametros("ii", &inxLista, &CondRetEsp);

        if((numLidos != 2) || (!ValidarInxPeca(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        tipo = PEC_obterTipo(vtPecas[inxLista]);
        return TST_CompararInt(CondRetEsp, tipo, "Tipo errado ao obter tipo.");
    } /* fim ativa: Testar Obter Tipo da peca */

    /* Testar Setar Tipo da peca*/
    else if(strcmp(ComandoTeste, SETAR_TIPO_CMD) == 0) {
        numLidos = LER_LerParametros("iii", &inxLista, &tipo, &CondRetEsp);

        if((numLidos != 3) || (!ValidarInxPeca(inxLista, INDIFERENTE)))
            return TST_CondRetParm;

        CondRet = PEC_setarTipo(vtPecas[inxLista], tipo);
        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao setar tipo da peca.");
    } /* fim ativa: Testar Setar Tipo da peca */

    /* Testar Obter Caracter da peca*/
    else if(strcmp(ComandoTeste, OBTER_CARACTER_CMD) == 0) {
        numLidos = LER_LerParametros("is", &inxLista, StringDado);

        if((numLidos != 2) || (!ValidarInxPeca(inxLista, NAO_VAZIO)))
            return TST_CondRetParm;

        caracter = PEC_obterCaracter(vtPecas[inxLista]);
        return TST_CompararEspaco(StringDado, &caracter, 1, "Caracter errado ao obter caracter.");
    } /* fim ativa: Testar Obter Caracter da peca */

    /* Testar Setar Caracter da peca*/
    else if(strcmp(ComandoTeste, SETAR_CARACTER_CMD) == 0) {
        numLidos = LER_LerParametros("isi", &inxLista, StringDado, &CondRetEsp);

        if((numLidos != 3) || (!ValidarInxPeca(inxLista, INDIFERENTE)))
            return TST_CondRetParm;

        CondRet = PEC_setarCaracter(vtPecas[inxLista], StringDado[0]);
        return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao setar caracter da peca.");
    } /* fim ativa: Testar Setar Caracter da peca */

    return TST_CondRetNaoConhec;
} /* Fim função: TPEC &Testar peca */
Beispiel #6
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {
	   LAB_tppLabirinto epLabirinto=NULL;


      int inxLabirinto  = -1 ,
          numLidos   = -1 ,
          CondRetEsp = -1  ;

      TST_tpCondRet CondRet ;

      char   StringDado[  DIM_VALOR ] ;
      char * pDado ;
	  char ** strp;

      int ValEsp = -1 ;

      int i ;
	  int j;
	  int noCorrente;
	  int noCorrenteEsperado;
	  int* intpointer;
      int numElem = -1 ;
	  int valorAresta;
      StringDado[ 0 ] = 0 ;

      /* Efetuar reset de teste de labirinto */

         if ( strcmp( ComandoTeste , RESET_LABIRINTO_CMD ) == 0 )
         {

            for( i = 0 ; i < DIM_VT_LABIRINTO ; i++ )
            {
               VTLABIRINTO[ i ] = NULL ;
            } /* for */

            return TST_CondRetOK ;

         } /* fim ativa: Efetuar reset de teste de labirinto */

      /* Testar CriarLabirinto */

         else if ( strcmp( ComandoTeste , CRIAR_LABIRINTO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                       &inxLabirinto ) ;

			
            if ( ( numLidos != 1 )
              || ( ! ValidarInxLabirinto( inxLabirinto , VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */
			
            LAB_CriarLabirinto(&VTLABIRINTO[ inxLabirinto ]) ;
				 //eplabirinto retornado por ref

            return TST_CompararPonteiroNulo( 1 , VTLABIRINTO[ inxLabirinto ] ,
               "Erro em ponteiro de novo labirinto."  ) ;

         } /* fim ativa: Testar CriarLabirinto */
		    /* Testar CriarLabirinto */

         else if ( strcmp( ComandoTeste , DESTRUIR_LABIRINTO_CMD ) == 0 )
         {

           numLidos = LER_LerParametros( "i" ,
                       &inxLabirinto ) ;
		   
            if ( ( numLidos != 1 )
              || ( ! ValidarInxLabirinto( inxLabirinto , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */
			
            LAB_DestruirLabirinto(VTLABIRINTO[ inxLabirinto ]) ;
				 //eplabirinto retornado por ref
			VTLABIRINTO[inxLabirinto]=0;
            return TST_CompararPonteiroNulo( 0 , VTLABIRINTO[ inxLabirinto ] ,
               "Erro em ponteiro de labirinto."  ) ;

         } /* fim ativa: Testar DestruirLabirinto */
   }
   TST_tpCondRet TST_EfetuarComando(char *ComandoTeste)
   {
      int numLidos   = -1,
          CondRetEsp = -1;

      TST_tpCondRet CondRet;

      /*Testar CriarGrafo */

         if (strcmp (ComandoTeste, CRIAR_GRAFO_CMD) == 0)
         {

            numLidos = LER_LerParametros("i", &CondRetEsp);

            if (numLidos != 1)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_CriarGrafo(&pGrafo, DestruirValor);

            if(CondRet ==  GRA_CondRetOK)
            {
               CondRet = TST_CompararPonteiroNulo(1, pGrafo, "Erro em ponteiro de nova lista.");
               return CondRet;
            }

            return TST_CondRetErro;

         }

     /*Testar Destruir grafo */

         else if (strcmp(ComandoTeste, DESTRUIR_GRAFO_CMD) == 0)
         {

            numLidos = LER_LerParametros("i", &CondRetEsp);

            if (numLidos != 1)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_DestruirGrafo(&pGrafo);

            return TST_CompararInt(CondRetEsp, CondRet, "Erro ao destruir grafo");

         }
     
      /*Testar inserir vertice */

         else if (strcmp(ComandoTeste, INS_VERT_CMD) == 0)
         {
            char *nome = AlocarEspacoParaNome();
            char *pDado = AlocarEspacoParaNome();

            numLidos = LER_LerParametros("ssi", nome, pDado, &CondRetEsp);

            if (numLidos != 3)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_InserirVertice(pGrafo, nome, pDado);

            return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir vértice.");

         }
    
      /*Testar inserir aresta */

         else if (strcmp(ComandoTeste, INS_ARESTA_CMD) == 0)
         {
            char *nomeAresta = AlocarEspacoParaNome();
            char *nomeVerticeOrig = AlocarEspacoParaNome();
            char *nomeVerticeDest = AlocarEspacoParaNome();

            numLidos = LER_LerParametros("sssi", nomeAresta, nomeVerticeOrig, nomeVerticeDest, &CondRetEsp);

            if (numLidos != 4)
            {
               return TST_CondRetParm;
            }
   
            CondRet = GRA_InserirAresta(pGrafo, nomeAresta, nomeVerticeOrig, nomeVerticeDest);

            MEM_Free(nomeVerticeOrig);
            MEM_Free(nomeVerticeDest);

            return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir aresta.");
         }

      /*Testar obter valor do vértice corrente */

         else if (strcmp(ComandoTeste, OBTER_VALOR_CMD) == 0)
         {
            char *pDadoEsperado = AlocarEspacoParaNome();
            char *pDadoObtido;

            numLidos = LER_LerParametros("si", pDadoEsperado, &CondRetEsp);

            if (numLidos != 2)
            {
               MEM_Free(pDadoEsperado);
               return TST_CondRetParm;
            }

            if (strcmp(pDadoEsperado, SIMBOLO_PARA_NULL) == 0)
            {
               pDadoEsperado = NULL;
            }

            CondRet = GRA_ObterValorCorrente(pGrafo, (void**) &pDadoObtido);


            if (CondRetEsp == TST_CondRetOK)
            {
               CondRet = TST_CompararString(pDadoEsperado, pDadoObtido, "Valor do elemento errado.");
               MEM_Free(pDadoEsperado);
               return CondRet;
            }
            else
            {
               MEM_Free(pDadoEsperado);
               if (pDadoObtido != NULL)
               {
                  return TST_NotificarFalha("Não foi obtido null como conteudo ao ocorrer um erro."); 
               }

               return TST_CompararInt(CondRetEsp, CondRet, "Não ocorreu o erro esperado na obtenção do conteudo.");
            }
         }

       /*Testar alterar valor do vértice corrente */

         else if (strcmp(ComandoTeste, ALTER_VALOR_CMD) == 0)
         {
            char *pNovoValor = AlocarEspacoParaNome();
            char *pAntigoValor;

            numLidos = LER_LerParametros("si", pNovoValor, &CondRetEsp);

            if (numLidos != 2)
            {
               return TST_CondRetParm;
            }
            
            GRA_ObterValorCorrente(pGrafo, (void**) &pAntigoValor);
            MEM_Free(pAntigoValor);

            CondRet = GRA_AlterarValorCorrente(pGrafo, pNovoValor);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao alterar o valor.");
         }


       /*Testar tornar corrente uma origem */

         else if (strcmp(ComandoTeste, TORNAR_ORIGEM_CMD) == 0)
         {
            numLidos = LER_LerParametros("i", &CondRetEsp);

            if (numLidos != 1)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_TornarCorrenteUmaOrigem(pGrafo);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao tornar o corrente uma origem.");
         }


       /*Testar tornar corrente uma origem */

         else if (strcmp(ComandoTeste, DEIXAR_ORIGEM_CMD) == 0)
         {
            numLidos = LER_LerParametros("i", &CondRetEsp);

            if (numLidos != 1)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_DeixarDeSerOrigem(pGrafo);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro remover uma origem.");
         }


        /*Testar seguir pela aresta */

       else if (strcmp(ComandoTeste, IR_ARESTA_CMD) == 0)
         {
            char *nomeDaAresta = AlocarEspacoParaNome();

            numLidos = LER_LerParametros("si", nomeDaAresta, &CondRetEsp);

            if (numLidos != 2)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_SeguirPelaAresta(pGrafo, nomeDaAresta);

            MEM_Free(nomeDaAresta);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao ir para vértice adjacente.");
         }

       /*Testar ir vertice adjacente */

       else if (strcmp(ComandoTeste, IR_VERTICE_CMD) == 0)
         {
            char *nomeVertice = AlocarEspacoParaNome();

            numLidos = LER_LerParametros("si", nomeVertice, &CondRetEsp);

            if (numLidos != 2)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_IrParaVerticeAdjacente(pGrafo, nomeVertice);

            MEM_Free(nomeVertice);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao ir para vértice adjacente.");
         }

        /*Testar ir para origem */

       else if (strcmp(ComandoTeste, IR_ORIGEM_CMD) == 0)
         {
            char *nomeVertice = AlocarEspacoParaNome();

            numLidos = LER_LerParametros("si", nomeVertice, &CondRetEsp);

            if (numLidos != 2)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_IrParaAOrigem(pGrafo, nomeVertice);

            MEM_Free(nomeVertice);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao ir para origem.");
         }

         /*Testar ir destruir aresta adjacente */

       else if (strcmp(ComandoTeste, DESTRUIR_ARESTA_CMD) == 0)
         {
            char *nomeAresta = AlocarEspacoParaNome();

            numLidos = LER_LerParametros("si", nomeAresta, &CondRetEsp);

            if (numLidos != 2)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_DestruirArestaAdjacente(pGrafo, nomeAresta);

            MEM_Free(nomeAresta);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao destruir aresta adjacente.");
         }

          /*Testar ir destruir aresta adjacente */

       else if (strcmp(ComandoTeste, DESTRUIR_VERT_CMD) == 0)
         {
            numLidos = LER_LerParametros("i", &CondRetEsp);

            if (numLidos != 1)
            {
               return TST_CondRetParm;
            }

            CondRet = GRA_DestruirVerticeCorrente(pGrafo);

            return TST_CompararInt(CondRetEsp, CondRet, "Ocorreu um erro ao destruir vertice corrente.");
         }

        /* Finalizar o teste */

       else if (strcmp(ComandoTeste, FIM_CMD) == 0)
         {
            MEM_LiberarTodaMemoriaAlocada();

            return TST_CondRetOK;
         }

      return TST_CondRetNaoConhec;

   }
Beispiel #8
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {

      int inxLista  = -1 ,
          numLidos   = -1 ,
          CondRetEsp = -1  ;

      TST_tpCondRet CondRet ;

	  int CondRetObtido = LIS_CondRetOK;
	  int det, falhasEsperadas, falhasObtidas;

      char   StringDado[  DIM_VALOR ] ;
      char * pDado ;

      int ValEsp = -1 ;

      int i,num ;

      int numElem = -1 ;

      StringDado[ 0 ] = 0 ;

      /* Efetuar reset de teste de lista */

         if ( strcmp( ComandoTeste , RESET_LISTA_CMD ) == 0 )
         {

            for( i = 0 ; i < DIM_VT_LISTA ; i++ )
            {
               vtListas[ i ] = NULL ;
            } /* for */

            return TST_CondRetOK ;

         } /* fim ativa: Efetuar reset de teste de lista */

      /* Testar CriarLista */

         else if ( strcmp( ComandoTeste , CRIAR_LISTA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                       &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            vtListas[ inxLista ] =
                 LIS_CriarLista( DestruirValor ) ;

            return TST_CompararPonteiroNulo( 1 , vtListas[ inxLista ] ,
               "Erro em ponteiro de nova lista."  ) ;

         } /* fim ativa: Testar CriarLista */

      /* Testar Esvaziar lista lista */

         else if ( strcmp( ComandoTeste , ESVAZIAR_LISTA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            LIS_EsvaziarLista( vtListas[ inxLista ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Esvaziar lista lista */

      /* Testar Destruir lista */

         else if ( strcmp( ComandoTeste , DESTRUIR_LISTA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            LIS_DestruirLista( vtListas[ inxLista ] ) ;
            vtListas[ inxLista ] = NULL ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Destruir lista */

      /* Testar inserir elemento antes */

         else if ( strcmp( ComandoTeste , INS_ELEM_ANTES_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isi" ,
                       &inxLista , StringDado , &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado = ( char * ) malloc( strlen( StringDado ) + 1 ) ;
            if ( pDado == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */

            strcpy( pDado , StringDado ) ;


            CondRet = LIS_InserirElementoAntes( vtListas[ inxLista ] , pDado ) ;

            if ( CondRet != LIS_CondRetOK )
            {
               free( pDado ) ;
            } /* if */

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno errada ao inserir antes."                   ) ;

         } /* fim ativa: Testar inserir elemento antes */

      /* Testar inserir elemento apos */

         else if ( strcmp( ComandoTeste , INS_ELEM_APOS_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isi" ,
                       &inxLista , StringDado , &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado = ( char * ) malloc( strlen( StringDado ) + 1 ) ;
            if ( pDado == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */

            strcpy( pDado , StringDado ) ;


            CondRet = LIS_InserirElementoApos( vtListas[ inxLista ] , pDado ) ;

            if ( CondRet != LIS_CondRetOK )
            {
               free( pDado ) ;
            } /* if */

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno errada ao inserir apos."                   ) ;

         } /* fim ativa: Testar inserir elemento apos */

      /* Testar excluir simbolo */

         else if ( strcmp( ComandoTeste , EXC_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                  &inxLista , &CondRetEsp ) ;

            if ( ( numLidos != 2 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp ,
                      LIS_ExcluirElemento( vtListas[ inxLista ] ) ,
                     "Condição de retorno errada ao excluir."   ) ;

         } /* fim ativa: Testar excluir simbolo */

      /* Testar obter valor do elemento corrente */

         else if ( strcmp( ComandoTeste , OBTER_VALOR_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isi" ,
                       &inxLista , StringDado , &ValEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado = ( char * ) LIS_ObterValor( vtListas[ inxLista ] ) ;

            if ( ValEsp == 0 )
            {
               return TST_CompararPonteiroNulo( 0 , pDado ,
                         "Valor não deveria existir." ) ;
            } /* if */

            if ( pDado == NULL )
            {
               return TST_CompararPonteiroNulo( 1 , pDado ,
                         "Dado tipo um deveria existir." ) ;
            } /* if */

            return TST_CompararString( StringDado , pDado ,
                         "Valor do elemento errado." ) ;

         } /* fim ativa: Testar obter valor do elemento corrente */

      /* Testar ir para o elemento inicial */

         else if ( strcmp( ComandoTeste , IR_INICIO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" , &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            IrInicioLista( vtListas[ inxLista ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar ir para o elemento inicial */

      /* LIS  &Ir para o elemento final */

         else if ( strcmp( ComandoTeste , IR_FIM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" , &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            IrFinalLista( vtListas[ inxLista ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: LIS  &Ir para o elemento final */

      /* LIS  &Avançar elemento */

         else if ( strcmp( ComandoTeste , AVANCAR_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" , &inxLista , &numElem ,
                                &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp , LIS_AvancarElementoCorrente( vtListas[ inxLista ] , numElem ) ,
                      "Condicao de retorno errada ao avancar" ) ;

         } /* fim ativa: LIS  &Avançar elemento */
		 /* LIS &Testar Obter Tamanho Lista */
		 else if (strcmp ( ComandoTeste , OBTER_TAMANHO_CMD ) == 0 )
		 {
			 numLidos = LER_LerParametros( "iii" ,&inxLista,&ValEsp, &CondRetEsp ) ;

			if ( ( numLidos != 3 )||( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

			CondRetObtido = LIS_ObterTamanho( vtListas[ inxLista ], &num );

			CondRet = TST_CompararInt( ValEsp , num ,"Valor do elemento errado, diferente do esperado" ) ;

			if ( CondRet != TST_CondRetOK )
               return CondRet ;

						return TST_CondRetOK;
		 }  /* Fim testar Obter Tamanho */
#ifdef _DEBUG
		 /* Testar Deturpar */
		 else if (strcmp ( ComandoTeste , DETURPA_CMD ) == 0 )
		 {
			 numLidos = LER_LerParametros( "ii" ,&inxLista, &det) ;

			if ( numLidos != 2 )
            {
               return TST_CondRetParm ;
            } /* if */

			DeturpaLista(vtListas[ inxLista ], det);

			return TST_CondRetOK;
		 }
		 else if (strcmp ( ComandoTeste , VERIFICA_CMD ) == 0 )
		 {
			 numLidos = LER_LerParametros( "ii" ,&inxLista, &falhasEsperadas) ;

			if ( numLidos != 2 )
            {
               return TST_CondRetParm ;
            } /* if */

			verificaLista(vtListas[ inxLista ], &falhasObtidas);

			CondRet = TST_CompararInt( falhasEsperadas , falhasObtidas ,"Numero de falhas esperadas diferente de obtida" ) ;
			if ( CondRet != TST_CondRetOK )
               return CondRet ;

			return TST_CondRetOK;
		 }
#endif
		 return TST_CondRetNaoConhec ;

   } /* Fim função: TLIS &Testar lista */
Beispiel #9
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {
	   GRA_tppGrafo epGrafo=NULL;


      int inxGrafo  = -1 ,
          numLidos   = -1 ,
          CondRetEsp = -1  ;

      TST_tpCondRet CondRet ;

      char   StringDado[  DIM_VALOR ] ;
      char * pDado ;

      int ValEsp = -1 ;

      int i ;
	  int j;
      int numElem = -1 ;

      StringDado[ 0 ] = 0 ;

      /* Efetuar reset de teste de grafo */

         if ( strcmp( ComandoTeste , RESET_GRAFO_CMD ) == 0 )
         {

            for( i = 0 ; i < DIM_VT_GRAFO ; i++ )
            {
               VTGRAFO[ i ] = NULL ;
            } /* for */

            return TST_CondRetOK ;

         } /* fim ativa: Efetuar reset de teste de grafo */

      /* Testar CriarGrafo */

         else if ( strcmp( ComandoTeste , CRIAR_GRAFO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                       &inxGrafo ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxGrafo( inxGrafo , VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */


                 GRA_CriarGrafo(&VTGRAFO[ inxGrafo ]) ;
				 //epgrafo retornado por ref

            return TST_CompararPonteiroNulo( 1 , VTGRAFO[ inxGrafo ] ,
               "Erro em ponteiro de nova grafo."  ) ;

         } /* fim ativa: Testar CriarGrafo */

      /* Testar Esvaziar grafo grafo */

         else if ( strcmp( ComandoTeste , ESVAZIAR_GRAFO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxGrafo ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            GRA_EsvaziarGrafo( &VTGRAFO[ inxGrafo ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Esvaziar grafo grafo */

      /* Testar Destruir grafo */

         else if ( strcmp( ComandoTeste , DESTRUIR_GRAFO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxGrafo ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            GRA_DestruirGrafo( &VTGRAFO[ inxGrafo ] ) ;
            VTGRAFO[ inxGrafo ] = NULL ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Destruir grafo */

      /* Testar inserir elemento antes */

         else if ( strcmp( ComandoTeste , INSERIR_NO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iiii" ,
                       &inxGrafo , &i,&j , &CondRetEsp ) ;

            if ( ( numLidos != 4 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

           
            if ( pDado == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */

            strcpy( pDado , StringDado ) ;


            CondRet =(TST_tpCondRet) GRA_InserirAresta( &VTGRAFO[ inxGrafo ] , i,j,0,0 ) ;

            if ( CondRet != GRA_CondRetOK )
            {
               free( pDado ) ;
            } /* if */

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno errada ao inserir antes."                   ) ;

         } /* fim ativa: Testar inserir elemento antes */

      /* Testar inserir elemento apos */

         else if ( strcmp( ComandoTeste , INS_ELEM_APOS_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isi" ,
                       &inxGrafo , StringDado , &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado = ( char * ) malloc( strlen( StringDado ) + 1 ) ;
            if ( pDado == NULL )
            {
               return TST_CondRetMemoria ;
            } /* if */

            strcpy( pDado , StringDado ) ;


            CondRet = GRA_InserirElementoApos( VTGRAFO[ inxGrafo ] , pDado ) ;

            if ( CondRet != GRA_CondRetOK )
            {
               free( pDado ) ;
            } /* if */

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno errada ao inserir apos."                   ) ;

         } /* fim ativa: Testar inserir elemento apos */

      /* Testar excluir simbolo */

         else if ( strcmp( ComandoTeste , EXC_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                  &inxGrafo , &CondRetEsp ) ;

            if ( ( numLidos != 2 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp ,
                      GRA_ExcluirElemento( VTGRAFO[ inxGrafo ] ) ,
                     "Condi��o de retorno errada ao excluir."   ) ;

         } /* fim ativa: Testar excluir simbolo */

      /* Testar obter valor do elemento corrente */

         else if ( strcmp( ComandoTeste , OBTER_VALOR_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "isi" ,
                       &inxGrafo , StringDado , &ValEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            pDado = ( char * ) GRA_ObterValor( VTGRAFO[ inxGrafo ] ) ;

            if ( ValEsp == 0 )
            {
               return TST_CompararPonteiroNulo( 0 , pDado ,
                         "Valor n�o deveria existir." ) ;
            } /* if */

            if ( pDado == NULL )
            {
               return TST_CompararPonteiroNulo( 1 , pDado ,
                         "Dado tipo um deveria existir." ) ;
            } /* if */

            return TST_CompararString( StringDado , pDado ,
                         "Valor do elemento errado." ) ;

         } /* fim ativa: Testar obter valor do elemento corrente */

      /* Testar ir para o elemento inicial */

         else if ( strcmp( ComandoTeste , IR_INICIO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" , &inxGrafo ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            GRA_IrInicioGrafo( VTGRAFO[ inxGrafo ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar ir para o elemento inicial */

      /* GRA  &Ir para o elemento final */

         else if ( strcmp( ComandoTeste , IR_FIM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" , &inxGrafo ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            GRA_IrFinalGrafo( VTGRAFO[ inxGrafo ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: GRA  &Ir para o elemento final */

      /* GRA  &Avan�ar elemento */

         else if ( strcmp( ComandoTeste , AVANCAR_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" , &inxGrafo , &numElem ,
                                &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxGrafo( inxGrafo , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp ,
                      GRA_AvancarElementoCorrente( VTGRAFO[ inxGrafo ] , numElem ) ,
                      "Condicao de retorno errada ao avancar" ) ;

         } /* fim ativa: GRA  &Avan�ar elemento */

      return TST_CondRetNaoConhec ;

   } /* Fim fun��o: TGRA &Testar grafo */
Beispiel #10
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {

      int numLidos = -1;
	  int valorCarta;
	  int naipeCarta;

	  BAR_tpCarta* carta;
	  BAR_tpCarta cartaNaoP;

	  int CondRetEsp = -1  ;
	  int ValEsp = -1 ;
	  TST_tpCondRet CondRet ;


      /* Testar criar baralho*/

		 if ( strcmp( ComandoTeste , CriarBaralho ) == 0 )
         {
			 baralho = BAR_CriarBaralho();
			 return TST_CompararPonteiroNulo( 1 , baralho ,
               "Erro em ponteiro de novo baralho."  ) ;

         } /* fim ativa: Testar criar baralho */

		/* Testar setar baralho*/

         else if ( strcmp( ComandoTeste , TestarSetarBaralho ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &CondRetEsp ) ;

            if (  numLidos != 1 )
            {
               return TST_CondRetParm ;
            } /* if */

			CondRet = BAR_SetarBaralho(baralho);

			return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno ao setar baralho"                   ) ;


         } /* fim ativa: Testar setar baralho */

      /* Testar setar baralho de truco */

         else if ( strcmp( ComandoTeste , TestarSetarBaralhoTruco ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &CondRetEsp ) ;

            if (  numLidos != 1 )
            {
               return TST_CondRetParm ;
            } /* if */

			CondRet = BAR_SetarBaralhoTruco(baralho);

			return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno ao setar baralho de truco"                   ) ;

         } /* fim ativa: Testar setar baralho truco */

		 /* Testar comparar compra */

         else if ( strcmp( ComandoTeste , CompararCompra ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                               &naipeCarta, &valorCarta ) ;

            if (  numLidos != 2 || naipeCarta > 3 || naipeCarta < 0 || valorCarta < 0 || valorCarta > 13 )
            {
               return TST_CondRetParm ;
            } /* if */

			carta = BAR_PedirCarta(baralho);

			if(carta->naipe != naipeCarta || carta->valor != valorCarta)
			{
				return TST_CondRetErro;
			}

			else return TST_CondRetOK;

         } /* fim ativa: Testar comparar compra */


		 /* Testar comprar carta */

         else if ( strcmp( ComandoTeste , TestarCompra ) == 0 )
         {

			numLidos = LER_LerParametros( "i" ,
                       &ValEsp ) ;

            if ( numLidos != 1 )
            {
               return TST_CondRetParm ;
            } /* if */

			carta = BAR_PedirCarta(baralho);
			
			if((carta != NULL) && carta->valor != BAR_Coringa)
			{		
				fprintf( TST_ObterArqLog( ) , "Naipe: %d Valor: %d \n", carta->naipe, carta->valor) ;
				return TST_CondRetOK;
			}
			else if	(carta != NULL)
			{
				fprintf( TST_ObterArqLog( ) , "Naipe: Coringa Valor: %d \n", carta->valor);
				return TST_CondRetOK;
			}
			else return TST_CondRetErro;


         } /* fim ativa: Testar compra */

		 
		 /* Testar devolução de cartas*/

         else if ( strcmp( ComandoTeste , TestarDevolucao ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" ,
					&naipeCarta, &valorCarta, &CondRetEsp ) ;

            if (  numLidos != 3 || naipeCarta > 3 || naipeCarta < 0 || valorCarta < 0 || valorCarta > 13 )
            {
               return TST_CondRetParm ;
            } /* if */

			carta = (BAR_tpCarta*) malloc(sizeof(BAR_tpCarta));

			
			if(carta == NULL)
			{
				return TST_CondRetMemoria;
			}

			carta->naipe =  naipeCarta;
			carta->valor =  valorCarta;

			


			CondRet = BAR_DevolverCarta(baralho, carta);

			return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno ao setar baralho de truco"                   ) ;


         } /* fim ativa: Testar destruir */


		 else if ( strcmp( ComandoTeste , TestarDestruir ) == 0 )
         {

           BAR_DestruirBaralho(baralho);
		   return TST_CondRetOK;



         } /* fim ativa: Testar destruir */

		 

      return TST_CondRetNaoConhec ;


   } /* Fim função: TBAR &Efetuar o teste do módulo baralho */
TST_tpCondRet TST_EfetuarComando( char *ComandoTeste )
{

    int inxTab  = -1 ,
        numLidos   = -1 ;

    short int tamColuna = -1 ,
              tamLinha  = -1 ,
              Coluna    = -1 ,
              Linha     = -1 ,
              ColunaDest = -1,
              LinhaDest  = -1;

    PECA_tpCor cor;

    TAB_tpTamanho tam;
    TAB_tpPosicao pos,
                  posOrigem,
                  posDestino;
    TAB_tpCondRet condEsp;
    TAB_tpCondRet tabCondRet;

    PECA_tppPeca pDado ;
    int valEsp = -1 ;

#ifdef _DEBUG
    TAB_tpModoDeturpacao modoDeturpacao;
#endif

    int i ;

    /* Efetuar reset de teste de tabuleiro */

    if ( strcmp( ComandoTeste , RESETAR_TABULEIRO_CMD ) == 0 )
    {

        for ( i = 0 ; i < DIM_VT_TABULEIRO ; i++ )
        {
            vtTab[ i ] = NULL ;
        } /* for */

        return TST_CondRetOK ;

    } /* fim ativa: Efetuar reset de teste de tabuleiro */

    /* Testar Criar Tabuleiro */

    else if ( strcmp( ComandoTeste , CRIAR_TABULEIRO_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iiii" ,
                                      &inxTab, &tamColuna, &tamLinha, &valEsp ) ;

        if ( ( numLidos != 4 )
                || ( ! ValidarInxTabuleiro( inxTab )))
        {
            return TST_CondRetParm ;
        }

        vtTab[ inxTab ] =
            TAB_CriarTabuleiro( tamColuna, tamLinha, DestruirPeca ) ;

        return TST_CompararPonteiroNulo( 1 , vtTab[ inxTab ] ,
                                         "Erro em ponteiro de nova tabuleiro."  ) ;

    } /* fim ativa: Testar CriarTabuleiro */

    /* Testar Destruir Tabuleiro  */

    else if ( strcmp( ComandoTeste , DESTRUIR_TABULEIRO_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "i" ,
                                      &inxTab ) ;

        if ( ( numLidos != 1 )
                || ( ! ValidarInxTabuleiro( inxTab )))
        {
            return TST_CondRetParm ;
        }

        TAB_DestruirTabuleiro( vtTab[ inxTab ] ) ;
        vtTab[ inxTab ] = NULL;

        return TST_CondRetOK ;

    } /* fim ativa: Testar Destruir Tabuleiro*/

    /* Testar Obter Tamanho */

    else if ( strcmp( ComandoTeste , OBTER_TAMANHO_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iii" ,
                                      &inxTab, &tamColuna, &tamLinha ) ;

        if ( ( numLidos != 3 )
                || ( ! ValidarInxTabuleiro( inxTab )))
        {
            return TST_CondRetParm ;
        }

        tam = TAB_ObterTamanho( vtTab[ inxTab ] ) ;
        if ((tam.colunas == tamColuna) && (tam.linhas == tamLinha))
            return TST_CondRetOK ;
        return TST_CondRetErro;

    } /* fim ativa: Testar Obter Tamanho */

    /* Testar Incluir Peca */
    else if ( strcmp( ComandoTeste , INCLUIR_PECA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iiiii" ,
                                      &inxTab , &Coluna, &Linha, &cor , &condEsp ) ;

        if ( ( numLidos != 5 )
                || ( ! ValidarInxTabuleiro( inxTab )) )
        {
            return TST_CondRetParm ;
        }

        pDado = (PECA_tppPeca) PECA_CriarPeca (cor) ;
        if ( pDado == NULL )
        {
            return TST_CondRetMemoria ;
        }

        pos.coluna = Coluna;
        pos.linha = Linha;
        tabCondRet = TAB_IncluirPeca( vtTab[ inxTab ] , pDado , pos) ;

        if ( tabCondRet != TAB_CondRetOK )
        {
            PECA_DestruirPeca(pDado) ;
        }

        return TST_CompararInt( condEsp , tabCondRet ,
                                "Condicao de retorno errada ao incluir peca no tabuleiro." ) ;

    } /* fim ativa: Testar Incluir Peca*/
    /* Testar Mover Peça*/
    else if ( strcmp( ComandoTeste , MOVER_PECA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iiiiii" ,
                                      &inxTab , &Coluna, &Linha, &ColunaDest , &LinhaDest, &condEsp ) ;

        if ( ( numLidos != 6 )
                || ( ! ValidarInxTabuleiro( inxTab )) )
        {
            return TST_CondRetParm ;
        }


        posOrigem.coluna = Coluna;
        posOrigem.linha = Linha;
        posDestino.coluna = ColunaDest;
        posDestino.linha = LinhaDest;
        tabCondRet = TAB_MoverPeca( vtTab[ inxTab ] , posOrigem , posDestino) ;


        return TST_CompararInt( condEsp , tabCondRet ,
                                "Condicao de retorno errada ao mover a peca no tabuleiro." ) ;

    } /* fim ativa: Testar Mover Peca*/
    /* Testar Obter Peca */
    else if ( strcmp( ComandoTeste , OBTER_PECA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iiii" ,
                                      &inxTab , &Coluna, &Linha, &valEsp ) ;

        if ( ( numLidos != 4  )
                || ( ! ValidarInxTabuleiro( inxTab )) )
        {
            return TST_CondRetParm ;
        }

        pos.coluna = Coluna;
        pos.linha = Linha;
        pDado = (PECA_tppPeca) TAB_ObterPeca( vtTab[ inxTab ] , pos) ;

        if ( valEsp == 0 )
        {
            return TST_CompararPonteiroNulo( 0, pDado,
                                             "Peça não devia existir");
        }

        if ( pDado == NULL)
        {
            return TST_CompararPonteiroNulo( 1, pDado,
                                             "Peça deveria existir");
        }
        return TST_CondRetOK;

    } /* fim ativa: Testar Obter Peca*/
    /* Testar Destruir Peca */
    else if ( strcmp( ComandoTeste , DESTRUIR_PECA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iiii" ,
                                      &inxTab , &Coluna, &Linha, &condEsp ) ;

        if ( ( numLidos != 4 )
                || ( ! ValidarInxTabuleiro( inxTab )) )
        {
            return TST_CondRetParm ;
        }

        pos.coluna = Coluna;
        pos.linha = Linha;
        tabCondRet = TAB_DestruirPeca( vtTab[ inxTab ] , pos) ;

        return TST_CompararInt( condEsp , tabCondRet ,
                                "Condicao de retorno errada ao excluir peca do tabuleiro." ) ;

    } /* fim ativa: Testar Destruir Peca*/
    /* Testar Remover Peca */
    else if ( strcmp( ComandoTeste , REMOVER_PECA_CMD ) == 0 )
    {

        numLidos = LER_LerParametros( "iiii" ,
                                      &inxTab , &Coluna, &Linha, &valEsp ) ;

        if ( ( numLidos != 4  )
                || ( ! ValidarInxTabuleiro( inxTab )) )
        {
            return TST_CondRetParm ;
        }

        pos.coluna = Coluna;
        pos.linha = Linha;
        pDado = (PECA_tppPeca) TAB_RemoverPeca( vtTab[ inxTab ] , pos) ;

        if ( valEsp == 0 )
        {
            return TST_CompararPonteiroNulo( 0, pDado, "Peça não devia existir");
        }

        if ( pDado == NULL )
        {
            return TST_CompararPonteiroNulo( 1, pDado, "Peça deveria existir");
        }
        return TST_CondRetOK;

    } /* fim ativa: Testar Remover Peca*/

    /* Início instrumentação */
    #ifdef _DEBUG
    /* Testar verificador de tabuleiro */
    else if ( strcmp( ComandoTeste, VERIFICAR_TABULEIRO_CMD ) == 0 )
    {
        numLidos = LER_LerParametros( "ii",
                                      &inxTab, &condEsp ) ;
        if ( ( numLidos != 2 )
            || !ValidarInxTabuleiro( inxTab ))
        {
            return TST_CondRetParm;
        }

        return TST_CompararInt( condEsp ,
                                TAB_VerificarTabuleiro( vtTab[ inxTab ] ) ,
                                "Retorno incorreto ao verificar tabuleiro") ;
    } /* fim ativa: Testar verificador de tabuleiro */
    /* Deturpar um tabuleiro */
    else if ( strcmp( ComandoTeste, DETURPAR_CMD ) == 0 )
    {
        numLidos = LER_LerParametros( "ii" ,
                                       &inxTab , &modoDeturpacao ) ;
        if ( ( numLidos != 2 )
             || !ValidarInxTabuleiro( inxTab ))
        {
            return TST_CondRetParm;
        }

        TAB_Deturpar( vtTab [ inxTab ] , modoDeturpacao ) ;

        return TST_CondRetOK ;
    } /* fim ativa: Deturpar um tabuleiro */
    /* Verificar vazamento de memória */
    else if ( strcmp( ComandoTeste, VERIFICAR_MEMORIA_CMD ) == 0 )
    {
        CED_ExibirTodosEspacos( CED_ExibirTodos ) ;

        return TST_CondRetOK ;
    } /* fim ativa: Verificar vazamento de memória */
    #endif
    /* Fim instrumentação */

    return TST_CondRetNaoConhec ;

} /* Fim função: TTAB &Testar tabuleiro */
Beispiel #12
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {

      int  numLidos = -1, 
           indexMat = -1,
           dimMatriz = -1,
           CondRetEsperada = -1,
           direcao = -1 ;

	  char stringDada [ DIM_STR ] = {0};
	  char *stringObtida;

      LIS_tppLista listaAuxiliar ;     

      TST_tpCondRet CondRetObtido ;

      /* Testar MAT Criar Matriz */

         if ( strcmp( ComandoTeste , CRIAR_MAT_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" ,
                               &indexMat, &dimMatriz, &CondRetEsperada ) ;
            if ( numLidos != 3 )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRetObtido = MAT_CriarMatriz( &(vtMatrizes[ indexMat ]), dimMatriz ) ;

            return TST_CompararInt( CondRetEsperada , CondRetObtido ,
                     "Condicao de retorno errada ao criar matriz." ) ;

         } /* fim ativa: Testar MAT Criar Matriz */

      /* Testar MAT andar na matriz */

         else if ( strcmp( ComandoTeste , ANDAR_DIR_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" ,
                               &indexMat, &direcao , &CondRetEsperada ) ;
            if ( numLidos != 3 )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRetObtido = MAT_AndarCorrente( vtMatrizes[indexMat], (MAT_tpDirecao) direcao ) ;

            return TST_CompararInt( CondRetEsperada , CondRetObtido ,
                                    "Retorno errado ao percorrer a matriz." );

         } /* fim ativa: Testar MAT andar na matriz */

      /* Testar MAT atribuir lista a célula corrente */

         else if ( strcmp( ComandoTeste , ATRIBUIR_LIS_CMD ) == 0 )
         {
            numLidos = LER_LerParametros( "isi" ,
                              &indexMat, stringDada, &CondRetEsperada ) ;
            if ( numLidos != 3 )
            {
               return TST_CondRetParm ;
            } /* if */
			
			listaAuxiliar = criarListaAPartirDeString(stringDada);

            CondRetObtido = MAT_AtribuirValorCorrente( vtMatrizes[ indexMat ], listaAuxiliar ) ;
			
			return TST_CompararInt( CondRetEsperada , CondRetObtido ,
                                "Retorno errado ao inserir lista no elemento corrente." );
	     } /* fim ativa: Testar MAT atribuir lista a célula corrente */

      /* Testar MAT obter valor da célula corrente */  
         else if ( strcmp( ComandoTeste , OBTER_LIS_CMD ) == 0 )
         {
			int pEsp;
			numLidos = LER_LerParametros( "isii" ,
                              &indexMat, stringDada, &pEsp, &CondRetEsperada ) ;
            if ( numLidos != 4 )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRetObtido = MAT_ObterValorCorrente( vtMatrizes[ indexMat ], &listaAuxiliar ) ;
			
			if( CondRetObtido != CondRetEsperada || CondRetObtido == MAT_CondRetPonteiroNulo ){
				return TST_CompararInt( CondRetEsperada , CondRetObtido ,
                                    "Retorno errado ao obter lista no elemento corrente." );
			}

			if ( pEsp == 0 )
            {
               return TST_CompararPonteiroNulo( 0 , listaAuxiliar ,
                         "Valor não deveria existir." ) ;
            } /* if */

			stringObtida = obterStringAPartirDeLista( listaAuxiliar );

			return TST_CompararString(stringDada, stringObtida, 
									"Representação em string da lista obtida diferente do esperado."); 
         } /* fim ativa: Testar MAT obeter valor da célula corrente */

      /* Testar MAT destruir matriz */  
         else if ( strcmp( ComandoTeste , DESTROI_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                              &indexMat, &CondRetEsperada ) ;
            if ( numLidos != 2 )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRetObtido = MAT_DestruirMatriz( vtMatrizes[ indexMat ] ) ;

            return TST_CompararInt( CondRetEsperada , CondRetObtido ,
                                    "Retorno errado ao destruir matriz" );

         } /* fim ativa: Testar MAT destruir matriz */

      /* Testar MAT esvaziar matriz */  
         else if ( strcmp( ComandoTeste , ESVAZIA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                              &indexMat, &CondRetEsperada ) ;
            if ( numLidos != 2 )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRetObtido = MAT_EsvaziarMatriz( vtMatrizes[ indexMat ] ) ;

            return TST_CompararInt( CondRetEsperada , CondRetObtido ,
                                    "Retorno errado ao esvaziar matriz" );

         } /* fim ativa: MAT esvaziar matriz */

      return TST_CondRetNaoConhec ;

   } /* Fim função: TARV Efetuar operações de teste específicas para árvore */
Beispiel #13
0
   TST_tpCondRet TST_EfetuarComando( char * ComandoTeste )
   {

      int inxLista  = -1 ,
          numLidos   = -1 ,
          CondRetEsp = -1  ;

      TST_tpCondRet CondRet ;

      char   CharDado ;

      int ValEsp = -1 ;

      int i ;

      int numElem = -1 ;

      /* Efetuar reset de teste de lista */

         if ( strcmp( ComandoTeste , RESET_LISTA_CMD ) == 0 )
         {

            for( i = 0 ; i < DIM_VT_LISTA ; i++ )
            {
               vtListas[ i ] = NULL ;
            } /* for */

            return TST_CondRetOK ;

         } /* fim ativa: Efetuar reset de teste de lista */

      /* Testar CriarLista */

         else if ( strcmp( ComandoTeste , CRIAR_LISTA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                       &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            vtListas[ inxLista ] =
                 LIS_CriarLista( ) ;

            return TST_CompararPonteiroNulo( 1 , vtListas[ inxLista ] ,
               "Erro em ponteiro de nova lista."  ) ;

         } /* fim ativa: Testar CriarLista */

      /* Testar Esvaziar lista */

         else if ( strcmp( ComandoTeste , ESVAZIAR_LISTA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            LIS_EsvaziarLista( vtListas[ inxLista ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Esvaziar lista lista */

      /* Testar Destruir lista */

         else if ( strcmp( ComandoTeste , DESTRUIR_LISTA_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" ,
                               &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )))
            {
               return TST_CondRetParm ;
            } /* if */

            LIS_DestruirLista( vtListas[ inxLista ] ) ;
            vtListas[ inxLista ] = NULL ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar Destruir lista */

      /* Testar inserir elemento antes */

         else if ( strcmp( ComandoTeste , INS_ELEM_ANTES_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ici" ,
                       &inxLista , &CharDado , &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRet = LIS_InserirElementoAntes( vtListas[ inxLista ] , CharDado ) ;

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno errada ao inserir antes."                   ) ;

         } /* fim ativa: Testar inserir elemento antes */

      /* Testar inserir elemento apos */

         else if ( strcmp( ComandoTeste , INS_ELEM_APOS_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ici" ,
                       &inxLista , &CharDado , &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            CondRet = LIS_InserirElementoApos( vtListas[ inxLista ] , CharDado ) ;

            return TST_CompararInt( CondRetEsp , CondRet ,
                     "Condicao de retorno errada ao inserir apos."                   ) ;

         } /* fim ativa: Testar inserir elemento apos */

      /* Testar excluir simbolo */

         else if ( strcmp( ComandoTeste , EXC_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                  &inxLista , &CondRetEsp ) ;

            if ( ( numLidos != 2 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp ,
                      LIS_ExcluirElemento( vtListas[ inxLista ] ) ,
                     "Condição de retorno errada ao excluir."   ) ;

         } /* fim ativa: Testar excluir simbolo */

      /* Testar obter valor do elemento corrente */

         else if ( strcmp( ComandoTeste , OBTER_VALOR_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ic" ,
                       &inxLista , &CharDado ) ;

            if ( ( numLidos != 2 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

			return TST_CompararChar( CharDado,
					LIS_ObterValor( vtListas[ inxLista ] ),
					"Valor do elemento corrente está errado." );

         } /* fim ativa: Testar obter valor do elemento corrente */

      /* Testar ir para o elemento inicial */

         else if ( strcmp( ComandoTeste , IR_INICIO_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" , &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            LIS_IrInicioLista( vtListas[ inxLista ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: Testar ir para o elemento inicial */

      /* LIS  &Ir para o elemento final */

         else if ( strcmp( ComandoTeste , IR_FIM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "i" , &inxLista ) ;

            if ( ( numLidos != 1 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            LIS_IrFinalLista( vtListas[ inxLista ] ) ;

            return TST_CondRetOK ;

         } /* fim ativa: LIS  &Ir para o elemento final */

      /* LIS  &Avançar elemento */

         else if ( strcmp( ComandoTeste , AVANCAR_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "iii" , &inxLista , &numElem ,
                                &CondRetEsp ) ;

            if ( ( numLidos != 3 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

            return TST_CompararInt( CondRetEsp ,
                      LIS_AvancarElementoCorrente( vtListas[ inxLista ] , numElem ) ,
                      "Condicao de retorno errada ao avancar" ) ;

         } /* fim ativa: LIS  &Avançar elemento */
		 
      /* Testar obter numero de elementos */

         else if ( strcmp( ComandoTeste , OBTER_NUM_ELEM_CMD ) == 0 )
         {

            numLidos = LER_LerParametros( "ii" ,
                       &inxLista , &ValEsp ) ;

            if ( ( numLidos != 2 )
              || ( ! ValidarInxLista( inxLista , NAO_VAZIO )) )
            {
               return TST_CondRetParm ;
            } /* if */

			return TST_CompararInt( ValEsp,
					LIS_ObterNumElem( vtListas[ inxLista ] ),
					"Numero de elementos da lista esta errado." );

         } /* fim ativa: Testar obter numero de elementos */
     

      return TST_CondRetNaoConhec ;

   } /* Fim função: TLIS &Testar lista */