UPDATE: My test is now included in tests on http://www.majdsrour.com/mtm Seems to me this is much easier way for everyone to run tests.
Good luck to everyone :) On Jan 7, 7:23 pm, Dmitry <dmitry.zbar...@gmail.com> wrote: > First things first. > I just found one case that is not tested and it is NULL pointers > passed to schedule* functions. > Just add this case somewhere in the end of test. > Second thing. > Everyone interested in getting files, just send me email and I will > send you files. > There is no option of attaching files to messages in Google Groups, so > if someone wants me to put this file somewhere online, just email me > address of site where I can put them. > Last thing. Long lines. Program code still can be copied and pasted > into file and it will work. > > P.S. To Firasm101: I will send you files shortly. > > Regards, > Dmitry Zbarski. > > On Jan 4, 5:54 pm, Dmitry <dmitry.zbar...@gmail.com> wrote: > > > Hello everyone. > > > I've written my own test for matam homework 2. It's a much more > > extensive then the default ones provided by technion. I ran and double > > checked my output, but it is recommended to recheck your output in > > case something is different. > > To run the test, compile as explained in homework 2, but instead of > > copying main.c create real_test.c. > > Following are real_test.c, test.out (reference output) and test.err > > (reference error output). > > > real_test.c: > > #include <stdio.h> > > #include <stdlib.h> > > #include <assert.h> > > #include "schedule.h" > > #include "mtm_ex2.h" > > > #define SUCCESS 0 > > #define ERROR_OUT_OF_MEMORY -1 > > > #define ERROR_STREAM stderr > > > static int handleError(ScheduleResult result) { > > switch (result) { > > case SCHEDULE_OUT_OF_MEMORY: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_OUT_OF_MEMORY); > > return ERROR_OUT_OF_MEMORY; > > case SCHEDULE_NULL_ARG: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_NULL_ARG); > > break; > > case SCHEDULE_INVALID_LINE_TYPE: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_INVALID_LINE_TYPE); > > break; > > case SCHEDULE_INVALID_LINE_NUMBER: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_INVALID_LINE_NUMBER); > > break; > > case SCHEDULE_INVALID_PRICE: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_INVALID_PRICE); > > break; > > case SCHEDULE_INVALID_TRAIN_TYPE: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_INVALID_TRAIN_TYPE); > > break; > > case SCHEDULE_LINE_ALREADY_EXISTS: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_LINE_ALREADY_EXIST); > > break; > > case SCHEDULE_LINE_DOESNT_EXIST: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_LINE_DOESNT_EXIST); > > break; > > case SCHEDULE_STATION_ALREADY_EXIST: > > > > mtmPrintErrorMessage(ERROR_STREAM,MTM_STATION_ALREADY_EXIST); > > break; > > case SCHEDULE_STATION_DOESNT_EXIST: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_STATION_DOESNT_EXIST); > > break; > > case SCHEDULE_STATION_IS_USED: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_STATION_IS_USED); > > break; > > case SCHEDULE_INVALID_TIME: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_INVALID_TIME); > > break; > > case SCHEDULE_INVALID_STATION_INDEX: > > > > mtmPrintErrorMessage(ERROR_STREAM,MTM_INVALID_STATION_INDEX); > > break; > > case SCHEDULE_NO_LINES: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_NO_LINES); > > break; > > case SCHEDULE_NO_STATIONS: > > mtmPrintErrorMessage(ERROR_STREAM,MTM_NO_STATIONS); > > break; > > default: > > assert(result == SCHEDULE_SUCCESS); > > break; > > } > > return SUCCESS;} > > > // > > ============================================================================= > > int test() { > > Schedule schedule = scheduleCreate(); > > if(schedule == NULL) > > return ERROR_OUT_OF_MEMORY; > > > printf("Check some reports with empty schedule, should output errors > > \n"); > > if (handleError(scheduleReportRegisteredStations(schedule))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleReportLines(schedule, MTM_LINE_ALL))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleReportLines(schedule, MTM_LINE_BUS))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleReportLines(schedule, MTM_LINE_TRAIN))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > > printf("Register some stations\n"); > > if (handleError(scheduleRegisterStation(schedule, "Station 1.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 1.1"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 1.2"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 1.3"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 1.4"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 11.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 11.1"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 11.2"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 11.3"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 11.4"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 2.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 2.1"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 2.2"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 2.3"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 3.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 3.1"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 3.2"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 3.3"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 3.4"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 3.5"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 0.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > > printf("Here should be 3 errors about station already exists\n"); > > if (handleError(scheduleRegisterStation(schedule, "Station 1.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 2.3"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleRegisterStation(schedule, "Station 0.0"))) > > {scheduleDestroy(schedule); return ERROR_OUT_OF_MEMORY;} > > > printf("Add lines\n"); > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 901, > > "Egged", 33))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 902, > > "Egged", 34))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 101, > > "Metropolin", 34))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 555, > > "Metropolin", 30))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 9, > > "A", 45))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 89, > > "e", 54))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_BUS, 75, > > "z", 56))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, MTM_LINE_TRAIN, 1901, > > "direct", 37))) {scheduleDestroy(schedule); return > > ERROR_OUT_OF_MEMORY;} > > if (handleError(scheduleAddLine(schedule, > > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Technion References" group. To post to this group, send email to reference-technion@googlegroups.com To unsubscribe from this group, send email to reference-technion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reference-technion?hl=en -~----------~----~----~----~------~----~------~--~---