mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
add yet more tests
This commit is contained in:
@@ -22,11 +22,18 @@ noinst_PROGRAMS = test_unit
|
|||||||
test_unit_LDADD = $(top_builddir)/src/libFLAC/libFLAC.la -lm
|
test_unit_LDADD = $(top_builddir)/src/libFLAC/libFLAC.la -lm
|
||||||
test_unit_SOURCES = \
|
test_unit_SOURCES = \
|
||||||
bitbuffer.c \
|
bitbuffer.c \
|
||||||
|
decoders.c \
|
||||||
|
file_decoder.c \
|
||||||
file_utils.c \
|
file_utils.c \
|
||||||
main.c \
|
main.c \
|
||||||
metadata.c \
|
metadata.c \
|
||||||
metadata_manip.c \
|
metadata_manip.c \
|
||||||
metadata_object.c \
|
metadata_object.c \
|
||||||
metadata_utils.c \
|
metadata_utils.c \
|
||||||
|
seekable_stream_decoder.c \
|
||||||
|
stream_decoder.c \
|
||||||
bitbuffer.h \
|
bitbuffer.h \
|
||||||
metadata.h
|
decoders.h \
|
||||||
|
file_utils.h \
|
||||||
|
metadata.h \
|
||||||
|
metadata_utils.h
|
||||||
|
|||||||
@@ -21,15 +21,19 @@
|
|||||||
|
|
||||||
PROGRAM_NAME = test_unit
|
PROGRAM_NAME = test_unit
|
||||||
INCLUDES = -I../libFLAC/include -I../../include
|
INCLUDES = -I../libFLAC/include -I../../include
|
||||||
LIBS = -lFLAC -lm
|
LIBS = -lFLAC -lm -lefence
|
||||||
OBJS = \
|
OBJS = \
|
||||||
bitbuffer.o \
|
bitbuffer.o \
|
||||||
|
decoders.o \
|
||||||
|
file_decoder.o \
|
||||||
file_utils.o \
|
file_utils.o \
|
||||||
main.o \
|
main.o \
|
||||||
metadata.o \
|
metadata.o \
|
||||||
metadata_manip.o \
|
metadata_manip.o \
|
||||||
metadata_object.o \
|
metadata_object.o \
|
||||||
metadata_utils.o
|
metadata_utils.o \
|
||||||
|
stream_decoder.o \
|
||||||
|
seekable_stream_decoder.o
|
||||||
|
|
||||||
include ../../build/exe.mk
|
include ../../build/exe.mk
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,16 @@
|
|||||||
|
|
||||||
C_FILES= \
|
C_FILES= \
|
||||||
bitbuffer.c \
|
bitbuffer.c \
|
||||||
|
decoders.c \
|
||||||
|
file_decoder.c \
|
||||||
file_utils.c \
|
file_utils.c \
|
||||||
main.c \
|
main.c \
|
||||||
metadata.c \
|
metadata.c \
|
||||||
metadata_manip.c \
|
metadata_manip.c \
|
||||||
metadata_object.c \
|
metadata_object.c \
|
||||||
metadata_utils.c
|
metadata_utils.c \
|
||||||
|
seekable_stream_decoder.c \
|
||||||
|
stream_decoder.c
|
||||||
|
|
||||||
OBJS= $(C_FILES:.c=.obj)
|
OBJS= $(C_FILES:.c=.obj)
|
||||||
|
|
||||||
|
|||||||
40
src/test_unit/decoders.c
Normal file
40
src/test_unit/decoders.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* test_unit - Simple FLAC unit tester
|
||||||
|
* Copyright (C) 2002 Josh Coalson
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU 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 "decoders.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern int test_file_decoder();
|
||||||
|
extern int test_seekable_stream_decoder();
|
||||||
|
extern int test_stream_decoder();
|
||||||
|
|
||||||
|
int test_decoders()
|
||||||
|
{
|
||||||
|
if(0 != test_stream_decoder())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(0 != test_seekable_stream_decoder())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(0 != test_file_decoder())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
printf("\nPASSED!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
24
src/test_unit/decoders.h
Normal file
24
src/test_unit/decoders.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/* test_unit - Simple FLAC unit tester
|
||||||
|
* Copyright (C) 2002 Josh Coalson
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FLAC__TEST_UNIT_DECODERS_H
|
||||||
|
#define FLAC__TEST_UNIT_DECODERS_H
|
||||||
|
|
||||||
|
int test_decoders();
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bitbuffer.h"
|
#include "bitbuffer.h"
|
||||||
|
#include "decoders.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -29,5 +30,10 @@ int main(int argc, char *argv[])
|
|||||||
if(0 != test_metadata())
|
if(0 != test_metadata())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if(0 != test_decoders())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* the encoder is tested relatively well in the file_utils */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FLAC/metadata.h"
|
#include "metadata.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern int test_metadata_object();
|
extern int test_metadata_object();
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ static FLAC__bool generate_file_()
|
|||||||
if(!insert_to_our_metadata_(&streaminfo, 0, /*copy=*/true) || !insert_to_our_metadata_(&padding, 1, /*copy=*/true))
|
if(!insert_to_our_metadata_(&streaminfo, 0, /*copy=*/true) || !insert_to_our_metadata_(&padding, 1, /*copy=*/true))
|
||||||
return die_("priming our metadata");
|
return die_("priming our metadata");
|
||||||
|
|
||||||
if(!file_utils__generate_file(flacfile_, 512 * 1024, &streaminfo, padding.length))
|
if(!file_utils__generate_flacfile(flacfile_, 512 * 1024, &streaminfo, padding.length))
|
||||||
return die_("creating the encoded file");
|
return die_("creating the encoded file");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -126,14 +126,22 @@ FLAC__bool compare_block_data_application_(const FLAC__StreamMetaData_Applicatio
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(block_length - sizeof(block->id) > 0 && (0 == block->data || 0 == blockcopy->data)) {
|
if(0 == block->data || 0 == blockcopy->data) {
|
||||||
if(block->data != blockcopy->data) {
|
if(block->data != blockcopy->data) {
|
||||||
printf("FAILED, data mismatch (%s's data pointer is null)\n", 0==block->data?"original":"copy");
|
printf("FAILED, data mismatch (%s's data pointer is null)\n", 0==block->data?"original":"copy");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if(block_length - sizeof(block->id) > 0) {
|
||||||
|
printf("FAILED, data pointer is null but block length is not 0\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(0 != memcmp(blockcopy->data, block->data, block_length - sizeof(block->id))) {
|
if(block_length - sizeof(block->id) == 0) {
|
||||||
|
printf("FAILED, data pointer is not null but block length is 0\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(0 != memcmp(blockcopy->data, block->data, block_length - sizeof(block->id))) {
|
||||||
printf("FAILED, data mismatch\n");
|
printf("FAILED, data mismatch\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -178,7 +186,7 @@ FLAC__bool compare_block_data_vorbiscomment_(const FLAC__StreamMetaData_VorbisCo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(0 != memcmp(blockcopy->vendor_string.entry, block->vendor_string.entry, block->vendor_string.length)) {
|
else if(0 != memcmp(blockcopy->vendor_string.entry, block->vendor_string.entry, block->vendor_string.length)) {
|
||||||
printf("FAILED, vendor_string.entry mismatch\n");
|
printf("FAILED, vendor_string.entry mismatch\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user