TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { PIL_tpCondRet CondRetObtido = PIL_CondRetOK ; PIL_tpCondRet CondRetEsperada = PIL_CondRetFaltouMemoria ; /* inicializa para qualquer coisa */ char NaipeEsperado = '?' ; char NaipeObtido = '!' ; char NaipeDado = '\0' ; int ValorEsperado = -1 ; int ValorObtido = -2 ; int ValorDado = 0 ; int PosicaoPilha = -1 ; int NumPilha = -1 ; int NumLidos = -1 ; CAR_tppCarta CartaObtida ; CAR_tppCarta CartaDada ; TST_tpCondRet Ret ; /* Testar PIL Criar Pilha de Cartas */ if ( strcmp( ComandoTeste , CRIAR_PIL_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &NumPilha , &CondRetEsperada ) ; if ( NumLidos != 2 || NumPilha >= MAX_PILS || NumPilha < 0 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = PIL_CriarPilhaVazia( &vPilhas[NumPilha] ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao criar pilha." ); } /* fim ativa: Testar PIL Criar Pilha de cartas*/ /* Testar PIL Push Carta na pilha */ else if ( strcmp( ComandoTeste , PUSH_CMD ) == 0 ) { NumLidos = LER_LerParametros( "icii" , &NumPilha, &NaipeDado , &ValorDado, &CondRetEsperada ) ; if ( NumLidos != 4 || NumPilha >= MAX_PILS || NumPilha < 0 ) { return TST_CondRetParm ; } /* if */ CAR_CriarCarta( &CartaDada ) ; CAR_PreencheCarta( CartaDada, NaipeDado , ValorDado ); CondRetObtido = PIL_PushCarta( vPilhas[NumPilha] , CartaDada ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao operar 'push' na pilha" ); } /* fim ativa: Testar PIL Push Carta na pilha */ /* Testar PIL Pop Carta da Pilha */ else if ( strcmp( ComandoTeste , POP_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &NumPilha , &CondRetEsperada ) ; if ( NumLidos != 2 || NumPilha >= MAX_PILS || NumPilha < 0 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = PIL_PopCarta( vPilhas[NumPilha] , &CartaObtida ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao operar 'pop' na pilha") ; } /* Testar PIL Ver Carta da Pilha */ else if ( strcmp( ComandoTeste , VER_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &NumPilha , &PosicaoPilha , &CondRetEsperada ) ; if ( NumLidos != 3 || NumPilha >= MAX_PILS || NumPilha < 0 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = PIL_VerCarta( vPilhas[NumPilha] , &CartaObtida , PosicaoPilha ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao ver carta da pilha") ; } /* Testar PIL Ver Carta da Pilha */ /* Testar PIL Destruir pilha de cartas */ else if ( strcmp( ComandoTeste , DESTROI_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &NumPilha , &CondRetEsperada ) ; if ( NumLidos != 2 || NumPilha >= MAX_PILS || NumPilha < 0 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = PIL_DestruirPilha( vPilhas[NumPilha] ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado destruir pilha." ); } /* fim ativa: Testar PIL Destruir Pilha de Cartas */ /* Testar PIL Destruir Pilha */ return TST_CondRetNaoConhec ; } /* Fim função: TPIL Efetuar operações de teste específicas para pilha de cartas */
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 */
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { int indice, numLidos = -1, CondRetEsp = -1, indicePeca, casa, passos, quantidadePecasEsp, quantidadePecas; void *valorPeca; int * pecaRecebida; int * vtPeca[10]; TST_tpCondRet Ret; for (indice = 0; indice < 10; indice++){ vtPeca[indice] = (int*)malloc(sizeof(int)); if (vtPeca == NULL) { return TST_CondRetMemoria; } /* if */ *vtPeca[indice] = indice; } /* for */ TAB_tpCondRet CondRet ; /* testar criar um tabuleiro */ if ( strcmp( ComandoTeste , CRIAR_TABULEIRO_CMD ) == 0 ) { numLidos = LER_LerParametros( "i" , &CondRetEsp) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRet = TAB_CriarTabuleiro(&pTabuleiro); return TST_CompararInt( CondRetEsp , CondRet , "Condicao de retorno errada ao criar tabuleiro."); } /* Fim ativa: Testar criar um tabuleiro */ /* Testar destruir um tabuleiro */ else if ( strcmp( ComandoTeste , DESTRUIR_TABULEIRO_CMD ) == 0 ) { numLidos = LER_LerParametros( "i" , &CondRetEsp) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRet = TAB_DestruirTabuleiro(&pTabuleiro); return TST_CompararInt( CondRetEsp , CondRet , "Condicao de retorno errada ao destruir tabuleiro."); } /* Fim ativa: Testar destruir tabuleiro */ /* Testar inserir peca */ else if (strcmp(ComandoTeste, INSERIR_PECA_CMD) == 0) { numLidos = LER_LerParametros("iii", &indicePeca, &casa, &CondRetEsp); if (numLidos != 3) { return TST_CondRetParm; } /* if */ CondRet = TAB_InserirPeca(&pTabuleiro, vtPeca[indicePeca], casa); if (CondRet != TAB_CondRetOK) free(vtPeca[indicePeca]); return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao inserir peca."); } /* Fim ativa: Testar inserir peca */ /* Testar retirar peca */ else if (strcmp(ComandoTeste, RETIRAR_PECA_CMD) == 0) { numLidos = LER_LerParametros("iii", &indicePeca, &casa, &CondRetEsp); if (numLidos != 3) { return TST_CondRetParm; } /* if */ CondRet = TAB_RetirarPeca(&pTabuleiro, &valorPeca, casa); Ret = TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao retirar peca."); if (Ret != TST_CondRetOK) return Ret; pecaRecebida = (int *)valorPeca; Ret = TST_CompararInt(*vtPeca[indicePeca], *pecaRecebida, "peca recebida errada"); free(pecaRecebida); return Ret; } /* Fim ativa: Testar retirar peca */ /* Testar mover peca */ else if (strcmp(ComandoTeste, MOVER_PECA_CMD) == 0) { numLidos = LER_LerParametros("iii", &casa, &passos, &CondRetEsp); if (numLidos != 3) { return TST_CondRetParm; } /* if */ CondRet = TAB_MoverPeca(&pTabuleiro, casa, passos); return TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao mover peca."); } /* Fim ativa: Testar mover peca */ /* Testar quantidade peca */ else if (strcmp(ComandoTeste, QUANTIDADE_PECA_CMD) == 0) { numLidos = LER_LerParametros("iii", &casa, &quantidadePecasEsp, &CondRetEsp); if (numLidos != 3) { return TST_CondRetParm; } /* if */ CondRet =TAB_QuantidadePecasCasa(pTabuleiro, casa, &quantidadePecas); Ret = TST_CompararInt(CondRetEsp, CondRet, "Condicao de retorno errada ao contar peca."); if (Ret != TST_CondRetOK) return Ret; return TST_CompararInt(quantidadePecasEsp, quantidadePecas, "numero de pecas errado"); } /* Fim ativa: Testar quantidade peca */ /* Liberar espaco alocado teste */ else if (strcmp(ComandoTeste, LIBERAR_CMD) == 0) { for (indice = 0; indice < 10; indice++) free(vtPeca[indice]); return TST_CondRetOK; } /* Fim ativa: Liberar espaco alocado teste */ return TST_CondRetNaoConhec ; } /* Fim função: TTAB &Testar tabuleiro */
TST_tpCondRet TST_EfetuarComando(char *ComandoTeste) { int numLidos = -1, CondRetEsp = -1; TST_tpCondRet CondRet; PAS_tppPasso PASSOS[3][MAX_PASSOS]; int PASSOS_SIZE[3]; PAS_CriarPasso(&PASSOS[0][0], NORTE, 2); PASSOS_SIZE[0] = 1; PAS_CriarPasso(&PASSOS[1][0], SUL, 2); PAS_CriarPasso(&PASSOS[1][1], ESTE, 5); PASSOS_SIZE[1] = 2; PAS_CriarPasso(&PASSOS[2][0], OESTE, 2); PAS_CriarPasso(&PASSOS[2][1], NOROESTE, 1); PAS_CriarPasso(&PASSOS[2][2], ESTE, 0); PASSOS_SIZE[2] = 3; /*Testar Ler tipo de movimento*/ if (strcmp (ComandoTeste, LER_TIPO_MOVIMENTO_CMD) == 0) { char *tipoStr; int tipoEsperado; MPEC_tpTipoMovimento tipoObtido; MEM_Alloc(sizeof(tipoStr)*MAX_TIPO_STR, (void **) &tipoStr); numLidos = LER_LerParametros("sii", tipoStr, &tipoEsperado, &CondRetEsp); if (numLidos != 3) { return TST_CondRetParm; } CondRet = ISP_LerTipoMovimento(tipoStr, &tipoObtido); if(CondRet == ISP_CondRetOK) { TST_CompararInt(tipoEsperado, (int) tipoObtido, "Não foi obtido o tipo esperado."); } return CondRet; } /*Testar Ler passos*/ if (strcmp(ComandoTeste, LER_PASSOS_CMD) == 0) { char *passosStr; int iPassosEsperado; LIS_tppLista pPassosEsperado; LIS_tppLista pPassosObtido; MEM_Alloc(sizeof(passosStr)*MAX_PASSOS_STR, (void **) &passosStr); numLidos = LER_LerParametros("sii", passosStr, &iPassosEsperado, &CondRetEsp); if (numLidos != 3) { return TST_CondRetParm; } pPassosEsperado = CriarListaPassos(PASSOS[iPassosEsperado], PASSOS_SIZE[iPassosEsperado]); CondRet = ISP_LerPassos(passosStr, &pPassosObtido); if (CondRet == ISP_CondRetOK) { if (!ListaDePassosSaoIguais(pPassosEsperado, pPassosObtido)) { TST_NotificarFalha("A lista de passos obtida não é igual à esperada"); return TST_CondRetErro; } } return CondRet; } /* Finalizar o teste */ else if (strcmp(ComandoTeste, FIM_CMD) == 0) { MEM_LiberarTodaMemoriaAlocada(); return TST_CondRetOK; } return TST_CondRetNaoConhec; }
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { int numLidos ; int valorCarta; int naipeCarta; tagCarta* carta; /* Testar Inicializar modulo baralho */ if ( strcmp( ComandoTeste , TestarInicializarCmd ) == 0 ) { BAR_Inicializar() ; baralho = BAR_CriarBaralho(); return TST_CondRetOK ; } /* fim ativa: Testar Inicializar modulo baralho */ /* Testar setar baralho*/ else if ( strcmp( ComandoTeste , TestarSetarBaralho ) == 0 ) { if(BAR_SetarBaralho(baralho) == LIS_CondRetOK) return TST_CondRetOK; else return TST_CondRetMemoria; } /* fim ativa: Testar setar baralho */ /* Testar setar baralho de truco */ else if ( strcmp( ComandoTeste , TestarSetarBaralhoTruco ) == 0 ) { if(BAR_SetarBaralhoTruco(baralho) == LIS_CondRetOK) return TST_CondRetOK; else return TST_CondRetMemoria; } /* fim ativa: Testar setar baralho truco */ /* Testar comprar carta */ else if ( strcmp( ComandoTeste , TestarCompra ) == 0 ) { carta = BAR_PedirCarta(baralho); if(carta == NULL) return TST_CondRetErro; else { if(carta->naipe != NULL) fprintf( TST_ObterArqLog( ) , "Naipe: %d Valor: %d \n", carta->naipe, carta->valor) ; else fprintf( TST_ObterArqLog( ) , "Naipe: Joker Valor: %d \n", carta->valor) ; } return TST_CondRetOK; } /* fim ativa: Testar compra */ /* Testar devolução de cartas*/ else if ( strcmp( ComandoTeste , TestarDevolucao ) == 0 ) { numLidos = LER_LerParametros( "ii" , &naipeCarta, &valorCarta ) ; if ( numLidos != 2 ) { return TST_CondRetParm ; } /* if */ carta = (tagCarta*) malloc(sizeof(tagCarta)); carta->naipe = naipeCarta; valor->carta = valorCarta; if(BAR_DevolverCarta(baralho, carta) == LIS_CondRetFaltouMemoria) return TST_CondRetMemoria; else return TST_CondRetOK; } /* 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: TALT &Efetuar o teste de função do módulo aleatorio */
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; }
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 */
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { int inxLista = -1 , numLidos = -1 , CondRetEsp = -1 ; TST_tpCondRet CondRet ; char StringDado[ DIM_VALOR ] ; char * pDado ; 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( ) ; 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 */ return TST_CondRetNaoConhec ; } /* Fim função: TLIS &Testar lista */
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 i ; int numLidos = -1 ; int inxEspaco = -1 ; int valEsperado = -1 ; int valObtido = -1 ; #define DIM_STRING_PARM 100 char StringParm[ DIM_STRING_PARM ] ; int Deslocamento ; int Valor ; int Tamanho ; int numLinhaFonte ; int idTipo ; int numAllocs = -1 , Frequencia = 0 , ContaNULL = 0 ; double Tolerancia , PercentEsperado , PercentObtido ; void * pEspaco = NULL ; InstrumentarString( StringParm , DIM_STRING_PARM ) ; /* Tratar: Reinicializar módulo de teste espeçifico */ if ( strcmp( ComandoTeste , ResetEspacosCmd ) == 0 ) { if ( EhPrimeiraVez ) { EhPrimeiraVez = FALSE ; for( i = 0 ; i < DIM_VT_ESPACO ; i ++ ) { vtEspaco[ i ] = NULL ; } /* for */ return TST_CondRetOK ; } /* if */ for( i = 0 ; i < DIM_VT_ESPACO ; i++ ) { if ( vtEspaco[ i ] != NULL ) { CED_Free( vtEspaco[ i ] ) ; vtEspaco[ i ] = NULL ; } /* if */ } /* for */ return TST_CondRetOK ; } /* fim ativa: Tratar: Reinicializar módulo de teste espeçifico */ /* Tratar: Deturpar espaço */ else if ( strcmp( ComandoTeste , DeturparEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "iii" , &inxEspaco , &Deslocamento , &Valor ) ; if ( ( numLidos != 3 ) || !VerificarInxEspaco( inxEspaco , TRUE )) { return TST_CondRetParm ; } /* if */ (( char * ) vtEspaco[ inxEspaco ] )[ Deslocamento ] = ( char ) Valor ; return TST_CondRetOK ; } /* fim ativa: Tratar: Deturpar espaço */ /* Tratar: Atribuir string ao espaço */ else if ( strcmp( ComandoTeste , InserirStringEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "is" , &inxEspaco , StringParm ) ; if ( ( numLidos != 2 ) || !VerificarInxEspaco( inxEspaco , TRUE ) || !VerificarString( StringParm , DIM_STRING_PARM )) { return TST_CondRetParm ; } /* if */ strcpy( vtEspaco[ inxEspaco ] , StringParm ) ; return TST_CondRetOK ; } /* fim ativa: Tratar: Atribuir string ao espaço */ /* Testar: Obter string contido no espaço */ else if ( strcmp( ComandoTeste , ObterStringEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "is" , &inxEspaco , StringParm ) ; if ( ( numLidos != 2 ) || !VerificarInxEspaco( inxEspaco , TRUE ) || !VerificarString( StringParm , DIM_STRING_PARM )) { return TST_CondRetParm ; } /* if */ return TST_CompararEspaco( StringParm , vtEspaco[ inxEspaco ] , strlen( StringParm ) , "Conteúdo do valor errado." ) ; } /* fim ativa: Testar: Obter string contido no espaço */ /* Testar: CED &Alocar espaço */ else if ( strcmp( ComandoTeste , AlocarEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "iiis" , &inxEspaco , &Tamanho , &numLinhaFonte , StringParm ) ; if ( ( numLidos != 4 ) || ( Tamanho <= 0 ) || ( numLinhaFonte < 1 ) || !VerificarInxEspaco( inxEspaco , FALSE ) || !VerificarString( StringParm , DIM_STRING_PARM )) { return TST_CondRetParm ; } /* if */ vtEspaco[ inxEspaco ] = CED_Malloc( Tamanho , numLinhaFonte , StringParm ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Alocar espaço */ /* Testar: CED &Desalocar espaço */ else if ( strcmp( ComandoTeste , DesalocarEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &inxEspaco ) ; if ( ( numLidos != 1 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ CED_Free( vtEspaco[ inxEspaco ] ) ; vtEspaco[ inxEspaco ] = NULL ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Desalocar espaço */ /* Testar: CED &Exibir conteúdo bruto do espaço */ else if ( strcmp( ComandoTeste , ExibirEspacoBrutoCmd ) == 0 ) { #define DIM_ESPACO 70 numLidos = LER_LerParametros( "i" , &inxEspaco ) ; if ( ( numLidos != 1 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ TST_ExibirEspacoHexa( DIM_ESPACO + 4 , (( char * ) vtEspaco[ inxEspaco ] ) - DIM_ESPACO ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Exibir conteúdo bruto do espaço */ /* Testar: CED &Exibir conteúdo útil do espaço */ else if ( strcmp( ComandoTeste , ExibirEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &inxEspaco ) ; if ( ( numLidos != 1 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ CED_ExibirEspaco( vtEspaco[ inxEspaco ] ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Exibir conteúdo útil do espaço */ /* Testar: CED &Verificar a integridade de um espaço de dados */ else if ( strcmp( ComandoTeste , VerificarEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxEspaco , &valEsperado ) ; if ( ( numLidos != 2 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ valObtido = CED_VerificarEspaco( vtEspaco[ inxEspaco ] , VerificarValor ) ; return TST_CompararBool( valEsperado , valObtido , "Verificação resultou errado." ) ; } /* fim ativa: Testar: CED &Verificar a integridade de um espaço de dados */ /* Testar: CED &Definir o tipo do espaço */ else if ( strcmp( ComandoTeste , DefinirTipoEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "iii" , &inxEspaco , &idTipo , &valEsperado ) ; if ( ( numLidos != 3 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ valObtido = CED_DefinirTipoEspaco( vtEspaco[ inxEspaco ] , idTipo ); return TST_CompararInt( valEsperado , valObtido , "Condição de retorno errada." ) ; } /* fim ativa: Testar: CED &Definir o tipo do espaço */ /* Testar: CED &Obter o tipo do espaço */ else if ( strcmp( ComandoTeste , ObterTipoEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxEspaco , &valEsperado ) ; if ( ( numLidos != 2 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ valObtido = CED_ObterTipoEspaco( vtEspaco[ inxEspaco ] ) ; return TST_CompararInt( valEsperado , valObtido , "Tipo do espaço errado." ) ; } /* fim ativa: Testar: CED &Obter o tipo do espaço */ /* Testar: CED &Obter tamanho do valor contido no espaço */ else if ( strcmp( ComandoTeste , ObterTamanhoEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxEspaco , &valEsperado ) ; if ( ( numLidos != 2 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ valObtido = CED_ObterTamanhoValor( vtEspaco[ inxEspaco ] ) ; return TST_CompararInt( valEsperado , valObtido , "Tamanho do valor errado." ) ; } /* fim ativa: Testar: CED &Obter tamanho do valor contido no espaço */ /* Testar: CED &Marcar ativo o espaço */ else if ( strcmp( ComandoTeste , MarcarEspacoAtivoCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &inxEspaco ) ; if ( ( numLidos != 1 ) || !VerificarInxEspaco( inxEspaco , TRUE )) { return TST_CondRetParm ; } /* if */ CED_MarcarEspacoAtivo( vtEspaco[ inxEspaco ] ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Marcar ativo o espaço */ /* Testar: CED &Marcar não ativo o espaço */ else if ( strcmp( ComandoTeste , MarcarEspacoNaoAtivoCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &inxEspaco ) ; if ( ( numLidos != 1 ) || !VerificarInxEspaco( inxEspaco , TRUE )) { return TST_CondRetParm ; } /* if */ CED_MarcarEspacoNaoAtivo( vtEspaco[ inxEspaco ] ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Marcar não ativo o espaço */ /* Testar: CED &Marcar não ativos todos os espaços */ else if ( strcmp( ComandoTeste , MarcarTodosNaoAtivosCmd ) == 0 ) { CED_MarcarTodosEspacosInativos( ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Marcar não ativos todos os espaços */ /* Testar: CED &Verificar se espaço é ativo */ else if ( strcmp( ComandoTeste , VerificarEspacoAtivoCmd ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxEspaco , &valEsperado ) ; if ( ( numLidos != 2 ) || !VerificarInxEspaco( inxEspaco , TRUE )) { return TST_CondRetParm ; } /* if */ valObtido = CED_EhEspacoAtivo( vtEspaco[ inxEspaco ] ) ; return TST_CompararInt( valEsperado , valObtido , "Marca de espaço ativo errada." ) ; } /* fim ativa: Testar: CED &Verificar se espaço é ativo */ /* Testar CED &Limitar com freqüência de geração de NULL */ else if ( strcmp( ComandoTeste , VerificarFrequenciaCmd ) == 0 ) { numLidos = LER_LerParametros( "iif" , &numAllocs , &Frequencia , &Tolerancia ) ; if ( ( numLidos != 3 ) || ( numAllocs < 100 )) { return TST_CondRetParm ; } /* if */ valObtido = CED_LimitarFrequencia( Frequencia ) ; if ( !valObtido ) { return TST_NotificarFalha( "Freqüência limite de malloc em erro." ) ; } /* if */ for( i = 0 ; i < numAllocs ; i++ ) { pEspaco = CED_Malloc( 100 , i + 1 , "TesteFrequencia" ) ; if ( pEspaco == NULL ) { ContaNULL ++ ; } else { CED_Free( pEspaco ) ; } /* if */ } /* for */ PercentEsperado = ( 1000. - Frequencia ) / 1000. ; PercentObtido = ContaNULL ; PercentObtido = PercentObtido / numAllocs ; return TST_CompararFloat( PercentEsperado , PercentObtido , Tolerancia , "Número de NULLs gerados está fora da tolerância." ) ; } /* fim ativa: Testar CED &Limitar com freqüência de geração de NULL */ /* Testar: CED &Iterador: iniciar iterador de espaços */ else if ( strcmp( ComandoTeste , IniciarIteradorEspacosCmd ) == 0 ) { CED_InicializarIteradorEspacos( ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Iterador: iniciar iterador de espaços */ /* Testar: CED &Iterador: avançar para o próximo espaço */ else if ( strcmp( ComandoTeste , AvancarProximoEspacoCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &valEsperado ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ valObtido = CED_AvancarProximoEspaco( ) ; return TST_CompararInt( valEsperado , valObtido , "Condição de avanço errada." ) ; } /* fim ativa: Testar: CED &Iterador: avançar para o próximo espaço */ /* Testar: CED &Iterador: obter referência para o espaço corrente */ else if ( strcmp( ComandoTeste , ObterEspacoCorrenteCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &inxEspaco ) ; if ( ( numLidos != 1 ) || !VerificarInxEspaco( inxEspaco , FALSE )) { return TST_CondRetParm ; } /* if */ vtEspaco[ inxEspaco ] = CED_ObterPonteiroEspacoCorrente( ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Iterador: obter referência para o espaço corrente */ /* Testar: CED &Iterador: existe espaço corrente */ else if ( strcmp( ComandoTeste , ExisteEspacoCorrenteCmd ) == 0 ) { numLidos = LER_LerParametros( "i" , &valEsperado ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ valObtido = CED_ExisteEspacoCorrente( ) ; return TST_CompararInt( valEsperado , valObtido , "Condição de existência de iterador errada." ) ; { } /* fim repete: Testar: CED &Iterador: existe espaço corrente */ } /* fim ativa: Testar: CED &Iterador: existe espaço corrente */ /* Testar: CED &Iterador: terminar iterador */ else if ( strcmp( ComandoTeste , TerminarIteradorEspacoCmd ) == 0 ) { CED_TerminarIteradorEspacos( ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Iterador: terminar iterador */ /* Testar: CED &Iterador: excluir espaço corrente */ else if ( strcmp( ComandoTeste , ExcluirEspacoCorrenteCmd ) == 0 ) { CED_ExcluirEspacoCorrente( ) ; return TST_CondRetOK ; } /* fim ativa: Testar: CED &Iterador: excluir espaço corrente */ return TST_CondRetNaoConhec ; } /* Fim função: TCED &Efetuar comando de teste do controle de espaço dinâmico */
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { /* Variáveis para retorno de operações com lista */ /* Devem ser inicializadas com qualquer valor */ LBT_tpCondRet LBT_CondRetObtido = LBT_CondRetOK ; LBT_tpCondRet LBT_CondRetEsperada = LBT_CondRetFaltouMemoria ; int indexFocoLista = '0'; int indexFocoGrafo = '0'; int indexFocoLabirinto = '0'; int afastamentoHorizontal = 0; int afastamentoVertical = 0; int NumLidos = -1 ; int i = 0; int resposta = 0; int quantidade = 0; int numPassos = 0; int real = 0; LBT_tpSentido sentido; char filePath[200]; int vertice = 0; int aresta = 0; char * caracter; char stringDado [2] ; TST_tpCondRet Ret = TST_CondRetOK ; stringDado[1]='\0'; caracter = (char*) malloc ( sizeof(char) ); /* Efetuar reset de teste de labirinto */ if ( strcmp (ComandoTeste, RESET_LBT_CMD) == 0 ) { for ( i = 0; i < DIM_VT_LABIRINTO; i++ ) { vtLabirintos[ i ] = NULL; } return TST_CondRetOK; } /* Fim ativa: Efetuar reset de teste de labirinto */ /* Testar LBT Criar Labirinto */ else if ( strcmp( ComandoTeste, CRIAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_CriarLabirinto( &vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao criar labirinto." ); } /* Fim ativa: Testar LBT Criar Labirinto */ /* Testar LBT Destruir Labirinto */ else if ( strcmp( ComandoTeste, DESTRUIR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_DestruirLabirinto( &vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao destruir labirinto." ); } /* Fim ativa: Testar LBT Destruir Labirinto */ /* Testar LBT Construir Labirinto */ else if ( strcmp( ComandoTeste, CONSTRUIR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &sentido, &LBT_CondRetEsperada ) ; if ( NumLidos != 3 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ConstruirLabirinto( vtLabirintos[ indexFocoLabirinto ], sentido ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao construir labirinto." ); } /* Fim ativa: Testar LBT Construir Labirinto */ /* Testar LBT Desenhar Labirinto */ else if ( strcmp( ComandoTeste, DESENHAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iiii" , &indexFocoLabirinto, &numPassos, &resposta, &LBT_CondRetEsperada ) ; if ( NumLidos != 4 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ printf("\n\n"); LBT_CondRetObtido = LBT_DesenharLabirinto( vtLabirintos[ indexFocoLabirinto ], numPassos, resposta ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao desenhar labirinto." ); } /* Fim ativa: Testar LBT Desenhar Labirinto */ /* Testar LBT Percorrer Labirinto */ else if ( strcmp( ComandoTeste, PERCORRER_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &sentido, &LBT_CondRetEsperada ) ; if ( NumLidos != 3 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_PercorrerLabirinto( vtLabirintos[ indexFocoLabirinto ], sentido ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao percorrer labirinto no sentido." ); } /* Fim ativa: Testar LBT Percorrer Labirinto */ /* Testar LBT Terminar Labirinto */ else if ( strcmp( ComandoTeste, TERMINAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_TerminarLabirinto( vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao marcar posicao corrente como posicao de saída do labirinto." ); } /* Fim ativa: Testar LBT Terminar Labirinto */ /* Testar LBT Iniciar Labirinto */ else if ( strcmp( ComandoTeste, INICIAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_IniciarLabirinto( vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao marcar posicao corrente como posicao de entrada do labirinto." ); } /* Fim ativa: Testar LBT Iniciar Labirinto */ /* Testar LBT Excluir Corrente */ else if ( strcmp( ComandoTeste, EXCLUIR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ExcluirCorrente( vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao excluir posicao corrente do labirinto." ); } /* Fim ativa: Testar LBT Excluir Corrente */ /* Testar LBT Validar Labirinto */ else if ( strcmp( ComandoTeste, VALIDAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ValidarLabirinto( vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao validar labirinto." ); } /* Fim ativa: Testar LBT Validar Labirinto */ /* Testar LBT Salvar Labirinto */ else if ( strcmp( ComandoTeste, SALVAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "isi" , &indexFocoLabirinto, filePath, &LBT_CondRetEsperada ) ; if ( NumLidos != 3 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_SalvarLabirinto( vtLabirintos[ indexFocoLabirinto ], filePath ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao salvar labirinto." ); } /* Fim ativa: Testar LBT Salvar Labirinto */ /* Testar LBT Carregar Labirinto */ else if ( strcmp( ComandoTeste, CARREGAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "isi" , &indexFocoLabirinto, filePath, &LBT_CondRetEsperada ) ; if ( NumLidos != 3 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_CarregarLabirinto( vtLabirintos[ indexFocoLabirinto ], filePath ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao carregar labirinto." ); } /* Fim ativa: Testar LBT Carregar Labirinto */ /* Testar LBT Ir Entrada Labirinto */ else if ( strcmp( ComandoTeste, IR_ENTRADA_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &indexFocoLabirinto, &LBT_CondRetEsperada ) ; if ( NumLidos != 2 || !ValidarIndex ( indexFocoLabirinto, DIM_VT_LABIRINTO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_IrEntradaLabirinto( vtLabirintos[ indexFocoLabirinto ] ); return TST_CompararInt( LBT_CondRetEsperada , LBT_CondRetObtido , "Retorno errado ao ir para a posicao de entrada do labirinto." ); } /* Fim ativa: Testar LBT Ir Entrada Labirinto */ /* Testar LBT Obter Valor Corrente */ else if ( strcmp ( ComandoTeste, OBTER_VALCORR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ici" , &indexFocoLabirinto, caracter, &LBT_CondRetEsperada ); if ( NumLidos != 3 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ObterValorCorrente( vtLabirintos[ indexFocoLabirinto ], (char*)&stringDado[0] ); if( LBT_CondRetObtido == LBT_CondRetOK && LBT_CondRetObtido == LBT_CondRetEsperada ) { return TST_CompararChar( *caracter, stringDado[0], "Valor obtido diferente do valor esperado na posicao corrente do labirinto. " ); } return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, "Retorno errado ao obter valor da posicao corrente do labirinto. " ); } /* fim da ativa: Testar Obter Valor Corrente */ /* Testar LBT Obter Entrada */ else if ( strcmp ( ComandoTeste, OBTER_ENTRADA_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &resposta, &LBT_CondRetEsperada ); if ( NumLidos != 3 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ObterEntrada( vtLabirintos[ indexFocoLabirinto ], &real ); if( LBT_CondRetObtido == LBT_CondRetOK && LBT_CondRetObtido == LBT_CondRetEsperada ) { return TST_CompararInt( resposta, real, "Valor obtido diferente do valor esperado da posicao de entrada do labirinto" ); } return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, " Retorno errado ao obter entrada do labirinto. " ); } /* fim da ativa: Testar LBT Obter Entrada */ /* Testar LBT Obter Saida */ else if ( strcmp ( ComandoTeste, OBTER_SAIDA_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &resposta, &LBT_CondRetEsperada ); if ( NumLidos != 3 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ObterSaida( vtLabirintos[ indexFocoLabirinto ], &real ); if( LBT_CondRetObtido == LBT_CondRetOK && LBT_CondRetObtido == LBT_CondRetEsperada ) { return TST_CompararInt( resposta, real, "Valor obtido diferente do valor esperado da posicao de entrada do labirinto" ); } return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, "Retorno errado ao obter saida do labirinto. " ); } /* fim da ativa: Testar LBT Obter Saida */ /* Testar LBT Obter Posicao Corrente */ else if ( strcmp ( ComandoTeste, OBTER_POSCORR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &resposta, &LBT_CondRetEsperada ); if ( NumLidos != 3 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ObterPosicaoCorrente( vtLabirintos[ indexFocoLabirinto ], &real ); if( LBT_CondRetObtido == LBT_CondRetOK && LBT_CondRetObtido == LBT_CondRetEsperada ) { return TST_CompararInt( resposta, real, "Valor obtido diferente do valor esperado da posicao corrente do labirinto" ); } return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, "Retorno errado ao obter posicao corrente do labirinto. " ); } /* fim da ativa: Testar Obter Posicao Corrente */ /* Testar LBT Obter Solucao */ else if ( strcmp ( ComandoTeste, OBTER_SOLUCAO_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &indexFocoLista, &LBT_CondRetEsperada ); if ( NumLidos != 3 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ObterSolucao( vtLabirintos[ indexFocoLabirinto ], &vtListas [ indexFocoLista ] ); return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, "Retorno errado ao obter lista de solucao do labirinto. " ); } /* fim da ativa: Testar LBT Obter Solucao */ /* Testar LBT Obter afastamento da Entrada à Saída do Labirinto */ else if ( strcmp ( ComandoTeste, OBTERAFASTAMENTO_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iiii" , &indexFocoLabirinto, &resposta, &numPassos, &LBT_CondRetEsperada ); if ( NumLidos != 4 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_ObterAfastamentoEntradaSaida( vtLabirintos[ indexFocoLabirinto ], &real, &quantidade ); if( LBT_CondRetObtido == LBT_CondRetOK && LBT_CondRetObtido == LBT_CondRetEsperada ) { if( TST_CompararInt( resposta, real, "Valor obtido diferente do valor esperado para o afastamento horizontal do labirinto." ) != TST_CondRetErro ) { return TST_CompararInt( numPassos, quantidade, "Valor obtido diferente do valor esperado para o afastamento vertical do labirinto." ); } } return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, "Retorno errado ao obter afastamentos horizontal e vertical do labirinto. " ); } /* fim da ativa: Testar LBT Obter afastamento da Entrada à Saída do Labirinto */ /* Testar LBT Solucionar Labirinto */ else if ( strcmp ( ComandoTeste, SOLUCIONAR_LBT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "iii" , &indexFocoLabirinto, &numPassos, &LBT_CondRetEsperada ); if ( NumLidos != 3 || !ValidarIndex( indexFocoGrafo, DIM_VT_GRAFO ) ) { return TST_CondRetParm ; } /* if */ LBT_CondRetObtido = LBT_SolucionarLabirinto( vtLabirintos[ indexFocoLabirinto ], &numPassos ); return TST_CompararInt( LBT_CondRetEsperada, LBT_CondRetObtido, "Retorno errado ao solucionar labirinto. " ); } /* fim da ativa: Testar LBT Solucionar Labirinto */ return TST_CondRetNaoConhec ; } /* Fim função: TLBT Efetuar operações de teste específicas para labirinto */
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { DES_tpCondRet CondRetObtido; DES_tpCondRet CondRetEsperada; int NumLidos; /* Testar DES Inicia desenho */ if ( strcmp( ComandoTeste , INICIAR_DES_CMD ) == 0 ) { int linhas, colunas; NumLidos = LER_LerParametros( "iii" , &CondRetEsperada, &linhas, &colunas) ; if ( NumLidos != 3 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_IniciaDesenho( linhas, colunas ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao criar desenho." ); } /* fim ativa: Testar DES Iniciar desenho aleatório */ /* Testar DES Inicia desenho */ else if ( strcmp( ComandoTeste , INI_DES_VAZIO_CMD ) == 0 ) { int linhas, colunas; NumLidos = LER_LerParametros( "iii" , &CondRetEsperada, &linhas, &colunas) ; if ( NumLidos != 3 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_IniciaDesenhoVazio( linhas, colunas ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao criar desenho vazio." ); } /* fim ativa: Testar DES Iniciar desenho vazio */ /* Testar DES Inicia desenho projetado */ else if ( strcmp( ComandoTeste , INI_DES_PROJ_CMD ) == 0 ) { char NomeJogo[41]; FILE* ArquivoJogo; NumLidos = LER_LerParametros( "is" , &CondRetEsperada, NomeJogo ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ ArquivoJogo = fopen( NomeJogo, "r" ); CondRetObtido = DES_IniciaDesenhoProjetado( ArquivoJogo ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao criar desenho projetado." ); } /* fim ativa: Testar DES Iniciar desenho projetado */ /* Testar DES Inicia desenho último jogo salvo */ else if ( strcmp( ComandoTeste , INI_DES_ULT_JOGO_CMD ) == 0 ) { NumLidos = LER_LerParametros( "i" , &CondRetEsperada) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_RetomaUltimoJogoSalvo( ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao retomar ultimo jogo salvo." ); } /* fim ativa: Testar DES Iniciar desenho último jogo salvo */ /* Testar DES Destroi desenho */ else if ( strcmp( ComandoTeste , DESTROI_DES_CMD ) == 0 ) { NumLidos = LER_LerParametros( "i" , &CondRetEsperada ) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_DestroiDesenho( ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao destruir desenho." ); } /* fim ativa: Testar DES Destroi desenho */ /* Testar DES Alterar Marcação Coordenada */ else if ( strcmp( ComandoTeste , ALT_MARC_CMD ) == 0 ) { int coordX, coordY; NumLidos = LER_LerParametros( "iii" , &CondRetEsperada, &coordX, &coordY ) ; if ( NumLidos != 3 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_AlteraMarcacaoCoordenada( coordX, coordY ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao alterar marcação." ); } /* fim ativa: Testar DES Alterar Marcação Coordenada */ /* Testar DES Ativar Dica */ else if ( strcmp( ComandoTeste , ATIV_DICA_CMD ) == 0 ) { NumLidos = LER_LerParametros( "i" , &CondRetEsperada ) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_AtivaDica( ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao ativar dica." ); } /* fim ativa: Testar DES Ativar Dica */ /* Testar DES Grava Jogo Atual */ else if ( strcmp( ComandoTeste , GRAVA_JOGO_CMD ) == 0 ) { NumLidos = LER_LerParametros( "i" , &CondRetEsperada ) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_GravaJogoAtual( ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao gravar jogo atual." ); } /* fim ativa: Testar DES Grava Jogo Atual */ /* Testar DES Grava Projeto Matriz */ else if ( strcmp( ComandoTeste , GRAVA_MAT_PROJ_CMD ) == 0 ) { char NomeJogo[41]; NumLidos = LER_LerParametros( "is" , &CondRetEsperada, NomeJogo ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_GravaMatrizProjetada( NomeJogo ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao gravar projeto." ); } /* fim ativa: Testar DES Grava Projeto Matriz */ /* Testar DES Jogo Finalizado */ else if ( strcmp( ComandoTeste , JOGO_FINAL_CMD ) == 0 ) { int FinalEsperado, FinalRecebido; NumLidos = LER_LerParametros( "i" , &FinalEsperado) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ FinalRecebido = DES_DesenhoFinalizado( ) ; return TST_CompararInt( FinalEsperado , FinalRecebido , "Retorno errado ao verificar se o jogo terminou." ); } /* fim ativa: Testar DES Jogo Finalizado */ /* Testar DES Jogo Finalizado */ else if ( strcmp( ComandoTeste , IMPRIME_JOGO_CMD ) == 0 ) { NumLidos = LER_LerParametros( "i" , &CondRetEsperada) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_ImprimeDesenho( ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao verificar se o jogo terminou." ); } /* fim ativa: Testar DES Jogo Finalizado */ #ifdef _DEBUG /* Testar DES Deturpa */ else if ( strcmp( ComandoTeste , DETURPA_CMD ) == 0 ) { int AcaoDeturpadora; NumLidos = LER_LerParametros( "ii" , &CondRetEsperada, &AcaoDeturpadora) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ CondRetObtido = DES_Deturpar( AcaoDeturpadora ) ; return TST_CompararInt( CondRetEsperada , CondRetObtido , "Retorno errado ao verificar se o jogo terminou." ); } /* fim ativa: Testar DES Deturpa */ /* Testar DES Verifica */ else if ( strcmp( ComandoTeste , VERIFICA_CMD ) == 0 ) { int numErrosEsperados; int numErrosOcorridos; NumLidos = LER_LerParametros( "i" , &numErrosEsperados) ; if ( NumLidos != 1 ) { return TST_CondRetParm ; } /* if */ DES_Verifica( &numErrosOcorridos ) ; return TST_CompararInt( numErrosEsperados , numErrosOcorridos , "Contagem de erros errada." ); } /* fim ativa: Testar DES Verifica */ #endif return TST_CondRetNaoConhec ; } /* Fim função: TDES Efetuar operações de teste específicas para desenho */
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 */
TST_tpCondRet ICNT_EfetuarComadoContagem( char * ComandoTeste ) { char NomeArquivo[ DIM_NOME_ARQ ] ; char NomeContador[ DIM_NOME_CONTADOR ] ; int numLidos , IntEsp , IntObtido ; CNT_tpCondRet CondRetEsp , CondRetEh ; /* Tratar CNT &Inicializar contadores */ if ( strcmp( ComandoTeste , INICIALIZAR_CONTADORES_CMD ) == 0 ) { /* CNT_tpCondRet CNT_InicializarContadores( FILE * pArqLog , char * NomeArquivo ) */ CondRetEsp = CNT_CondRetOK ; numLidos = LER_LerParametros( "si" , NomeArquivo , &CondRetEsp ) ; if ( numLidos < 1 ) { CondRetEsp = CNT_CondRetErro ; } /* if */ if ( ( NomeArquivo[ 0 ] == 0 ) || ( numLidos < 1 )) { CondRetEh = CNT_InicializarContadores( NULL ) ; } else { CondRetEh = CNT_InicializarContadores( NomeArquivo ) ; } /* if */ return TST_CompararInt( CondRetEsp , CondRetEh , "Condição de retorno errada." ) ; } /* fim ativa: Tratar CNT &Inicializar contadores */ /* Tratar CNT &Terminar contadores */ else if ( strcmp( ComandoTeste , TERMINAR_CONTADORES_CMD ) == 0 ) { /* CNT_tpCondRet CNT_TerminarContadores( ) */ CondRetEsp = CNT_CondRetOK ; numLidos = LER_LerParametros( "i" , &CondRetEsp ) ; return TST_CompararInt( CondRetEsp , CNT_TerminarContadores( ) , CondRetErrada ) ; } /* fim ativa: Tratar CNT &Terminar contadores */ /* Tratar CNT &Registrar arquivo acumulador */ if ( strcmp( ComandoTeste , REGISTRAR_ACUMULADOR_CMD ) == 0 ) { /* void CNT_RegistrarAcumulador( char * NomeArquivo ) ; */ numLidos = LER_LerParametros( "s" , NomeArquivo ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ if ( NomeArquivo[ 0 ] == 0 ) { CNT_RegistrarAcumulador( NULL ) ; } else { CNT_RegistrarAcumulador( NomeArquivo ) ; } /* if */ return TST_CondRetOK ; } /* fim ativa: Tratar CNT &Registrar arquivo acumulador */ /* Tratar CNT &Ler arquivo de definição de contadores */ else if ( strcmp( ComandoTeste , LER_CONTADORES_CMD ) == 0 ) { /* int CNT_LerContadores( char * NomeArquivoDefinicao ) */ IntEsp = 0 ; numLidos = LER_LerParametros( "si" , NomeArquivo , &IntEsp ) ; if ( ( numLidos < 1 ) || ( IntEsp < 0 )) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsp , CNT_LerContadores( NomeArquivo ) , "Número de erros de leitura errado." ) ; } /* fim ativa: Tratar CNT &Ler arquivo de definição de contadores */ /* Tratar CNT &Gravar arquivo de contagem acumulada */ else if ( strcmp( ComandoTeste , GRAVAR_CONTADORES_CMD ) == 0 ) { /* int CNT_GravarContadores( char * NomeArquivo ) */ IntEsp = 0 ; numLidos = LER_LerParametros( "si" , NomeArquivo , &IntEsp ) ; if ( ( numLidos < 1 ) || ( IntEsp < 0 )) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsp , CNT_GravarContadores( NomeArquivo ) , "Número de erros de gravação errado." ) ; } /* fim ativa: Tratar CNT &Gravar arquivo de contagem acumulada */ /* Tratar CNT &Zerar todos contadores */ else if ( strcmp( ComandoTeste , ZERAR_CONTADORES_CMD ) == 0 ) { /* CNT_tpCondRet CNT_ZerarContadores( ) */ CondRetEsp = CNT_CondRetOK ; numLidos = LER_LerParametros( "i" , &CondRetEsp ) ; return TST_CompararInt( CondRetEsp , CNT_ZerarContadores( ) , CondRetErrada ) ; } /* fim ativa: Tratar CNT &Zerar todos contadores */ /* Tratar CNT &Zerar contador dado */ else if ( strcmp( ComandoTeste , ZERAR_CONTADOR_DADO_CMD ) == 0 ) { /* CNT_tpCondRet CNT_ZerarContador( char * NomeContador ) */ CondRetEsp = CNT_CondRetOK ; numLidos = LER_LerParametros( "si" , NomeContador , &CondRetEsp ) ; if ( numLidos < 1 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( CondRetEsp , CNT_ZerarContador( NomeContador ) , CondRetErrada ) ; } /* fim ativa: Tratar CNT &Zerar contador dado */ /* Tratar CNT &Iniciar a contagem */ else if ( strcmp( ComandoTeste , INICIAR_CONTAGEM_CMD ) == 0 ) { /* void CNT_IniciarContagem( ) */ CNT_IniciarContagem( ) ; return TST_CondRetOK ; } /* fim ativa: Tratar CNT &Iniciar a contagem */ /* Tratar CNT &Parar contagem */ else if ( strcmp( ComandoTeste , PARAR_CONTAGEM_CMD ) == 0 ) { /* void CNT_PararContagem( ) */ CNT_PararContagem( ) ; return TST_CondRetOK ; } /* fim ativa: Tratar CNT &Parar contagem */ /* Tratar CNT &Obter valor de contagem */ else if ( strcmp( ComandoTeste , OBTER_CONTAGEM_CMD ) == 0 ) { /* long CNT_ObterContagem( char * NomeContador ) */ numLidos = LER_LerParametros( "si" , NomeContador , &IntEsp ) ; if ( numLidos != 2 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsp , ( int ) CNT_ObterContagem( NomeContador ) , "Valor de contagem errado." ) ; } /* fim ativa: Tratar CNT &Obter valor de contagem */ /* Tratar Exibir valor de contagem */ else if ( strcmp( ComandoTeste , EXIBIR_CONTAGEM_CMD ) == 0 ) { /* long CNT_ObterContagem( char * NomeContador ) */ numLidos = LER_LerParametros( "s" , NomeContador ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ IntObtido = ( int ) CNT_ObterContagem( NomeContador ) ; if ( IntObtido == CNT_CondRetNaoContador ) { TST_NotificarFalha( "Contador desconhecido: " ) ; fprintf( TST_ObterArqLog( ) , "\"%s\"" , NomeContador ) ; return TST_CondRetErro ; } /* if */ TST_ExibirPrefixo( SINALIZA_COMENTARIO , "" ) ; fprintf( TST_ObterArqLog( ) , "Valor do contador \"%s\" é: %d " , NomeContador , IntObtido ) ; return TST_CondRetOK ; } /* fim ativa: Tratar Exibir valor de contagem */ /* Tratar CNT &Obter número de contadores */ else if ( strcmp( ComandoTeste , OBTER_NUM_CONTADORES_CMD ) == 0 ) { /* int CNT_ObterNumeroContadores( ) */ numLidos = LER_LerParametros( "i" , &IntEsp ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsp , CNT_ObterNumeroContadores( ) , "Número de contadores errado." ) ; } /* fim ativa: Tratar CNT &Obter número de contadores */ /* Tratar CNT &Obter total de contagem */ else if ( strcmp( ComandoTeste , OBTER_TOTAL_CONTAGEM_CMD ) == 0 ) { /* long CNT_ObterContagemTotal( ) */ numLidos = LER_LerParametros( "i" , &IntEsp ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsp , ( int ) CNT_ObterContagemTotal( ) , "Contagem total errada." ) ; } /* fim ativa: Tratar CNT &Obter total de contagem */ /* Tratar CNT &Verificar contagem */ else if ( strcmp( ComandoTeste , VERIFICAR_CONTAGENS_CMD ) == 0 ) { /* int CNT_VerificarContagem( ) */ numLidos = LER_LerParametros( "i" , &IntEsp ) ; if ( numLidos != 1 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsp , CNT_VerificarContagem( ) , "Número de contadores zero errado." ) ; } /* fim ativa: Tratar CNT &Verificar contagem */ return TST_CondRetNaoExecutou ; } /* Fim função: ICNT &Interpretar comandos de contagem */
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { int NumLidos = -1 ; int IntEsperado, IntObtido ; char CharEsperado, CharObtido ; long LongEsperado, LongObtido ; double FloatEsperado , FloatObtido , Tolerancia ; char StringEsperado[ 250 ] , StringObtido[ 250 ] ; char EspacEsperado[ 100 ] ; char EspacObtido[ 100 ] ; /* Testar Booleano */ if ( strcmp( ComandoTeste , BOOL_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &IntEsperado , &IntObtido ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ return TST_CompararBool( IntEsperado , IntObtido , "Booleanos não são iguais." ) ; } /* fim ativa: Testar Booleano */ /* Testar caractere */ else if ( strcmp( ComandoTeste , CHAR_CMD ) == 0 ) { NumLidos = LER_LerParametros( "cc" , &CharEsperado , &CharObtido ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ return TST_CompararChar( CharEsperado , CharObtido , "Caracteres não são iguais." ) ; } /* fim ativa: Testar caractere */ /* Testar inteiro normal */ else if ( strcmp( ComandoTeste , INT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &IntEsperado , &IntObtido ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( IntEsperado , IntObtido , "Inteiros não são iguais." ) ; } /* fim ativa: Testar inteiro normal */ /* Testar inteiro longo */ else if ( strcmp( ComandoTeste , LONG_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ii" , &LongEsperado , &LongObtido ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( LongEsperado , LongObtido , "Inteiros longos não são iguais." ) ; } /* fim ativa: Testar inteiro longo */ /* Testar flutuante */ else if ( strcmp( ComandoTeste , FLOAT_CMD ) == 0 ) { NumLidos = LER_LerParametros( "fff" , &FloatEsperado , &FloatObtido , &Tolerancia ) ; if ( NumLidos != 3 ) { return TST_CondRetParm ; } /* if */ return TST_CompararFloat( FloatEsperado , FloatObtido , Tolerancia , "Flutuantes fora da tolerância." ) ; } /* fim ativa: Testar flutuante */ /* Testar string */ else if ( strcmp( ComandoTeste , STRING_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ss" , StringEsperado , StringObtido ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ return TST_CompararString( StringEsperado , StringObtido , "Strings não são iguais." ) ; } /* fim ativa: Testar string */ /* Testar acesso a espaços */ else if ( strcmp( ComandoTeste , ESPAC_CMD ) == 0 ) { NumLidos = LER_LerParametros( "ss" , EspacEsperado , EspacObtido ) ; if ( NumLidos != 2 ) { return TST_CondRetParm ; } /* if */ if ( EspacEsperado[ 0 ] == '.' ) /* gera string vazio */ { EspacEsperado[ 0 ] = 0 ; } /* if */ if ( EspacObtido[ 0 ] == '.' ) /* gera string com algum lixo */ { memcpy( EspacObtido , &NumLidos , 20 ) ; /* força espaco errado contendo resíduo da pilha */ } /* if */ return TST_CompararEspaco( EspacEsperado , EspacObtido , strlen( EspacEsperado ) , "Espaços não são iguais." ) ; } /* fim ativa: Testar acesso a espaços */ return TST_CondRetNaoConhec ; } /* Fim função: TGEN &Testar módulo TesteGen */
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) { PILHA_tpCondRet CondRetRecebida; PILHA_tpCondRet CondRetEsperada; CAR_tpCarta CartaDada; CAR_tpCarta CartaObtida; int acao; int nElem; int NumLidos = -1; int PosicaoPilha = -1; int numeroPilha = -1; char FaceEsperada = 'V'; char FaceObtida = 'E'; char FaceDada; char NaipeEsperado = 'A'; char NaipeObtido = 'E'; char NaipeDado = 'O'; char PosicaoEsperada = '1'; char PosicaoObtida = '2'; char PosicaoDada = '4'; int numAlocAnt = CED_ObterNumeroEspacosAlocados(); /* Testar PILHA criarPilha */ if (strcmp(ComandoTeste, CRIAR_PILHA_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_criarPilha(&nPilhas[numeroPilha]); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao criar a Pilha."); } /* fim ativa: Testar PILHA criarPilha */ /* Testar PILHA liberaPilha */ else if (strcmp(ComandoTeste, LIBERA_PILHA_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_liberaPilha(nPilhas[numeroPilha]); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao destruir a Pilha"); } /* fim ativa: Testar PILHA liberaPilha */ /* Testar PILHA num elem */ else if (strcmp(ComandoTeste, RETORNA_NUM_ELEM_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_retornaNumElem(nPilhas[numeroPilha], &nElem); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao saber a quantidade de cartas da Pilha"); } /* Testar PILHA pushPilha */ else if (strcmp(ComandoTeste, PUSH_PILHA_CMD) == 0) { char naipe; char posicao; char face; NumLidos = LER_LerParametros("iccci", &numeroPilha, &FaceDada, &NaipeDado, &PosicaoDada, &CondRetEsperada); if (NumLidos != 5 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CAR_criarCarta(&CartaDada); CAR_editarCarta(CartaDada, FaceDada, NaipeDado, PosicaoDada); CondRetRecebida = PILHA_pushPilha(nPilhas[numeroPilha], CartaDada); //(CAR_tpCarta)LIS_ObterValor(nPilhas[numeroPilha], &CartaDada); CAR_retornaFace(CartaDada, &face); CAR_retornaNaipe(CartaDada, &naipe); CAR_retornaPosicao(CartaDada, &posicao); printf("Carta Push: %c %c %c", face, naipe, posicao); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao push a Pilha."); } /* fim ativa: Testar PILHA pushPilha */ /* Testar PILHA popPilha */ else if (strcmp(ComandoTeste, POP_PILHA_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_popPilha(nPilhas[numeroPilha], &CartaObtida); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao pop a pilha."); } /* fim ativa: Testar PILHA popPilha */ /* Testar PILHA verificaPilhaVazia */ else if (strcmp(ComandoTeste, VERIFICA_PILHA_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_verificaPilhaVazia(nPilhas[numeroPilha]); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao verificar a Pilha"); } /* fim ativa: Testar PILHA verificaPilhaVazia */ /* Testar PILHA imprimePilha */ else if (strcmp(ComandoTeste, IMPRIME_PILHA_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_imprimePilha(nPilhas[numeroPilha]); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao imprimir a Pilha"); } /* fim ativa: Testar PILHA imprimePilha */ #ifdef _DEBUG else if (strcmp(ComandoTeste, DETURPAR_CMD) == 0) { NumLidos = LER_LerParametros("iii", &numeroPilha, &acao, &CondRetEsperada); if (NumLidos != 3 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ if (acao == 1){ numAlocAnt = CED_ObterNumeroEspacosAlocados(); } CondRetRecebida = PILHA_deturpaPilha(nPilhas[numeroPilha], acao, &numAlocAnt); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao Deturpar a Pilha"); } /* fim ativa: Testar PILHA DeturpaPilha */ #endif #ifdef _DEBUG else if (strcmp(ComandoTeste, VER_PILHA_CMD) == 0) { NumLidos = LER_LerParametros("ii", &numeroPilha, &CondRetEsperada); if (NumLidos != 2 || numeroPilha >= 10 || numeroPilha < 0){ return TST_CondRetParm; } /* if */ CondRetRecebida = PILHA_verificaNo(nPilhas[numeroPilha], numAlocAnt); return TST_CompararInt(CondRetEsperada, CondRetRecebida, "Erro ao Verificar a Pilha"); } /* fim ativa: Testar PILHA VerificaPilha */ #endif return TST_CondRetNaoConhec; } /* Fim função: TESTPILHA Efetuar operações de teste específicas para cartas */
TST_tpCondRet TST_EfetuarComando( char * ComandoTeste ) { int inxPilha = -1 , inxDado = -1, numLidos = -1 , CondRetEsp = -1 ; PIL_tpCondRet CondRet ; char StringDado [ DIM_VALOR ] ; char vetDado[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'} ; char teste = '\0' ; int ValEsp = -1 ; int i ; int numElem = -1 ; void *EndObtido = NULL; void *EndEsperado = NULL; StringDado[ 0 ] = 0 ; /* Efetuar reset de teste de pilha */ if ( strcmp( ComandoTeste , RESET_PILHA_CMD ) == 0 ) { for( i = 0 ; i < DIM_VT_PILHA ; i++ ) { vtPilhas[ i ] = NULL ; } /* for */ return TST_CondRetOK ; } /* fim ativa: Efetuar reset de teste de pilha */ /* Testar CriarPilha */ else if ( strcmp( ComandoTeste , CRIAR_PILHA_CMD ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxPilha, &CondRetEsp ) ; if ( ( numLidos != 2 ) || ( ! ValidarInxPilha( inxPilha , VAZIO ))) { return TST_CondRetParm ; } /* if */ CondRet = PIL_CriarPilha( &vtPilhas[ inxPilha ] ) ; return TST_CompararInt( CondRetEsp , CondRet , "Erro ao criar pilha." ) ; } /* fim ativa: Testar CriarPilha */ /* Testar Esvaziar pilha */ else if ( strcmp( ComandoTeste , ESVAZIAR_PILHA_CMD ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxPilha, &CondRetEsp ) ; if ( ( numLidos != 2 ) || ( ! ValidarInxPilha( inxPilha , NAO_VAZIO ))) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( CondRetEsp, PIL_EsvaziarPilha( vtPilhas[ inxPilha ] ), "Retorno inesperado." ); } /* fim ativa: Testar Esvaziar pilha */ /* Testar Destruir pilha */ else if ( strcmp( ComandoTeste , DESTRUIR_PILHA_CMD ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxPilha, &CondRetEsp ) ; if ( ( numLidos != 2 ) || ( ! ValidarInxPilha( inxPilha , NAO_VAZIO ))) { return TST_CondRetParm ; } /* if */ CondRet = PIL_DestruirPilha( vtPilhas[ inxPilha ] ) ; vtPilhas[ inxPilha ] = NULL ; return TST_CompararInt( CondRetEsp , CondRet , "Retorno inesperado." ) ; } /* fim ativa: Testar Destruir pilha */ /* Testar inserir elemento */ else if ( strcmp( ComandoTeste , EMPILHAR_CMD ) == 0 ) { numLidos = LER_LerParametros( "iii" , &inxPilha , &inxDado , &CondRetEsp ) ; if ( ( numLidos != 3 ) || ( ! ValidarInxPilha( inxPilha , NAO_VAZIO )) ) { return TST_CondRetParm ; } /* if */ CondRet = PIL_Empilha( vtPilhas[ inxPilha ], &vetDado[inxDado]); return TST_CompararInt( CondRetEsp , CondRet , "Condicao de retorno errada ao inserir antes." ) ; } /* fim ativa: Testar inserir elemento */ /* Testar excluir elemento */ else if ( strcmp( ComandoTeste , DESEMPILHAR_CMD ) == 0 ) { numLidos = LER_LerParametros( "ii" , &inxPilha , &CondRetEsp ) ; if ( ( numLidos != 2 ) || ( ! ValidarInxPilha( inxPilha , NAO_VAZIO )) ) { return TST_CondRetParm ; } /* if */ return TST_CompararInt( CondRetEsp , PIL_Desempilha( vtPilhas[ inxPilha ] ) , "Condição de retorno errada ao excluir." ) ; } /* fim ativa: Testar excluir elemento */ /* Testar obter valor do elemento corrente */ else if ( strcmp( ComandoTeste , OBTER_VALOR_CMD ) == 0 ) { numLidos = LER_LerParametros( "iici" , &inxPilha , &inxDado , &teste , &ValEsp ) ; if ( numLidos != 4 ) { return TST_CondRetParm ; } /* if */ CondRet = PIL_ObterValor( vtPilhas[ inxPilha ], &EndObtido ); if ( CondRet != PIL_CondRetOK ) { return TST_CompararInt( ValEsp , CondRet , "Erro ao obter endereço do elemento." ) ; } /* if */ EndEsperado = &vetDado[inxDado]; if ( EndEsperado != EndObtido ) { return TST_CompararPonteiro( EndEsperado, EndObtido, "Endereço obtido errado." ); } /*if*/ return TST_CompararChar( teste , *(char*)EndObtido , "Valor do elemento errado." ) ; } /* fim ativa: Testar obter valor do elemento corrente */ return TST_CondRetNaoConhec ; } /* Fim função: TPIL &Testar pilha */
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 */