mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
src/test_* : Collapse all tests into a single executable.
This commit is contained in:
parent
e80b9599f7
commit
adc85e91de
@ -71,13 +71,8 @@ src/config.h
|
|||||||
src/config.h.in
|
src/config.h.in
|
||||||
src/sndfile.h
|
src/sndfile.h
|
||||||
src/stamp-h1
|
src/stamp-h1
|
||||||
src/test_audio_detect
|
|
||||||
src/test_conversions
|
|
||||||
src/test_endswap
|
|
||||||
src/test_endswap.c
|
src/test_endswap.c
|
||||||
src/test_file_io
|
src/test_main
|
||||||
src/test_ima_oki_adpcm
|
|
||||||
src/test_log_printf
|
|
||||||
tests/*_test
|
tests/*_test
|
||||||
tests/benchmark
|
tests/benchmark
|
||||||
tests/benchmark.c
|
tests/benchmark.c
|
||||||
|
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2008-04-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||||
|
|
||||||
|
* src/test_*
|
||||||
|
Add files test_main.[ch].
|
||||||
|
Collapse all tests into a single executable.
|
||||||
|
|
||||||
|
2008-03-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||||
|
|
||||||
|
* src/FLAC
|
||||||
|
Sync to upstream CVS.
|
||||||
|
|
||||||
2008-03-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
2008-03-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||||
|
|
||||||
* doc/FAQ.html
|
* doc/FAQ.html
|
||||||
|
@ -19,8 +19,7 @@ EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \
|
|||||||
|
|
||||||
noinst_HEADERS = common.h sfconfig.h sfendian.h float_cast.h wav_w64.h sf_unistd.h
|
noinst_HEADERS = common.h sfconfig.h sfendian.h float_cast.h wav_w64.h sf_unistd.h
|
||||||
|
|
||||||
noinst_PROGRAMS = test_endswap test_file_io test_conversions test_log_printf \
|
noinst_PROGRAMS = test_main
|
||||||
test_audio_detect test_ima_oki_adpcm
|
|
||||||
|
|
||||||
COMMON = common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
|
COMMON = common.c file_io.c command.c pcm.c ulaw.c alaw.c float32.c \
|
||||||
double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \
|
double64.c ima_adpcm.c ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c \
|
||||||
@ -40,48 +39,27 @@ libsndfile_la_LIBADD = libcommon.la GSM610/libgsm.la G72x/libg72x.la OGG/libogg.
|
|||||||
|
|
||||||
libcommon_la_SOURCES = $(COMMON)
|
libcommon_la_SOURCES = $(COMMON)
|
||||||
|
|
||||||
test_endswap_SOURCES = test_endswap.c
|
test_main_SOURCES = test_main.c test_conversions.c test_endswap.c test_audio_detect.c \
|
||||||
|
test_log_printf.c test_file_io.c test_ima_oki_adpcm.c
|
||||||
|
test_main_LDADD = libcommon.la
|
||||||
|
|
||||||
test_file_io_CFLAGS = $(AM_CFLAGS)
|
|
||||||
test_file_io_SOURCES = test_file_io.c
|
|
||||||
test_file_io_LDADD = libcommon.la
|
|
||||||
|
|
||||||
test_log_printf_CFLAGS = $(AM_CFLAGS)
|
|
||||||
test_log_printf_SOURCES = test_log_printf.c
|
|
||||||
test_log_printf_LDADD = libcommon.la
|
|
||||||
|
|
||||||
test_conversions_CFLAGS = $(AM_CFLAGS)
|
|
||||||
test_conversions_SOURCES = test_conversions.c
|
|
||||||
test_conversions_LDADD = libcommon.la
|
|
||||||
|
|
||||||
test_audio_detect_CFLAGS = $(AM_CFLAGS)
|
|
||||||
test_audio_detect_SOURCES = test_audio_detect.c
|
|
||||||
test_audio_detect_LDADD = libcommon.la
|
|
||||||
|
|
||||||
test_ima_oki_adpcm_CFLAGS = -DTEST $(AM_CFLAGS)
|
|
||||||
test_ima_oki_adpcm_SOURCES = ima_oki_adpcm.c
|
|
||||||
|
|
||||||
test_endswap.c: test_endswap.def test_endswap.tpl
|
test_endswap.c: test_endswap.def test_endswap.tpl
|
||||||
autogen --writable test_endswap.def
|
autogen --writable test_endswap.def
|
||||||
|
|
||||||
genfiles : test_endswap.c Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def
|
genfiles : test_endswap.c Symbols.linux Symbols.darwin libsndfile.def cygsndfile.def
|
||||||
|
|
||||||
# Two test programs.
|
# A single test programs.
|
||||||
# It is not possible to place these in the tests/ directory because they
|
# It is not possible to place these in the tests/ directory because they
|
||||||
# need access to the internals of the SF_PRIVATE struct.
|
# need access to the internals of the SF_PRIVATE struct.
|
||||||
|
|
||||||
check: test_endswap test_file_io test_conversions test_log_printf
|
check: $(noinst_PROGRAMS)
|
||||||
@echo
|
@echo
|
||||||
@echo
|
@echo
|
||||||
@echo
|
@echo
|
||||||
@echo "============================================================"
|
@echo "============================================================"
|
||||||
@if [ -x /usr/bin/python2.4 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
|
@if [ -x /usr/bin/python2.4 ]; then $(srcdir)/binheader_writef_check.py $(srcdir)/*.c ; fi
|
||||||
./test_endswap
|
./test_main$(EXEEXT)
|
||||||
./test_file_io
|
|
||||||
./test_conversions
|
|
||||||
./test_log_printf
|
|
||||||
./test_audio_detect
|
|
||||||
./test_ima_oki_adpcm
|
|
||||||
@echo "============================================================"
|
@echo "============================================================"
|
||||||
@echo
|
@echo
|
||||||
@echo
|
@echo
|
||||||
@ -122,10 +100,3 @@ sds.c wve.c dwd.c ogg.c xi.c sndfile.c common.c file_io.c : sndfile.h common.h
|
|||||||
command.c pcm.c ulaw.c alaw.c float32.c double64.c ima_adpcm.c : sndfile.h common.h
|
command.c pcm.c ulaw.c alaw.c float32.c double64.c ima_adpcm.c : sndfile.h common.h
|
||||||
ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c interleave.c strings.c : sndfile.h common.h
|
ms_adpcm.c gsm610.c dwvw.c vox_adpcm.c interleave.c strings.c : sndfile.h common.h
|
||||||
dither.c : sndfile.h common.h
|
dither.c : sndfile.h common.h
|
||||||
|
|
||||||
## Do not edit or modify anything in this comment block.
|
|
||||||
## The arch-tag line is a file identity tag for the GNU Arch
|
|
||||||
## revision control system.
|
|
||||||
##
|
|
||||||
## arch-tag: fc3511e6-4230-4bcb-9c86-f728d7a06fe7
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2007 Erik de Castro Lopo <erikd@mega-nerd.com>
|
** Copyright (C) 2007-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify
|
** 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
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
@ -31,20 +31,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "sfendian.h"
|
#include "sfendian.h"
|
||||||
|
|
||||||
|
#include "test_main.h"
|
||||||
static void test_audio_detect (void) ;
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
test_audio_detect () ;
|
|
||||||
|
|
||||||
return 0 ;
|
|
||||||
} /* main */
|
|
||||||
|
|
||||||
/*==============================================================================
|
|
||||||
** Test data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static unsigned char float_le_mono [] =
|
static unsigned char float_le_mono [] =
|
||||||
{ 0x36, 0x86, 0x21, 0x44, 0xB5, 0xB4, 0x49, 0x44, 0xA2, 0xC0, 0x71, 0x44, 0x7B, 0xD1, 0x8C, 0x44,
|
{ 0x36, 0x86, 0x21, 0x44, 0xB5, 0xB4, 0x49, 0x44, 0xA2, 0xC0, 0x71, 0x44, 0x7B, 0xD1, 0x8C, 0x44,
|
||||||
@ -87,15 +74,14 @@ static unsigned char int24_32_le_stereo [] =
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
test_audio_detect (void)
|
test_audio_detect (void)
|
||||||
{
|
{
|
||||||
SF_PRIVATE psf ;
|
SF_PRIVATE psf ;
|
||||||
AUDIO_DETECT ad ;
|
AUDIO_DETECT ad ;
|
||||||
int errors = 0 ;
|
int errors = 0 ;
|
||||||
|
|
||||||
printf (" test_audio_detect : ") ;
|
print_test_name ("Testing audio detect") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
memset (&psf, 0, sizeof (psf)) ;
|
memset (&psf, 0, sizeof (psf)) ;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2006,2007 Erik de Castro Lopo <erikd@mega-nerd.com>
|
** Copyright (C) 2006-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify
|
** 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
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
@ -25,6 +25,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "test_main.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This is a bit rough, but it is the nicest way to do it.
|
** This is a bit rough, but it is the nicest way to do it.
|
||||||
@ -36,16 +38,6 @@
|
|||||||
exit (1) ; \
|
exit (1) ; \
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
static void conversion_test (char endian) ;
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
conversion_test ('E') ;
|
|
||||||
conversion_test ('e') ;
|
|
||||||
return 0 ;
|
|
||||||
} /* main */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
conversion_test (char endian)
|
conversion_test (char endian)
|
||||||
{
|
{
|
||||||
@ -53,6 +45,7 @@ conversion_test (char endian)
|
|||||||
const char * filename = "conversion.bin" ;
|
const char * filename = "conversion.bin" ;
|
||||||
long long i64 = SF_PLATFORM_S64 (0x0123456789abcdef), t64 = 0 ;
|
long long i64 = SF_PLATFORM_S64 (0x0123456789abcdef), t64 = 0 ;
|
||||||
char format_str [16] ;
|
char format_str [16] ;
|
||||||
|
char test_name [64] ;
|
||||||
char i8 = 12, t8 = 0 ;
|
char i8 = 12, t8 = 0 ;
|
||||||
short i16 = 0x123, t16 = 0 ;
|
short i16 = 0x123, t16 = 0 ;
|
||||||
int i24 = 0x23456, t24 = 0 ;
|
int i24 = 0x23456, t24 = 0 ;
|
||||||
@ -61,8 +54,8 @@ conversion_test (char endian)
|
|||||||
|
|
||||||
snprintf (format_str, sizeof (format_str), "%c12348", endian) ;
|
snprintf (format_str, sizeof (format_str), "%c12348", endian) ;
|
||||||
|
|
||||||
printf (" conversion_test_%-8s : ", endian == 'e' ? "le" : "be") ;
|
snprintf (test_name, sizeof (test_name), "Testing %s conversions", endian == 'e' ? "little endian" : "big endian") ;
|
||||||
fflush (stdout) ;
|
print_test_name (test_name) ;
|
||||||
|
|
||||||
psf = &sf_private ;
|
psf = &sf_private ;
|
||||||
memset (psf, 0, sizeof (sf_private)) ;
|
memset (psf, 0, sizeof (sf_private)) ;
|
||||||
@ -99,3 +92,11 @@ conversion_test (char endian)
|
|||||||
remove (filename) ;
|
remove (filename) ;
|
||||||
puts ("ok") ;
|
puts ("ok") ;
|
||||||
} /* conversion_test */
|
} /* conversion_test */
|
||||||
|
|
||||||
|
void
|
||||||
|
test_conversions (void)
|
||||||
|
{
|
||||||
|
conversion_test ('E') ;
|
||||||
|
conversion_test ('e') ;
|
||||||
|
} /* test_conversion */
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "sfendian.h"
|
#include "sfendian.h"
|
||||||
|
|
||||||
|
#include "test_main.h"
|
||||||
|
|
||||||
#define FMT_SHORT "0x%04x\n"
|
#define FMT_SHORT "0x%04x\n"
|
||||||
#define FMT_INT "0x%08x\n"
|
#define FMT_INT "0x%08x\n"
|
||||||
|
|
||||||
@ -41,23 +43,8 @@
|
|||||||
#define FMT_INT64 "0x%016llx\n"
|
#define FMT_INT64 "0x%016llx\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[+ FOR int_type
|
|
||||||
+]static void test_endswap_[+ (get "name") +] (void) ;
|
|
||||||
[+ ENDFOR int_type
|
|
||||||
+]
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
[+ FOR int_type
|
|
||||||
+] test_endswap_[+ (get "name") +] () ;
|
|
||||||
[+ ENDFOR int_type
|
|
||||||
+]
|
|
||||||
return 0 ;
|
|
||||||
} /* main */
|
|
||||||
|
|
||||||
/*==============================================================================
|
/*==============================================================================
|
||||||
** Actual test functions.
|
** Test functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[+ FOR int_type +]
|
[+ FOR int_type +]
|
||||||
@ -76,7 +63,7 @@ test_endswap_[+ (get "name") +] (void)
|
|||||||
{ [+ (get "name") +] orig [4], first [4], second [4] ;
|
{ [+ (get "name") +] orig [4], first [4], second [4] ;
|
||||||
int k ;
|
int k ;
|
||||||
|
|
||||||
printf (" %-24s : ", "test_endswap_[+ (get "name") +]") ;
|
printf (" %-40s : ", "test_endswap_[+ (get "name") +]") ;
|
||||||
fflush (stdout) ;
|
fflush (stdout) ;
|
||||||
|
|
||||||
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
|
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
|
||||||
@ -124,3 +111,12 @@ test_endswap_[+ (get "name") +] (void)
|
|||||||
+]
|
+]
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
test_endswap (void)
|
||||||
|
{
|
||||||
|
[+ FOR int_type
|
||||||
|
+] test_endswap_[+ (get "name") +] () ;
|
||||||
|
[+ ENDFOR int_type
|
||||||
|
+]
|
||||||
|
} /* test_endswap */
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify
|
** 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
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include "test_main.h"
|
||||||
|
|
||||||
static void make_data (int *data, int len, int seed) ;
|
static void make_data (int *data, int len, int seed) ;
|
||||||
|
|
||||||
static void file_open_test (const char *filename) ;
|
static void file_open_test (const char *filename) ;
|
||||||
@ -46,19 +48,6 @@ static void test_seek_or_die (SF_PRIVATE *psf, sf_count_t offset, int whence, sf
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{ const char *filename = "file_io.dat" ;
|
|
||||||
|
|
||||||
file_open_test (filename) ;
|
|
||||||
file_read_write_test (filename) ;
|
|
||||||
file_truncate_test (filename) ;
|
|
||||||
|
|
||||||
unlink (filename) ;
|
|
||||||
|
|
||||||
return 0 ;
|
|
||||||
} /* main */
|
|
||||||
|
|
||||||
/*==============================================================================
|
/*==============================================================================
|
||||||
** Actual test functions.
|
** Actual test functions.
|
||||||
*/
|
*/
|
||||||
@ -68,8 +57,7 @@ file_open_test (const char *filename)
|
|||||||
{ SF_PRIVATE sf_data, *psf ;
|
{ SF_PRIVATE sf_data, *psf ;
|
||||||
int error ;
|
int error ;
|
||||||
|
|
||||||
printf (" %-24s : ", "file_open_test") ;
|
print_test_name ("Testing file open") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
memset (&sf_data, 0, sizeof (sf_data)) ;
|
memset (&sf_data, 0, sizeof (sf_data)) ;
|
||||||
psf = &sf_data ;
|
psf = &sf_data ;
|
||||||
@ -129,8 +117,7 @@ file_read_write_test (const char *filename)
|
|||||||
** write, test that psf_get_filelen() returns the new length.
|
** write, test that psf_get_filelen() returns the new length.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf (" %-24s : ", "file_write_test") ;
|
print_test_name ("Testing file write") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
memset (&sf_data, 0, sizeof (sf_data)) ;
|
memset (&sf_data, 0, sizeof (sf_data)) ;
|
||||||
psf = &sf_data ;
|
psf = &sf_data ;
|
||||||
@ -166,8 +153,7 @@ file_read_write_test (const char *filename)
|
|||||||
** that the data is correct.
|
** that the data is correct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf (" %-24s : ", "file_read_test") ;
|
print_test_name ("Testing file read") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
/* Test file open in write mode. */
|
/* Test file open in write mode. */
|
||||||
psf->mode = SFM_READ ;
|
psf->mode = SFM_READ ;
|
||||||
@ -191,8 +177,7 @@ file_read_write_test (const char *filename)
|
|||||||
** go back and check that all three blocks are correct.
|
** go back and check that all three blocks are correct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf (" %-24s : ", "file_seek_test") ;
|
print_test_name ("Testing file seek") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
/* Test file open in read/write mode. */
|
/* Test file open in read/write mode. */
|
||||||
psf->mode = SFM_RDWR ;
|
psf->mode = SFM_RDWR ;
|
||||||
@ -230,8 +215,7 @@ file_read_write_test (const char *filename)
|
|||||||
** the file will actually be a seek to the value given by psf->fileoffset.
|
** the file will actually be a seek to the value given by psf->fileoffset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf (" %-24s : ", "file_offset_test") ;
|
print_test_name ("Testing file offset") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
/* Test file open in read/write mode. */
|
/* Test file open in read/write mode. */
|
||||||
psf->mode = SFM_RDWR ;
|
psf->mode = SFM_RDWR ;
|
||||||
@ -287,8 +271,7 @@ file_truncate_test (const char *filename)
|
|||||||
** write, test that psf_get_filelen() returns the new length.
|
** write, test that psf_get_filelen() returns the new length.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf (" %-24s : ", "file_truncate_test") ;
|
print_test_name ("Testing file truncate") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
memset (&sf_data, 0, sizeof (sf_data)) ;
|
memset (&sf_data, 0, sizeof (sf_data)) ;
|
||||||
memset (buffer, 0xEE, sizeof (buffer)) ;
|
memset (buffer, 0xEE, sizeof (buffer)) ;
|
||||||
@ -439,10 +422,15 @@ make_data (int *data, int len, int seed)
|
|||||||
data [k] = rand () ;
|
data [k] = rand () ;
|
||||||
|
|
||||||
} /* make_data */
|
} /* make_data */
|
||||||
/*
|
|
||||||
** Do not edit or modify anything in this comment block.
|
void
|
||||||
** The arch-tag line is a file identity tag for the GNU Arch
|
test_file_io (void)
|
||||||
** revision control system.
|
{ const char *filename = "file_io.dat" ;
|
||||||
**
|
|
||||||
** arch-tag: 0a21fb93-78dd-4f72-8338-4bca9e77b8c8
|
file_open_test (filename) ;
|
||||||
*/
|
file_read_write_test (filename) ;
|
||||||
|
file_truncate_test (filename) ;
|
||||||
|
|
||||||
|
unlink (filename) ;
|
||||||
|
} /* main */
|
||||||
|
|
||||||
|
155
src/test_ima_oki_adpcm.c
Normal file
155
src/test_ima_oki_adpcm.c
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
** Copyright (c) 2007 <robs@users.sourceforge.net>
|
||||||
|
** Copyright (C) 2007-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This library 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 of the License, or (at
|
||||||
|
** your option) any later version.
|
||||||
|
**
|
||||||
|
** This library 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 library. If not, write to the Free Software Foundation,
|
||||||
|
** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "test_main.h"
|
||||||
|
|
||||||
|
#include "ima_oki_adpcm.c"
|
||||||
|
|
||||||
|
static const unsigned char test_codes [] =
|
||||||
|
{ 0x08, 0x08, 0x04, 0x7f, 0x72, 0xf7, 0x9f, 0x7c, 0xd7, 0xbc, 0x7a, 0xa7, 0xb8,
|
||||||
|
0x4b, 0x0b, 0x38, 0xf6, 0x9d, 0x7a, 0xd7, 0xbc, 0x7a, 0xd7, 0xa8, 0x6c, 0x81,
|
||||||
|
0x98, 0xe4, 0x0e, 0x7a, 0xd7, 0x9e, 0x7b, 0xc7, 0xab, 0x7a, 0x85, 0xc0, 0xb3,
|
||||||
|
0x8f, 0x58, 0xd7, 0xad, 0x7a, 0xd7, 0xad, 0x7a, 0x87, 0xd0, 0x2b, 0x0e, 0x48,
|
||||||
|
0xd7, 0xad, 0x78, 0xf7, 0xbc, 0x7a, 0xb7, 0xa8, 0x4b, 0x88, 0x18, 0xd5, 0x8d,
|
||||||
|
0x6a, 0xa4, 0x98, 0x08, 0x00, 0x80, 0x88,
|
||||||
|
} ;
|
||||||
|
|
||||||
|
static const short test_pcm [] =
|
||||||
|
{ 32, 0, 32, 0, 32, 320, 880, -336, 2304, 4192, -992, 10128, 5360, -16352,
|
||||||
|
30208, 2272, -31872, 14688, -7040, -32432, 14128, -1392, -15488, 22960,
|
||||||
|
1232, -1584, 21488, -240, 2576, -15360, 960, -1152, -30032, 10320, 1008,
|
||||||
|
-30032, 16528, 1008, -30032, 16528, -5200, -30592, 15968, 448, -30592,
|
||||||
|
15968, 448, -2368, 30960, 3024, -80, 8384, 704, -1616, -29168, -1232, 1872,
|
||||||
|
-32768, 13792, -1728, -32768, 13792, 4480, -32192, 14368, -7360, -32752,
|
||||||
|
13808, -1712, -21456, 16992, 1472, -1344, 26848, -1088, 2016, -17728, 208,
|
||||||
|
-2112, -32768, 1376, -1728, -32768, 13792, -1728, -32768, 13792, -1728,
|
||||||
|
-32768, 13792, -1728, -32768, 13792, -1728, -4544, 32767, -1377, 1727,
|
||||||
|
15823, -2113, 207, -27345, 591, -2513, -32768, 13792, -1728, -32768, 13792,
|
||||||
|
10688, -31632, 14928, -6800, -32192, 14368, -1152, -20896, 17552, 2032,
|
||||||
|
-784, 22288, 560, -2256, -4816, 2176, 64, -21120, 9920, 6816, -24224, 16128,
|
||||||
|
608, -13488, 9584, 272, -2544, 16, -2304, -192, 1728, -16, 1568, 128, -1184,
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_oki_adpcm (void)
|
||||||
|
{
|
||||||
|
IMA_OKI_ADPCM adpcm ;
|
||||||
|
unsigned char code ;
|
||||||
|
int i, j ;
|
||||||
|
|
||||||
|
print_test_name ("Testing ima/oki encoder") ;
|
||||||
|
|
||||||
|
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
|
||||||
|
for (i = 0 ; i < ARRAY_LEN (test_codes) ; i++)
|
||||||
|
for (j = 0, code = test_codes [i] ; j < 2 ; j++, code <<= 4)
|
||||||
|
if (adpcm_decode (&adpcm, code >> 4) != test_pcm [2 * i + j])
|
||||||
|
{ printf ("\n\nFail at i = %d, j = %d.\n\n", i, j) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
puts ("ok") ;
|
||||||
|
|
||||||
|
print_test_name ("Testing ima/oki decoder") ;
|
||||||
|
|
||||||
|
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
|
||||||
|
for (i = 0 ; i < ARRAY_LEN (test_pcm) ; i += j)
|
||||||
|
{ code = adpcm_encode (&adpcm, test_pcm [i]) ;
|
||||||
|
code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ;
|
||||||
|
if (code != test_codes [i / 2])
|
||||||
|
{ printf ("\n\nFail at i = %d, %d should be %d\n\n", i, code, test_codes [i / 2]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
puts ("ok") ;
|
||||||
|
} /* test_oki_adpcm */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_oki_adpcm_block (void)
|
||||||
|
{
|
||||||
|
IMA_OKI_ADPCM adpcm ;
|
||||||
|
int k ;
|
||||||
|
|
||||||
|
if (ARRAY_LEN (adpcm.pcm) < ARRAY_LEN (test_pcm))
|
||||||
|
{ printf ("\n\nLine %d : ARRAY_LEN (adpcm->pcm) > ARRAY_LEN (test_pcm) (%d > %d).\n\n", __LINE__, ARRAY_LEN (adpcm.pcm), ARRAY_LEN (test_pcm)) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (ARRAY_LEN (adpcm.codes) < ARRAY_LEN (test_codes))
|
||||||
|
{ printf ("\n\nLine %d : ARRAY_LEN (adcodes->codes) > ARRAY_LEN (test_codes).n", __LINE__) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
print_test_name ("Testing ima/oki block encoder") ;
|
||||||
|
|
||||||
|
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
|
||||||
|
|
||||||
|
memcpy (adpcm.pcm, test_pcm, sizeof (adpcm.pcm [0]) * ARRAY_LEN (test_pcm)) ;
|
||||||
|
adpcm.pcm_count = ARRAY_LEN (test_pcm) ;
|
||||||
|
adpcm.code_count = 13 ;
|
||||||
|
|
||||||
|
ima_oki_adpcm_encode_block (&adpcm) ;
|
||||||
|
|
||||||
|
if (adpcm.code_count * 2 != ARRAY_LEN (test_pcm))
|
||||||
|
{ printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.code_count * 2, ARRAY_LEN (test_pcm)) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
for (k = 0 ; k < ARRAY_LEN (test_codes) ; k++)
|
||||||
|
if (adpcm.codes [k] != test_codes [k])
|
||||||
|
{ printf ("\n\nLine %d : Fail at k = %d, %d should be %d\n\n", __LINE__, k, adpcm.codes [k], test_codes [k]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
puts ("ok") ;
|
||||||
|
|
||||||
|
print_test_name ("Testing ima/oki block decoder") ;
|
||||||
|
|
||||||
|
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
|
||||||
|
|
||||||
|
memcpy (adpcm.codes, test_codes, sizeof (adpcm.codes [0]) * ARRAY_LEN (test_codes)) ;
|
||||||
|
adpcm.code_count = ARRAY_LEN (test_codes) ;
|
||||||
|
adpcm.pcm_count = 13 ;
|
||||||
|
|
||||||
|
ima_oki_adpcm_decode_block (&adpcm) ;
|
||||||
|
|
||||||
|
if (adpcm.pcm_count != 2 * ARRAY_LEN (test_codes))
|
||||||
|
{ printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.pcm_count, 2 * ARRAY_LEN (test_codes)) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
for (k = 0 ; k < ARRAY_LEN (test_pcm) ; k++)
|
||||||
|
if (adpcm.pcm [k] != test_pcm [k])
|
||||||
|
{ printf ("\n\nLine %d : Fail at i = %d, %d should be %d.\n\n", __LINE__, k, adpcm.pcm [k], test_pcm [k]) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
puts ("ok") ;
|
||||||
|
} /* test_oki_adpcm_block */
|
||||||
|
|
||||||
|
void
|
||||||
|
test_ima_oki_adpcm (void)
|
||||||
|
{
|
||||||
|
test_oki_adpcm () ;
|
||||||
|
test_oki_adpcm_block () ;
|
||||||
|
} /* main */
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2003-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
** Copyright (C) 2003-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify
|
** 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
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include "test_main.h"
|
||||||
|
|
||||||
#define CMP_0_ARGS(line,err,fmt) \
|
#define CMP_0_ARGS(line,err,fmt) \
|
||||||
{ psf->logindex = 0 ; \
|
{ psf->logindex = 0 ; \
|
||||||
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt)) ; \
|
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt)) ; \
|
||||||
@ -61,17 +63,29 @@
|
|||||||
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s3) ;
|
static int
|
||||||
|
compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s2)
|
||||||
|
{ int errors = 0 ;
|
||||||
|
/*-puts (s1) ;puts (s2) ;-*/
|
||||||
|
|
||||||
int
|
if (strcmp (s1, s2) != 0)
|
||||||
main (void)
|
{ printf ("\n\nLine %d: string compare mismatch:\n\t", linenum) ;
|
||||||
|
printf ("\"%s\"\n", fmt) ;
|
||||||
|
printf ("\t\"%s\"\n\t\"%s\"\n", s1, s2) ;
|
||||||
|
errors ++ ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return errors ;
|
||||||
|
} /* compare_strings_or_die */
|
||||||
|
|
||||||
|
void
|
||||||
|
test_log_printf (void)
|
||||||
{ static char buffer [2048] ;
|
{ static char buffer [2048] ;
|
||||||
SF_PRIVATE sf_private, *psf ;
|
SF_PRIVATE sf_private, *psf ;
|
||||||
int k, errors = 0 ;
|
int k, errors = 0 ;
|
||||||
int int_values [] = { 0, 1, 12, 123, 1234, 123456, -1, -12, -123, -1234, -123456 } ;
|
int int_values [] = { 0, 1, 12, 123, 1234, 123456, -1, -12, -123, -1234, -123456 } ;
|
||||||
|
|
||||||
printf (" %-24s : ", "psf_log_printf_test") ;
|
print_test_name ("Testing psf_log_printf") ;
|
||||||
fflush (stdout) ;
|
|
||||||
|
|
||||||
psf = &sf_private ;
|
psf = &sf_private ;
|
||||||
memset (psf, 0, sizeof (sf_private)) ;
|
memset (psf, 0, sizeof (sf_private)) ;
|
||||||
@ -105,29 +119,5 @@ main (void)
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
puts ("ok") ;
|
puts ("ok") ;
|
||||||
|
} /* test_log_printf */
|
||||||
|
|
||||||
return 0 ;
|
|
||||||
} /* main */
|
|
||||||
|
|
||||||
static int
|
|
||||||
compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s2)
|
|
||||||
{ int errors = 0 ;
|
|
||||||
/*-puts (s1) ;puts (s2) ;-*/
|
|
||||||
|
|
||||||
if (strcmp (s1, s2) != 0)
|
|
||||||
{ printf ("\n\nLine %d: string compare mismatch:\n\t", linenum) ;
|
|
||||||
printf ("\"%s\"\n", fmt) ;
|
|
||||||
printf ("\t\"%s\"\n\t\"%s\"\n", s1, s2) ;
|
|
||||||
errors ++ ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
return errors ;
|
|
||||||
} /* compare_strings_or_die */
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Do not edit or modify anything in this comment block.
|
|
||||||
** The arch-tag line is a file identity tag for the GNU Arch
|
|
||||||
** revision control system.
|
|
||||||
**
|
|
||||||
** arch-tag: 45147310-868b-400a-97e8-cc0a572a6270
|
|
||||||
*/
|
|
||||||
|
43
src/test_main.c
Normal file
43
src/test_main.c
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
** Copyright (C) 2008 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 <stdarg.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "test_main.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
test_conversions () ;
|
||||||
|
test_endswap () ;
|
||||||
|
|
||||||
|
test_log_printf () ;
|
||||||
|
test_file_io () ;
|
||||||
|
|
||||||
|
test_audio_detect () ;
|
||||||
|
test_ima_oki_adpcm () ;
|
||||||
|
|
||||||
|
return 0 ;
|
||||||
|
} /* main */
|
||||||
|
|
33
src/test_main.h
Normal file
33
src/test_main.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
** Copyright (C) 2008 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
print_test_name (const char * name)
|
||||||
|
{ printf (" %-40s : ", name) ;
|
||||||
|
fflush (stdout) ;
|
||||||
|
} /* print_test_name */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void test_conversions (void) ;
|
||||||
|
void test_endswap (void) ;
|
||||||
|
void test_log_printf (void) ;
|
||||||
|
void test_file_io (void) ;
|
||||||
|
|
||||||
|
void test_audio_detect (void) ;
|
||||||
|
void test_ima_oki_adpcm (void) ;
|
Loading…
Reference in New Issue
Block a user