add yet more tests

This commit is contained in:
Josh Coalson
2002-05-31 06:27:05 +00:00
parent adfaff398d
commit aa2a7ecfd9
10 changed files with 503 additions and 531 deletions

View File

@@ -22,11 +22,18 @@ noinst_PROGRAMS = test_unit
test_unit_LDADD = $(top_builddir)/src/libFLAC/libFLAC.la -lm
test_unit_SOURCES = \
bitbuffer.c \
decoders.c \
file_decoder.c \
file_utils.c \
main.c \
metadata.c \
metadata_manip.c \
metadata_object.c \
metadata_utils.c \
seekable_stream_decoder.c \
stream_decoder.c \
bitbuffer.h \
metadata.h
decoders.h \
file_utils.h \
metadata.h \
metadata_utils.h

View File

@@ -21,15 +21,19 @@
PROGRAM_NAME = test_unit
INCLUDES = -I../libFLAC/include -I../../include
LIBS = -lFLAC -lm
LIBS = -lFLAC -lm -lefence
OBJS = \
bitbuffer.o \
decoders.o \
file_decoder.o \
file_utils.o \
main.o \
metadata.o \
metadata_manip.o \
metadata_object.o \
metadata_utils.o
metadata_utils.o \
stream_decoder.o \
seekable_stream_decoder.o
include ../../build/exe.mk

View File

@@ -27,12 +27,16 @@
C_FILES= \
bitbuffer.c \
decoders.c \
file_decoder.c \
file_utils.c \
main.c \
metadata.c \
metadata_manip.c \
metadata_object.c \
metadata_utils.c
metadata_utils.c \
seekable_stream_decoder.c \
stream_decoder.c
OBJS= $(C_FILES:.c=.obj)

40
src/test_unit/decoders.c Normal file
View 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
View 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

View File

@@ -17,6 +17,7 @@
*/
#include "bitbuffer.h"
#include "decoders.h"
#include "metadata.h"
int main(int argc, char *argv[])
@@ -29,5 +30,10 @@ int main(int argc, char *argv[])
if(0 != test_metadata())
return 1;
if(0 != test_decoders())
return 1;
/* the encoder is tested relatively well in the file_utils */
return 0;
}

View File

@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "FLAC/metadata.h"
#include "metadata.h"
#include <stdio.h>
extern int test_metadata_object();

View File

@@ -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))
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 true;

File diff suppressed because it is too large Load Diff

View File

@@ -126,14 +126,22 @@ FLAC__bool compare_block_data_application_(const FLAC__StreamMetaData_Applicatio
);
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) {
printf("FAILED, data mismatch (%s's data pointer is null)\n", 0==block->data?"original":"copy");
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 {
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");
return false;
}
@@ -178,7 +186,7 @@ FLAC__bool compare_block_data_vorbiscomment_(const FLAC__StreamMetaData_VorbisCo
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");
return false;
}