mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Add file src/test_strncpy_crlf.c and hook into build/tests.
This commit is contained in:
parent
c67942ea42
commit
c76d613445
@ -4,6 +4,12 @@
|
||||
Move function strncpy_crlf() to src/common.c so the function can be tested
|
||||
in isolation.
|
||||
|
||||
* src/test_strncpy_crlf.c
|
||||
New file.
|
||||
|
||||
* src/Makefile.am src/test_main.[ch]
|
||||
Hook test_strncpy_crlf.c into tests.
|
||||
|
||||
2010-08-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/common.h
|
||||
|
@ -43,7 +43,8 @@ libsndfile_la_LIBADD = libcommon.la GSM610/libgsm.la G72x/libg72x.la \
|
||||
libcommon_la_SOURCES = $(COMMON)
|
||||
|
||||
test_main_SOURCES = test_main.c test_main.h test_conversions.c test_float.c test_endswap.c \
|
||||
test_audio_detect.c test_log_printf.c test_file_io.c test_ima_oki_adpcm.c
|
||||
test_audio_detect.c test_log_printf.c test_file_io.c test_ima_oki_adpcm.c \
|
||||
test_strncpy_crlf.c
|
||||
test_main_LDADD = libcommon.la
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2010 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -40,6 +40,8 @@ main (void)
|
||||
test_audio_detect () ;
|
||||
test_ima_oki_adpcm () ;
|
||||
|
||||
test_strncpy_crlf () ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2010 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -34,3 +34,6 @@ void test_double_convert (void) ;
|
||||
|
||||
void test_audio_detect (void) ;
|
||||
void test_ima_oki_adpcm (void) ;
|
||||
|
||||
void test_strncpy_crlf (void) ;
|
||||
|
||||
|
51
src/test_strncpy_crlf.c
Normal file
51
src/test_strncpy_crlf.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
** Copyright (C) 2010 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
** the Free Software Foundation; either version 2.1 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "test_main.h"
|
||||
|
||||
void
|
||||
test_strncpy_crlf (void)
|
||||
{ const char *src = "a\nb\nc\n" ;
|
||||
char *dest ;
|
||||
int dest_len ;
|
||||
|
||||
print_test_name ("Testing psf_strncpy_crlf") ;
|
||||
|
||||
for (dest_len = 3 ; dest_len < 30 ; dest_len++)
|
||||
{ dest = calloc (1, dest_len + 1) ;
|
||||
dest [dest_len] = 0xea ;
|
||||
|
||||
psf_strncpy_crlf (dest, src, dest_len, sizeof (src)) ;
|
||||
|
||||
if (dest [dest_len] != 0xea)
|
||||
{ printf ("\n\nLine %d: buffer overrun for dest_len == %d\n\t", __LINE__, dest_len) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
free (dest) ;
|
||||
} ;
|
||||
|
||||
puts ("ok") ;
|
||||
} /* test_strncpy_crlf */
|
Loading…
Reference in New Issue
Block a user