Name: Michael Zhang NetID: mz487
Name: Cyrus Majd NetID: cm1355
A word wrapping program meant to reformat a text file into a more easily digestible format, wrapping based upon a user inputted width and eliminating excess whitespace.
- Will wrap FILE_NAME within WIDTH amount, printing results to STDOUT
$./ww WIDTH FILE_NAME
- Will wrap all files in a DIRECTORY according to WIDTH, outputting to wrap.file_name for every file_name in DIRECTORY
$./ww WIDTH DIRECTORY
- Will read in from STDIN and print to STDOUT, according to WIDTH
$./ww WIDTH
- Note: It is recommended that if you so wish to read from STDIN, that you use piping and redirection to achieve so. Example:
$cat FILE_NAME | ./ww WIDTH
Initially, the program was tested to check for syntax, memory leaks, and compilation errors. Upon confirming a lack of such issues, these cases were tested for:
-
Does the program print as expected when encountering excess whitespace in the beginning?
Indeed it did. All excess whitespace in the beginning was eliminated in the output. -
Does the program print as expected given multiple newlines, thus establishing new paragraphs, but not printing excessive amounts of space between paragraphs?
Yes, it did. Only a singular empty line was printed between any two paragraphs. -
Can the program handle not only directories that are scoped to
./, but also in other locations, such as directories above it?
Yes, the program was able to handle other directory paths, both relative and absolute. -
Does the program behave as expected when encountering files that don't exist? That is, if the file inputted into the command line does not exist, does it
perrorand returnEXIT_FAILURE?
It did indeedperror, and it did returnEXIT_FAILUREas confirmed usingecho $?. -
Does a similar behavior as described in the situation with a file that does not exist occur for a file which does not have read permission?
Indeed, it did. Confirmed by theperrorresults as well asecho $?. -
Does the program behave correctly when one word is larger than the size of the read buffer?
Yes it did, asecho $?showed the exit code to be the int value ofEXIT_FAILUREon a Ubuntu machine. -
Does the program correctly wrap larger text files?
Yes, confirming that the program can handle files of large size. -
Does the program behave correctly when in a situation where write access to a file is not allowed?
Yes. Itperroras expected, although it should be noted that such a situation would be more a user error, as there should be no "wrap" file being written to that has not been made by the program itself.