mention that the str_copy return value does not include the \0
add unit test
This commit is contained in:
parent
2d78cb8406
commit
8714ae112d
@ -9,6 +9,6 @@ size_t \fBstr_copy\fP(char* \fIout\fR,const char* \fIin\fR);
|
||||
str_copy copies the leading bytes of \fIin\fR to \fIout\fR up to and
|
||||
including the first occurrance of \\0.
|
||||
|
||||
str_copy returns the number of bytes copied.
|
||||
str_copy returns the number of bytes copied (not including the \\0).
|
||||
.SH "SEE ALSO"
|
||||
strlen(3)
|
||||
|
@ -15,3 +15,13 @@ size_t str_copy(char *out,const char *in) {
|
||||
}
|
||||
return (size_t)(s-out);
|
||||
}
|
||||
|
||||
#ifdef UNITTEST
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
char buf[100];
|
||||
memset(buf,1,sizeof(buf)); assert(str_copy(buf,"foo")==3 && !memcmp(buf,"foo",4));
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user