|
@@ -134,6 +134,26 @@ static void string_test_exec ( void ) {
|
134
|
134
|
ok ( strcmp ( dup, orig ) == 0 );
|
135
|
135
|
free ( dup );
|
136
|
136
|
}
|
|
137
|
+
|
|
138
|
+ /* Test strndup() */
|
|
139
|
+ {
|
|
140
|
+ const char *normal = "testing testing";
|
|
141
|
+ const char unterminated[6] = { 'h', 'e', 'l', 'l', 'o', '!' };
|
|
142
|
+ char *dup;
|
|
143
|
+ dup = strndup ( normal, 32 );
|
|
144
|
+ ok ( dup != NULL );
|
|
145
|
+ ok ( dup != normal );
|
|
146
|
+ ok ( strcmp ( dup, normal ) == 0 );
|
|
147
|
+ free ( dup );
|
|
148
|
+ dup = strndup ( normal, 4 );
|
|
149
|
+ ok ( dup != NULL );
|
|
150
|
+ ok ( strcmp ( dup, "test" ) == 0 );
|
|
151
|
+ free ( dup );
|
|
152
|
+ dup = strndup ( unterminated, 5 );
|
|
153
|
+ ok ( dup != NULL );
|
|
154
|
+ ok ( strcmp ( dup, "hello" ) == 0 );
|
|
155
|
+ free ( dup );
|
|
156
|
+ }
|
137
|
157
|
}
|
138
|
158
|
|
139
|
159
|
/** String self-test */
|