5 /* strncat( char *, const char *, size_t )
7 This file is part of the Public Domain C Library (PDCLib).
8 Permission is granted to use, modify, and / or redistribute at will.
11 #include <_PDCLIB_aux.h>
16 char * strncat( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2, size_t n )
23 while ( n && ( *s1++ = *s2++ ) )
37 #include <_PDCLIB_test.h>
41 char s[] = "xx\0xxxxxx";
43 TESTCASE( strncat( s, abcde, 10 ) == s );
44 TESTCASE( s[2] == 'a' );
45 TESTCASE( s[6] == 'e' );
46 TESTCASE( s[7] == '\0' );
47 TESTCASE( s[8] == 'x' );
49 TESTCASE( strncat( s, abcdx, 10 ) == s );
50 TESTCASE( s[4] == 'x' );
51 TESTCASE( s[5] == '\0' );
52 TESTCASE( strncat( s, "\0", 10 ) == s );
53 TESTCASE( s[5] == '\0' );
54 TESTCASE( s[6] == 'e' );
55 TESTCASE( strncat( s, abcde, 0 ) == s );
56 TESTCASE( s[5] == '\0' );
57 TESTCASE( s[6] == 'e' );
58 TESTCASE( strncat( s, abcde, 3 ) == s );
59 TESTCASE( s[5] == 'a' );
60 TESTCASE( s[7] == 'c' );
61 TESTCASE( s[8] == '\0' );