Document Analysis Project in C - Part 2 (version 2)
This second part of the project builds upon the set of library functions from part 1.
Implement the functions in the order specified below. You are required to submit your code after
completing each function. An extensive set of unit tests is included along with a Makefile. You will also be required to implement your own unit tests in unit_tests_student.c
. See the file for details, and use the file unit_tests.c
as a reference.
Development process
- All of your code will be implemented in the analysis.c and unit_tests_student.c files. Detailed descriptions
of the operation of each function are included in this source code file. These are the only two source code files that will be graded.
- NOTE:You must copy your previously implemented linked_list_functions.c from Part 1 to your new Part 2 directory. You will be replacing the empty linked_list_functions.c file.
- Run the make utility to build your Part 2 code:
make
- Do not make any changes to any of the other files.
- You are not allowed to change the design of the functions in analysis.c.
- You will be graded on both the quality of your code and the number of provided unit tests that pass.
- Incremental development is required. You must submit your code after completing each function.
Do not start the next function until you get the previous function working.
- In your activity journal be sure to enter an estimate for each function before starting the code.
- Update your activity journal with your time spent and observations when implementing that one function.
- Submit your code when that function passes its unit tests. You must include your updated Activity Journal.
- Do not start the next function until the previous function is working.
If you must continue with one or two tests still failing be aware that this may cause problems with the subsequent functions.
- Implement and submit the functions in this order (as shown in the ActivityJournal):
- Optional helper functions that can be implemented at any time or skipped:
- Comment out these helper functions if you choose to not use them.
- check_linked_list
- get_current_entry
- If desired you can create your own static helper functions at the top of analysis.c.
- process_word
- get_first_entry
- get_next_entry
- get_last_entry
- get_prev_entry
- read_file (through test 56)
- read_file (MLK_dream_excerpt only)
- write_unique_word_list_to_csv_file
- Add four unit tests to the unit_tests_student.c file
Setup
Download part2.zip.
Build the system:
You need to periodically verify that you do not have any memory leaks:
valgrind --leak-check=full ./test
If your section is using the gitlab CI, update your .gitlab-ci.yml file PROJECT_FOLDER variable for this assignment
Unit Testing Notes
The zip file contains all of the files you need for the unit tests. These text files
(empty.txt, one_word.txt, five_words.txt, and MLK_dream_excerpt.txt) must not be changed.
The unit tests use these file to test your code.
Running the unit tests
- If you run analysis with no parameters then it will run all tests (linked list, analysis, and student)
./test
- If you run it this way you will just run the tests of your linked_list_function code from Part 1:
./test linked (l is sufficient)
- If you run it this way you will just run your student created unit tests along with the two provided tests in unit_tests_student.c:
./test student (s is sufficient)
- If you run it this way you will just run the analysis unit tests:
./test analysis (a is sufficient)
Development Tips
The analysis.c file provided has code to implement most of the file read capability that you need.
There are a few special methods as explained below:
validate_read_file_parameters
This is used by read_file
. Do not change this method
read_file
Starter code is provided. The code opens a file and sets up to read characters from the file using fopen() and a FILE structure. It uses fgetc()
, which is similar to getchar(), and reads one character at a time from the file.
Fill in the code where indicated (don't change other parts of the code)
NOTE: Read file should work similar to how you did word_count ... you have to read in characters until you find a word, and use process_word to add the word to the list.
-
write_unique_word_list_to_csv_file
Code is provided to open a file, so you can write to it. Do not change the initial code
Fill in the code where indicated, using fprintf
to write to the file (which is similar to printf
). Syntax examples are below.
Usage: fprintf(FILE*, "your format string", data_variables)
e.g. With printf it would be: printf("My word is: %s\n", word);
With fprintf it is: fprintf(out_file, "My word is: %s\n", word);
where out_file is a FILE*
(see the code)
Overall Evaluation
Note -- your project will be tested using the instructor's solution for part 1.
- (15) Overall code quality including valgrind checks that show no memory leaks.
- ( 5) Incremental development with at least one submission per function
- ( 5) Correct submission and code compiles and links without warnings with provided Makefile
- ( 5) All unit tests run without crashing (no segment faults and no infinite loops)
- (10) process_word
- ( 5) get_first_entry
- ( 5) get_next_entry
- ( 5) get_last_entry
- ( 5) get_prev_entry
- (15) read_file (through test 56)
- (10) read_file (MLK_dream_excerpt only)
- (10) write_unique_word_list_to_csv_file
- ( 5) Add four unit tests to the unit_tests_student.c file
Submission
Place your completed files and ActivityJournal.txt in a directory named
analysis_part2 at the top level of your git repo.