This assignment is to make several enhancements to the code in the lecture-13 repository.
For this assignment, first add to or enhance the unit tests in “main_v1.c”, include “main_v1.c” in your build and exclude “main_v2.c”, and run the program. Next, add or enhance the unit tests in “publisher_test.c” and/or “journal_test.c”, include “main_v2.c” in your build and exclude “main_v1.c”, and run the program again.
Check in all files from the lecture-13 repository, whether or not you modified, them so the graders can run your program.
Modify the Journal struct, changing the fixed length name field to a character array pointer (char*). In newJournal(), add code to initialize the field with a dynamically allocated string for the name parameter. Modify the deleteJournal() function to free the name string before freeing the Journal
Modify the Publisher struct, changing the fixed length name field to a character array pointer (char*). In newPublisher(), add code to initialize the field with a dynamically allocated string for the name parameter. Modify the deletePublisher() function to free the name string before freeing the Publisher.
Modify the deletePublisher() function to delete the Journal structs in the journals array before freeing the journals list and the Publisher. Enhance the Publisher unit tests to call deletePublisher() on the test publisher to ensure that its journals are deleted. To verify that it returns successfully, call CU_PASS(“Publisher deleted.”) after calling deletePublisher()
Implement a function getJournalForIssn() in “publisher.c” that takes a const Publisher pointer publisherand a Issn issn. The function returns a pointer to a Journal in the journals array whose issn field matches the specified issn. If a matching Journal is not found, the function returns NULL. Include a declaration for the new function in “publisher.h” and add unit tests for this new function.
Enhance the newJournal() function to first check whether a Journal with the same issn has already been added to the publisher using getJournalForIssn(). If so, newJournal() returns a pointer to the existing Journal. Otherwise, it creates and initializes a new Journal, calls addJournalToPublisher(), and returns a pointer to the new Journal. Enhance the unit tests for newJournal() to test this new functionality, and modify any other unit tests as necessary.