semestre_2/Algoritmos e Estruturas de .../EP 2/usaFilaPreferencial.c

128 lines
4.2 KiB
C

#include "filapreferencial.c"
int main() {
PFILA f = criarFila();
int id;
bool ehPreferencial;
bool res;
printf("################# INSERINDO #######################\n");
exibirLog(f);
res = inserirPessoaNaFila(f, -1, false);
if(res) printf("Insercao retornou true (0).\n");
else printf("Insercao retornou false (0). [OK]\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 1, false);
if(res) printf("Insercao retornou true (1). [OK]\n");
else printf("Insercao retornou false (1).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 2, false);
if(res) printf("Insercao retornou true (2). [OK]\n");
else printf("Insercao retornou false (2).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 3, false);
if(res) printf("Insercao retornou true (3). [OK]\n");
else printf("Insercao retornou false (3).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 4, true);
if(res) printf("Insercao retornou true (4). [OK]\n");
else printf("Insercao retornou false (4).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 5, true);
if(res) printf("Insercao retornou true (5). [OK]\n");
else printf("Insercao retornou false (5).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 6, true);
if(res) printf("Insercao retornou true (6). [OK]\n");
else printf("Insercao retornou false (6).\n");
exibirLog(f);
printf("################# ATENDENDO #######################\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (7), id=%i. [OK]\n",id);
else printf("Atendimento retornou false (7).\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (8), id=%i. [OK]\n",id);
else printf("Atendimento retornou false (8).\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (9), id=%i. [OK]\n",id);
else printf("Atendimento retornou false (9).\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (10), id=%i. [OK]\n",id);
else printf("Atendimento retornou false (10).\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (11), id=%i. [OK]\n",id);
else printf("Atendimento retornou false (11).\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (12), id=%i. [OK]\n",id);
else printf("Atendimento retornou false (12).\n");
exibirLog(f);
res = atenderPrimeiraDaFila(f, &id);
if(res) printf("Atendimento retornou true (13), id=%i.\n",id);
else printf("Atendimento retornou false (13). [OK]\n");
exibirLog(f);
printf("################# INSERINDO PARTE 2 ###############\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 7, true);
if(res) printf("Insercao retornou true (14). [OK]\n");
else printf("Insercao retornou false (14).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 8, false);
if(res) printf("Insercao retornou true (15). [OK]\n");
else printf("Insercao retornou false (15).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 9, true);
if(res) printf("Insercao retornou true (16). [OK]\n");
else printf("Insercao retornou false (16).\n");
exibirLog(f);
res = inserirPessoaNaFila(f, 10, false);
if(res) printf("Insercao retornou true (17). [OK]\n");
else printf("Insercao retornou false (17).\n");
exibirLog(f);
printf("################# SAINDO DA FILA ##################\n");
exibirLog(f);
res = desistirDaFila(f, 6);
if(res) printf("Desistindo da fila retornou true (18).\n");
else printf("Desistindo da fila retornou false (18). [OK]\n");
exibirLog(f);
res = desistirDaFila(f, 7);
if(res) printf("Desistindo da fila retornou true (19). [OK]\n");
else printf("Desistindo da fila retornou false (19).\n");
exibirLog(f);
res = desistirDaFila(f, 8);
if(res) printf("Desistindo da fila retornou true (20). [OK]\n");
else printf("Desistindo da fila retornou false (20).\n");
exibirLog(f);
res = desistirDaFila(f, 9);
if(res) printf("Desistindo da fila retornou true (21). [OK]\n");
else printf("Desistindo da fila retornou false (21).\n");
exibirLog(f);
res = desistirDaFila(f, 10);
if(res) printf("Desistindo da fila retornou true (22). [OK]\n");
else printf("Desistindo da fila retornou false (22).\n");
exibirLog(f);
return 0;
}