1bb183703505e5ce1636e22aad6ae61686392b5b
[Faustine.git] / interpretor / lib / src / libsndfile-1.0.25 / src / test_strncpy_crlf.c
1 /*
2 ** Copyright (C) 2010-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU Lesser General Public License as published by
6 ** the Free Software Foundation; either version 2.1 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "sfconfig.h"
20
21 #include <stdio.h>
22 #include <stdlib.h>
23
24 #include "common.h"
25
26 #include "test_main.h"
27
28 void
29 test_psf_strlcpy_crlf (void)
30 { const char *src = "a\nb\nc\n" ;
31 char *dest ;
32 int dest_len ;
33
34 print_test_name ("Testing psf_strlcpy_crlf") ;
35
36 for (dest_len = 3 ; dest_len < 30 ; dest_len++)
37 { dest = calloc (1, dest_len + 1) ;
38 if (dest == NULL)
39 { printf ("\n\nLine %d: calloc failed!\n\n", __LINE__) ;
40 exit (1) ;
41 } ;
42
43 dest [dest_len] = '\xea' ;
44
45 psf_strlcpy_crlf (dest, src, dest_len, sizeof (src)) ;
46
47 if (dest [dest_len] != '\xea')
48 { printf ("\n\nLine %d: buffer overrun for dest_len == %d\n\n", __LINE__, dest_len) ;
49 exit (1) ;
50 } ;
51
52 free (dest) ;
53 } ;
54
55 puts ("ok") ;
56 } /* test_psf_strlcpy_crlf */