mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-27 03:50:29 +00:00
Add test_endswap.
This commit is contained in:
parent
328931eff3
commit
2a117a2027
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2004-10-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/sfendian.h
|
||||
Improve type safety, add endswap_double_array().
|
||||
|
||||
* src/double64.c
|
||||
Use endswap_double_array() instead of endswap_long_array().
|
||||
|
||||
* src/test_endswap.(tpl|def) src/Makefile.am
|
||||
Add preliminary endswap tests and hook into build system.
|
||||
|
||||
2004-10-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/configure.ac src/makefile.am
|
||||
|
@ -8,8 +8,8 @@ include_HEADERS = sndfile.h
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
|
||||
EXTRA_DIST = sndfile.h.in config.h.in Symbols.linux Symbols.darwin \
|
||||
libsndfile.def create_symbols_file.py
|
||||
EXTRA_DIST = sndfile.h.in config.h.in test_endswap.tpl test_endswap.def \
|
||||
Symbols.linux Symbols.darwin libsndfile.def create_symbols_file.py
|
||||
|
||||
noinst_HEADERS = common.h sfendian.h float_cast.h wav_w64.h au.h sf_unistd.h
|
||||
|
||||
@ -28,23 +28,29 @@ libsndfile_la_LDFLAGS = -no-undefined -version-info @SHARED_VERSION_INFO@ @SHLIB
|
||||
libsndfile_la_SOURCES = $(COMMON) $(FILESPECIFIC) $(noinst_HEADERS) sndfile.h
|
||||
libsndfile_la_LIBADD = GSM610/libgsm.la G72x/libg72x.la -lm
|
||||
|
||||
test_endswap_SOURCES = test_endswap.c
|
||||
|
||||
test_file_io_CFLAGS = $(AM_CFLAGS)
|
||||
test_file_io_SOURCES = file_io.c test_file_io.c
|
||||
|
||||
test_log_printf_CFLAGS = $(AM_CFLAGS)
|
||||
test_log_printf_SOURCES = test_log_printf.c
|
||||
|
||||
test_endswap.c: test_endswap.def test_endswap.tpl
|
||||
autogen --writable --source-time test_endswap.def
|
||||
|
||||
# Two test programs.
|
||||
# It is not possible to place these in the tests/ directory because they
|
||||
# need access to the internals of the SF_PRIVATE struct.
|
||||
|
||||
check: test_file_io$(EXEEXT) test_log_printf$(EXEEXT)
|
||||
check: test_file_io test_log_printf
|
||||
@echo
|
||||
@echo
|
||||
@echo
|
||||
@echo "============================================================"
|
||||
./test_file_io$(EXEEXT)
|
||||
./test_log_printf$(EXEEXT)
|
||||
./test_endswap
|
||||
./test_file_io
|
||||
./test_log_printf
|
||||
@echo "============================================================"
|
||||
@echo
|
||||
@echo
|
||||
|
@ -2,20 +2,14 @@ autogen definitions test_endswap.tpl;
|
||||
|
||||
int_type = {
|
||||
name = short ;
|
||||
value = 0x3210 ;
|
||||
format = FMT_SHORT ;
|
||||
swapper = ENDSWAP_SHORT ;
|
||||
value = 0x0201 ;
|
||||
} ;
|
||||
|
||||
int_type = {
|
||||
name = int ;
|
||||
value = 0x76543210 ;
|
||||
format = FMT_INT ;
|
||||
} ;
|
||||
|
||||
int_type = {
|
||||
name = int64_t ;
|
||||
value = "0x0807050540302010LL" ;
|
||||
format = FMT_INT64 ;
|
||||
swapper = ENDSWAP_INT ;
|
||||
value = 0x04030201 ;
|
||||
} ;
|
||||
|
||||
/*
|
||||
|
@ -1,6 +1,6 @@
|
||||
[+ AutoGen5 template c +]
|
||||
/*
|
||||
** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2004 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
|
||||
@ -17,12 +17,12 @@
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@ -32,15 +32,6 @@
|
||||
#include "common.h"
|
||||
#include "sfendian.h"
|
||||
|
||||
#define FMT_SHORT "0x%04x\n"
|
||||
#define FMT_INT "0x%08x\n"
|
||||
|
||||
#if SIZEOF_INT64_T == SIZEOF_LONG
|
||||
#define FMT_INT64 "0x%016lx\n"
|
||||
#else
|
||||
#define FMT_INT64 "0x%016llx\n"
|
||||
#endif
|
||||
|
||||
[+ FOR int_type
|
||||
+]static void test_endswap_[+ (get "name") +] (void) ;
|
||||
[+ ENDFOR int_type
|
||||
@ -61,67 +52,52 @@ main (void)
|
||||
*/
|
||||
|
||||
[+ FOR int_type +]
|
||||
static void
|
||||
dump_[+ (get "name") +]_array (const char * name, [+ (get "name") +] * data, int datalen)
|
||||
{ int k ;
|
||||
|
||||
printf ("%-6s : ", name) ;
|
||||
for (k = 0 ; k < datalen ; k++)
|
||||
printf ([+ (get "format") +], data [k]) ;
|
||||
putchar ('\n') ;
|
||||
} /* dump_[+ (get "name") +]_array */
|
||||
|
||||
static void
|
||||
test_endswap_[+ (get "name") +] (void)
|
||||
{ [+ (get "name") +] orig [4], first [4], second [4] ;
|
||||
{ [+ (get "name") +] buffer [4] ;
|
||||
int k ;
|
||||
|
||||
printf (" %-24s : ", "test_endswap_[+ (get "name") +]") ;
|
||||
fflush (stdout) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (orig) ; k++)
|
||||
orig [k] = [+ (get "value") +] + k ;
|
||||
for (k = 0 ; k < ARRAY_LEN (buffer) ; k++)
|
||||
buffer [k] = [+ (get "value") +] + k ;
|
||||
|
||||
endswap_[+ (get "name") +]_copy (first, orig, ARRAY_LEN (first)) ;
|
||||
endswap_[+ (get "name") +]_copy (second, first, ARRAY_LEN (second)) ;
|
||||
endswap_[+ (get "name") +]_array (buffer, ARRAY_LEN (buffer)) ;
|
||||
|
||||
if (memcmp (orig, first, sizeof (orig)) == 0)
|
||||
{ printf ("\n\nLine %d : test 1 : these two array should not be the same:\n\n", __LINE__) ;
|
||||
dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ;
|
||||
dump_[+ (get "name") +]_array ("first", first, ARRAY_LEN (first)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
for (k = 0 ; k < ARRAY_LEN (buffer) ; k++)
|
||||
if (buffer [k] == k + 1 || buffer [k] != [+ (get "swapper") +] ([+ (get "value") +] + k))
|
||||
{ printf ("\n\nLine %d : \n\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (memcmp (orig, second, sizeof (orig)) != 0)
|
||||
{ printf ("\n\nLine %d : test 2 : these two array should be the same:\n\n", __LINE__) ;
|
||||
dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ;
|
||||
dump_[+ (get "name") +]_array ("second", second, ARRAY_LEN (second)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
endswap_[+ (get "name") +]_array (buffer, ARRAY_LEN (buffer)) ;
|
||||
|
||||
endswap_[+ (get "name") +]_array (first, ARRAY_LEN (first)) ;
|
||||
for (k = 0 ; k < ARRAY_LEN (buffer) ; k++)
|
||||
if (buffer [k] != [+ (get "value") +] + k)
|
||||
{ printf ("\n\nLine %d : \n\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (memcmp (orig, first, sizeof (orig)) != 0)
|
||||
{ printf ("\n\nLine %d : test 3 : these two array should be the same:\n\n", __LINE__) ;
|
||||
dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ;
|
||||
dump_[+ (get "name") +]_array ("first", first, ARRAY_LEN (first)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
endswap_[+ (get "name") +]_copy (buffer, buffer, ARRAY_LEN (buffer)) ;
|
||||
|
||||
endswap_[+ (get "name") +]_copy (first, orig, ARRAY_LEN (first)) ;
|
||||
endswap_[+ (get "name") +]_copy (first, first, ARRAY_LEN (first)) ;
|
||||
for (k = 0 ; k < ARRAY_LEN (buffer) ; k++)
|
||||
if (buffer [k] == k + 1 || buffer [k] != [+ (get "swapper") +] ([+ (get "value") +] + k))
|
||||
{ printf ("\n\nLine %d : \n\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (memcmp (orig, first, sizeof (orig)) != 0)
|
||||
{ printf ("\n\nLine %d : test 4 : these two array should be the same:\n\n", __LINE__) ;
|
||||
dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ;
|
||||
dump_[+ (get "name") +]_array ("first", first, ARRAY_LEN (first)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
endswap_[+ (get "name") +]_copy (buffer, buffer, ARRAY_LEN (buffer)) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (buffer) ; k++)
|
||||
if (buffer [k] != [+ (get "value") +] + k)
|
||||
{ printf ("\n\nLine %d : \n\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
puts ("ok") ;
|
||||
} /* test_endswap_[+ (get "name") +] */
|
||||
[+ ENDFOR int_type
|
||||
+]
|
||||
[+ ENDFOR int_type +]
|
||||
|
||||
|
||||
[+ COMMENT
|
||||
|
Loading…
Reference in New Issue
Block a user