mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Add file containing tests for broadcast_set_var().
This commit is contained in:
parent
c76d613445
commit
71213e1a7e
@ -1,3 +1,11 @@
|
||||
2010-08-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/test_broadcast_var.c
|
||||
New file containing tests for broadcast_set_var().
|
||||
|
||||
* src/Makefile.am src/test_main.[ch]
|
||||
Hook test_broadcast_var.c into tests.
|
||||
|
||||
2010-08-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/broadcast.c src/common.(c|h)
|
||||
|
@ -44,7 +44,7 @@ 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_strncpy_crlf.c
|
||||
test_strncpy_crlf.c test_broadcast_var.c
|
||||
test_main_LDADD = libcommon.la
|
||||
|
||||
|
||||
|
87
src/test_broadcast_var.c
Normal file
87
src/test_broadcast_var.c
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
** 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 <string.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "test_main.h"
|
||||
|
||||
#define BCAST_MAX 512
|
||||
|
||||
typedef SF_BROADCAST_INFO_VAR (512) SF_BROADCAST_INFO_512 ;
|
||||
|
||||
static void
|
||||
fill_coding_history (SF_BROADCAST_INFO_512 * bi)
|
||||
{ static const char *lines [] =
|
||||
{ "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.",
|
||||
"Donec dignissim erat\nvehicula libero condimentum\ndictum porta augue faucibus.",
|
||||
"Maecenas nec turpis\nsit amet quam\nfaucibus adipiscing.",
|
||||
"Mauris aliquam,\nlectus interdum\ntincidunt luctus.",
|
||||
"\n\n\n\n\n\n\n\n\n\n\n\n",
|
||||
"In auctor lorem\nvel est euismod\ncondimentum.",
|
||||
"\n\n\n\n\n\n\n\n\n\n\n\n",
|
||||
"Ut vitae magna\nid dui placerat vehicula\nin id lectus.",
|
||||
"\n\n\n\n\n\n\n\n\n\n\n\n",
|
||||
"Sed lacus leo,\nmolestie et luctus ac,\ntincidunt sit amet nisi.",
|
||||
"\n\n\n\n\n\n\n\n\n\n\n\n",
|
||||
"Sed ligula neque,\ngravida semper vulputate laoreet,\ngravida eu tellus.",
|
||||
"Donec dolor dolor,\nscelerisque in consequat ornare,\ntempor nec nisl."
|
||||
} ;
|
||||
int k ;
|
||||
|
||||
bi->coding_history [0] = 0 ;
|
||||
|
||||
for (k = 0 ; strlen (bi->coding_history) < bi->coding_history_size - 1 ; k ++)
|
||||
append_snprintf (bi->coding_history, bi->coding_history_size, "%s\n", lines [k % ARRAY_LEN (lines)]) ;
|
||||
|
||||
return ;
|
||||
} /* fill_coding_listory */
|
||||
|
||||
void
|
||||
test_broadcast_var (void)
|
||||
{ SF_PRIVATE sf_private, *psf ;
|
||||
int k ;
|
||||
|
||||
psf = &sf_private ;
|
||||
memset (psf, 0, sizeof (sf_private)) ;
|
||||
|
||||
print_test_name ("Testing broadcast_var_set ") ;
|
||||
|
||||
for (k = 64 ; k < BCAST_MAX + 20 ; k++)
|
||||
{
|
||||
SF_BROADCAST_INFO_512 bi ;
|
||||
|
||||
memset (&bi, 0, sizeof (bi)) ;
|
||||
|
||||
bi.coding_history_size = k ;
|
||||
fill_coding_history (&bi) ;
|
||||
bi.coding_history_size -- ;
|
||||
|
||||
broadcast_var_set (psf, (SF_BROADCAST_INFO*) &bi, sizeof (bi)) ;
|
||||
} ;
|
||||
|
||||
if (psf->broadcast_var != NULL)
|
||||
free (psf->broadcast_var) ;
|
||||
|
||||
puts ("ok") ;
|
||||
} /* test_broadcast_var */
|
@ -41,6 +41,7 @@ main (void)
|
||||
test_ima_oki_adpcm () ;
|
||||
|
||||
test_strncpy_crlf () ;
|
||||
test_broadcast_var () ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
@ -36,4 +36,4 @@ void test_audio_detect (void) ;
|
||||
void test_ima_oki_adpcm (void) ;
|
||||
|
||||
void test_strncpy_crlf (void) ;
|
||||
|
||||
void test_broadcast_var (void) ;
|
||||
|
Loading…
Reference in New Issue
Block a user