From 9ebb45d145efce4d3d3484dc249f1934bf6b9884 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 1 Sep 2003 15:08:15 +0000 Subject: [PATCH] Add minimal test of new iso9660 library. --- test/Makefile.am | 9 ++-- test/testiso9660.c | 130 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 test/testiso9660.c diff --git a/test/Makefile.am b/test/Makefile.am index 11e1baf7..9e4e2ae7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.5 2003/08/17 06:32:45 rocky Exp $ +# $Id: Makefile.am,v 1.6 2003/09/01 15:08:15 rocky Exp $ # # Copyright (C) 2003 Rocky Bernstein # @@ -20,17 +20,18 @@ # Things to regression testing #################################################### # -noinst_PROGRAMS = testassert testischar check_sizeof +noinst_PROGRAMS = testassert testischar testiso9660 check_sizeof INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) testassert_LDADD = $(LIBCDIO_LIBS) testischar_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) +testiso9660_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) check_sizeof_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) check_SCRIPTS = check_nrg.sh check_cue.sh check_opts.sh -check_PROGRAMS = testischar testassert +check_PROGRAMS = testischar testassert testiso9660 check_DATA = vcd_demo.right \ videocd.right videocd.nrg \ @@ -44,6 +45,6 @@ EXTRA_DIST = $(check_SCRIPTS) $(check_DATA) \ check_common_fn check_cue.sh.in check_nrg.sh.in TESTS_ENVIRONMENT=$(SHELL) -TESTS = testischar check_sizeof $(check_SCRIPTS) +TESTS = testischar testiso9660 check_sizeof $(check_SCRIPTS) MOSTLYCLEANFILES = core.* *.dump diff --git a/test/testiso9660.c b/test/testiso9660.c new file mode 100644 index 00000000..f18bca99 --- /dev/null +++ b/test/testiso9660.c @@ -0,0 +1,130 @@ +/* + $Id: testiso9660.c,v 1.1 2003/09/01 15:08:15 rocky Exp $ + + Copyright (C) 2003 Rocky Bernstein + + 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 +*/ +/* Tests ISO9660 library routines. */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#include + +int +main (int argc, const char *argv[]) +{ + int c; + int i; + char dst[100]; + char *dst_p; + int achars[] = {'!', '"', '%', '&', '(', ')', '*', '+', ',', '-', '.', + '/', '?', '<', '=', '>'}; + + + for (c='A'; c<='Z'; c++ ) { + if (!iso9660_isdchar(c)) { + printf("Failed iso9660_isdchar test on %d\n", c); + return c; + } + if (!iso9660_isachar(c)) { + printf("Failed iso9660_isachar test on %d\n", c); + return c; + } + } + for (c='0'; c<='9'; c++ ) { + if (!iso9660_isdchar(c)) { + printf("Failed iso9660_isdchar test on %d\n", c); + return c; + } + if (!iso9660_isachar(c)) { + printf("Failed iso9660_isachar test on %d\n", c); + return c; + } + } + + for (i=0; i<=13; i++ ) { + c=achars[i]; + if (iso9660_isdchar(c)) { + printf("Should not pass iso9660_isdchar test on %d\n", c); + return c; + } + if (!iso9660_isachar(c)) { + printf("Failed iso9660_isachar test on symbol %d\n", c); + return c; + } + } + + /* Test iso9660_strncpy_pad */ + dst_p = iso9660_strncpy_pad(dst, "1_3", 5, ISO9660_DCHARS); + if ( 0 != strncmp(dst, "1_3 ", 5) ) { + printf("Failed iso9660_strncpy_pad test 1\n"); + return 1; + } + dst_p = iso9660_strncpy_pad(dst, "ABC!123", 2, ISO9660_ACHARS); + if ( 0 != strncmp(dst, "AB", 2) ) { + printf("Failed iso9660_strncpy_pad test 2\n"); + return 2; + } + + /* Test iso9660_dirname_valid_p */ + if ( iso9660_dirname_valid_p("/NOGOOD") ) { + printf("/NOGOOD should fail iso9660_dirname_valid_p\n"); + return 3; + } + if ( iso9660_dirname_valid_p("LONGDIRECTORY/NOGOOD") ) { + printf("LONGDIRECTORY/NOGOOD should fail iso9660_dirname_valid_p\n"); + return 4; + } + if ( !iso9660_dirname_valid_p("OKAY/DIR") ) { + printf("OKAY/DIR should pass iso9660_dirname_valid_p\n"); + return 5; + } + if ( iso9660_dirname_valid_p("OKAY/FILE.EXT") ) { + printf("OKAY/FILENAME.EXT should fail iso9660_dirname_valid_p\n"); + return 6; + } + + /* Test iso9660_pathname_valid_p */ + if ( !iso9660_pathname_valid_p("OKAY/FILE.EXT") ) { + printf("OKAY/FILE.EXT should pass iso9660_dirname_valid_p\n"); + return 7; + } + if ( iso9660_pathname_valid_p("OKAY/FILENAMETOOLONG.EXT") ) { + printf("OKAY/FILENAMETOOLONG.EXT should fail iso9660_dirname_valid_p\n"); + return 8; + } + if ( iso9660_pathname_valid_p("OKAY/FILE.LONGEXT") ) { + printf("OKAY/FILE.LONGEXT should fail iso9660_dirname_valid_p\n"); + return 9; + } + + dst_p = iso9660_pathname_isofy ("this/file.ext", 1); + if ( 0 != strncmp(dst_p, "this/file.ext;1", 16) ) { + printf("Failed iso9660_pathname_isofy\n"); + return 10; + } + + return 0; +}