int main(void) { /* CODE FOR TESTING "sameDate" */ /* --------------------------- */ date_t a, b; a.day=17; a.month=12; a.year = 2014; b.day=17; b.month=12; b.year=2013; printf("----------------------------------------------------------------------------\n"); printf("sameDate(a,b) returns %d (should be 0) when called with initial vals for a,b.\n", sameDate(a,b)); b.year=2014; printf("sameDate(a,b) returns %d (should be 1) when called with second vals of a,b.\n", sameDate(a,b)); b.day=16; printf("sameDate(a,b) returns %d (should be 0) when called with third vals of a,b.\n", sameDate(a,b)); /* END OF CODE FOR TESTING "sameDate" */ /* ---------------------------------- */ if (initialiseDB("flightList.txt")) { printf("--------------------------\n"); printf("Initialisation successful.\n"); } /* CODE FOR TESTING "cheapestDirectFlight" */ /* --------------------------------------- */ int t1 = cheapestDirectFlight("DUB", "EDI", a); printf("-------------------------------------------------------\n"); printf("Test1 of cheapestDirectFlight returns %d, should be -1.\n",t1); t1 = cheapestDirectFlight("EDI", "DUB", b); printf("Test2 of cheapestDirectFlight returns %d, should be 3.\n",t1); t1 = cheapestDirectFlight("MAN", "NCE", a); printf("Test3 of cheapestDirectFlight returns %d, should be 27.\n",t1); /* END OF CODE FOR TESTING "cheapestDirectFlight" */ /* ---------------------------------------------- */ /* CODE FOR TESTING "connectingPair" */ /* --------------------------------------- */ printf("------------------------------------------------\n"); t1= connectingPair(allflights[25], allflights[27]); printf("Test1 of connectingPair returns %d, should be 0.\n",t1); t1= connectingPair(allflights[24], allflights[27]); printf("Test2 of connectingPair returns %d, should be 0.\n",t1); t1= connectingPair(allflights[23], allflights[27]); printf("Test3 of connectingPair returns %d, should be 1.\n",t1); t1= connectingPair(allflights[24], allflights[22]); printf("Test4 of connectingPair returns %d, should be 0.\n",t1); /* END OF CODE FOR TESTING "connectingPair" */ /* ---------------------------------------- */ /* CODE FOR TESTING "bestTransferOption" */ /* ------------------------------------- */ pair_t conn; conn = bestTransferOption("EDI", "NCE", a); printf("------------------------------------------------------------\n"); printf("Test1 of bestTransferOptions returns %d, %d; should be 2, 8.\n",conn.first, conn.second); conn = bestTransferOption("NCE", "DUB", a); printf("Test2 of bestTransferOptions returns %d, %d; should be -1, -1.\n",conn.first, conn.second); conn = bestTransferOption("SNN", "ORK", b); printf("Test3 of bestTransferOptions returns %d, %d; should be 12, 30.\n",conn.first, conn.second); conn = bestTransferOption("HAM", "NCE", a); printf("Test4 of bestTransferOptions returns %d, %d; should be 35, 8.\n",conn.first, conn.second); conn = bestTransferOption("SNN", "LHR", b); printf("Test5 of bestTransferOptions returns %d, %d; should be -1, -1.\n",conn.first, conn.second); /* 6th test addded to clarify whether bestTransferOptions should * consider connecting pairs that fly on different dates */ conn = bestTransferOption("SNN", "GLA", b); printf("Test6 of bestTransferOptions returns %d, %d; should be -1, -1.\n",conn.first, conn.second); /* END OF CODE FOR TESTING "bestTransferOption" */ /* -------------------------------------------- */ return EXIT_SUCCESS; }