Add test to validate ft_strncat potential length return#26
Open
SAntonopoulou wants to merge 1 commit intok11q:mainfrom
Open
Add test to validate ft_strncat potential length return#26SAntonopoulou wants to merge 1 commit intok11q:mainfrom
SAntonopoulou wants to merge 1 commit intok11q:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added a test condition to the C03/ex05/ft_strncat.c tests. I noticed that the returned potential length was not the same as my functions returned potential length; which caused my push to fail on moulinette. Upon comparing the outputs of the actual function and mine it was noted that the potential output on mine was not the same because of this particular condition mentioned in the man pages which I had failed to account for in my code:
"Note, however, that if strlcat() traverses size characters without finding a NUL, the length of the string is considered to be size and the destination string will not be NUL-terminated (since there was no space for the NUL)."
This allowed my code to pass the mini-moulinette tests but failed on the campus systems. I've since added a conditional check which compares the expected potential length (.pot) with the returned potential length (pot_len) of the student function.
I had originally just used my ft_strlen method for setting the dest
dest_length = ft_strlen(dest);
src_length = ft_strlen(src);
However because of this particular condition it was necessary to use strnlen to ensure that dest_length never became longer than size. The previous tests would only check the output (which in my case still matched), but failed to confirm the same potential length return value. The test I have added accounts for this potential difference.