Example #1
0
void PruebaMemoria::CorrerPruebaConcreta()
{
	if (m_PrimerPasada)
		m_PrimerPasada = false;
	else
	{
		IniciarSeccion("Memoria", ERROR);
		bool memoryLeaks = false;
		for (int i = 0; i < MEMORY_BUCKETS; i++)
		{
			MemoryShare::MemoryUsage* start = MemoryShare::s_GeneralUse[i];
			MemoryShare::MemoryUsage* end = MemoryShare::s_FirstCheck[i];
			memoryLeaks |= start != end;
			while (start != end)
			{
				if (!EsCadena(start))
				{
					Cadena tipo = NombrarTipo(start);
					Verificar(ERROR, OK, m_Comentario.DarFormato(tipo, Nro2Cadena(start->Contador)));
				}
				start = start->NextUsage;
			}
		}
		if (!memoryLeaks)
			Verificar(OK, OK, "Los Punteros y Arrays usados se liberaron correctamente");
		CerrarSeccion();
	}
	for (int i = 0; i < MEMORY_BUCKETS; i++)
		MemoryShare::s_FirstCheck[i] = MemoryShare::s_GeneralUse[i];
}
//=========================FUNÇÃO PRINCIPAL===================================
int main(){

    system("title Controle De Estoque 2011");
    system("color 0f");

    int op,z,d,i,k;
    char resp,c;

    TipoItem item;
    TipoLista Lista;
    ApontadorNo Arvore_cod;

    IniciarLista(&Lista);
    Inicializa(&Arvore_cod);

    i=0;

    do{
        menu();
		scanf("%d",&op);
		system("cls");
		 if(op==1){
            do{
                printf("\t\tGERENCIAMENTO DE ESTOQUE\n\n\tINCLUSAO DE NOVO CADASTRO\n\n");
                fflush(stdin);
                printf("Digite o codigo do produto: ");
                scanf("%d",&item.cod);
                printf("\nDigite o nome do produto: ");
                fflush(stdin);
                gets(&item.nome[i]);
                printf("\nDigite o valor: ");
                fflush(stdin);
                scanf("%f",&item.valor);
                printf("\nDigite o fabricante: ");
                fflush(stdin);
                gets(&item.fabri[i]);
                printf("\nDigite a quantidade: ");
                fflush(stdin);
                scanf("%d",&item.quantidade);
                InserirCelula(&Lista,item);
                printf("\n\tDeseja digita novamente? (S/N).:");
                fflush(stdin);
                Insere(item,&Arvore_cod);
                scanf("%c",&resp);
                system("cls");
            }while(resp=='s');
            system("cls");
        }

        if(op==2){
            printf("\t\t\tESTOQUE\n");
            ImprimeLista(Lista);
            system("pause");
            system("cls");
        }

        if(op==3){
            if(TesteListaVazia(Lista)){
                ImprimeLista(Lista);
                system("pause");
                system("cls");
            }
            else{
                ImprimeLista(Lista);
                do{
                    printf("\n\tQual deseja remover.:");
                    scanf("%d",&k);
                    if(Verificar(k,Lista)==1){
                        fflush(stdin);
                        RetiraL(k,&Lista,&item);
                        fflush(stdin);
                        Retira(item, &Arvore_cod);
                        fflush(stdin);
                        printf("\n\tDeseja Remover novamente? (S/N).:");
                        fflush(stdin);
                        scanf("%c",&resp);
                    }
                }while(resp=='s');
                system("pause");
                system("cls");
            }
        }
        if(op==4){
            if(TesteListaVazia(Lista)){
                ImprimeLista(Lista);
                system("pause");
                system("cls");
            }
            else{
                printf("\t\tOrdenado por valor\n");
                d=Tamanho(Lista);
                QuickSortLista(&Lista,d);
                ImprimeLista(Lista);
                system("pause");
                system("cls");
            }
        }

        if(op==5){
            if(TesteListaVazia(Lista)){
                ImprimeLista(Lista);
                system("pause");
                system("cls");
            }
            else{
                printf("\n\n\n Digite o codigo que deseja encontrar: ");
                scanf("%d", &item.cod);
                fflush(stdin);
                Pesquisa(&item, &Arvore_cod, item.quantidade);
                printf("\n");
                system("pause");
            }
            system("cls");

        }

        if(op==6){

        }

        if(op==7){

        }

        if(op==8){

        }

        if(op==9){

        }

        if(op<1||op>10){
            system("color 4f");
            printf("\tOpcao Invalida\n");
            system("pause");
            system("cls");
            system("color 0f");
        }

         else if(op==10){
            exit(1);
        }

    }while(op>0||op<10);
}