Skip to content

Add test to validate ft_strncat potential length return#26

Open
SAntonopoulou wants to merge 1 commit intok11q:mainfrom
SAntonopoulou:c03ex5destlengthfix
Open

Add test to validate ft_strncat potential length return#26
SAntonopoulou wants to merge 1 commit intok11q:mainfrom
SAntonopoulou:c03ex5destlengthfix

Conversation

@SAntonopoulou
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant