diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-09-17 08:44:51 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-09-17 08:44:51 +0000 |
commit | 1c299d5a5c493986ca4a19bd55a69281dabada86 (patch) | |
tree | dae18913a2261a157ba32308ef804050e1232542 /libs/taglib/tests | |
parent | 8e9a83dfdc233898e7c470667c7c9b797c83fe8b (diff) |
merge Sakari's (sbergen) branch back into 3.0, removing libsndfile and adding taglib
git-svn-id: svn://localhost/ardour2/branches/3.0@3736 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/taglib/tests')
25 files changed, 1760 insertions, 0 deletions
diff --git a/libs/taglib/tests/CMakeLists.txt b/libs/taglib/tests/CMakeLists.txt new file mode 100644 index 0000000000..88c08098e1 --- /dev/null +++ b/libs/taglib/tests/CMakeLists.txt @@ -0,0 +1,35 @@ +if(BUILD_TESTS) + +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/toolkit + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v1 + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2 + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg/id3v2/frames + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mpeg + ${CMAKE_CURRENT_SOURCE_DIR}/../taglib/trueaudio +) + +SET(test_runner_SRCS + main.cpp + test_list.cpp + test_map.cpp + test_mpeg.cpp + test_synchdata.cpp + test_trueaudio.cpp + test_bytevector.cpp + test_string.cpp + test_fileref.cpp + test_id3v1.cpp + test_id3v2.cpp +) + +ADD_EXECUTABLE(test_runner ${test_runner_SRCS}) +TARGET_LINK_LIBRARIES(test_runner tag ${CPPUNIT_LIBRARIES}) + +ADD_CUSTOM_TARGET(check + ./test_runner + DEPENDS test_runner +) + +endif(BUILD_TESTS) diff --git a/libs/taglib/tests/Makefile.am b/libs/taglib/tests/Makefile.am new file mode 100644 index 0000000000..65191808b9 --- /dev/null +++ b/libs/taglib/tests/Makefile.am @@ -0,0 +1,27 @@ +INCLUDES = \ + -I$(top_srcdir)/taglib\ + -I$(top_srcdir)/taglib/toolkit \ + -I$(top_srcdir)/taglib/trueaudio \ + -I$(top_srcdir)/taglib/mpeg \ + -I$(top_srcdir)/taglib/mpeg/id3v1 \ + -I$(top_srcdir)/taglib/mpeg/id3v2 \ + -I$(top_srcdir)/taglib/mpeg/id3v2/frames + +test_runner_SOURCES = \ + main.cpp \ + test_list.cpp \ + test_map.cpp \ + test_mpeg.cpp \ + test_synchdata.cpp \ + test_trueaudio.cpp \ + test_bytevector.cpp \ + test_string.cpp \ + test_fileref.cpp \ + test_id3v1.cpp \ + test_id3v2.cpp + +if build_tests +TESTS = test_runner +check_PROGRAMS = test_runner +LDADD = ../taglib/libtag.la -lcppunit +endif diff --git a/libs/taglib/tests/Makefile.in b/libs/taglib/tests/Makefile.in new file mode 100644 index 0000000000..4e6d32d5c6 --- /dev/null +++ b/libs/taglib/tests/Makefile.in @@ -0,0 +1,699 @@ +# Makefile.in generated by automake 1.10 from Makefile.am. +# KDE tags expanded automatically by am_edit - $Revision: 483858 $ +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@build_tests_TRUE@TESTS = test_runner$(EXEEXT) +@build_tests_TRUE@check_PROGRAMS = test_runner$(EXEEXT) +subdir = tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_test_runner_OBJECTS = main.$(OBJEXT) test_list.$(OBJEXT) \ + test_map.$(OBJEXT) test_mpeg.$(OBJEXT) \ + test_synchdata.$(OBJEXT) test_trueaudio.$(OBJEXT) \ + test_bytevector.$(OBJEXT) test_string.$(OBJEXT) \ + test_fileref.$(OBJEXT) test_id3v1.$(OBJEXT) \ + test_id3v2.$(OBJEXT) +#>- test_runner_OBJECTS = $(am_test_runner_OBJECTS) +#>+ 9 +test_runner_final_OBJECTS = test_runner.all_cpp.o +test_runner_nofinal_OBJECTS = main.$(OBJEXT) test_list.$(OBJEXT) \ + test_map.$(OBJEXT) test_mpeg.$(OBJEXT) \ + test_synchdata.$(OBJEXT) test_trueaudio.$(OBJEXT) \ + test_bytevector.$(OBJEXT) test_string.$(OBJEXT) \ + test_fileref.$(OBJEXT) test_id3v1.$(OBJEXT) \ + test_id3v2.$(OBJEXT) +@KDE_USE_FINAL_FALSE@test_runner_OBJECTS = $(test_runner_nofinal_OBJECTS) +@KDE_USE_FINAL_TRUE@test_runner_OBJECTS = $(test_runner_final_OBJECTS) +test_runner_LDADD = $(LDADD) +@build_tests_TRUE@test_runner_DEPENDENCIES = ../taglib/libtag.la +DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/admin/depcomp +am__depfiles_maybe = depfiles +#>- CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ +#>- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +#>+ 2 +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) +#>- LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ +#>- --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ +#>- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +#>+ 3 +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) +CXXLD = $(CXX) +#>- CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ +#>- --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ +#>- $(LDFLAGS) -o $@ +#>+ 3 +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(test_runner_SOURCES) +DIST_SOURCES = $(test_runner_SOURCES) +ETAGS = etags +CTAGS = ctags +#>- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +#>+ 1 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTODIRS = @AUTODIRS@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONF_FILES = @CONF_FILES@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_PERMISSIVE_FLAG = @ENABLE_PERMISSIVE_FLAG@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +HAVE_GCC_VISIBILITY = @HAVE_GCC_VISIBILITY@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDE_CHECK_PLUGIN = @KDE_CHECK_PLUGIN@ +KDE_NO_UNDEFINED = @KDE_NO_UNDEFINED@ +KDE_PLUGIN = @KDE_PLUGIN@ +KDE_USE_CLOSURE_FALSE = @KDE_USE_CLOSURE_FALSE@ +KDE_USE_CLOSURE_TRUE = @KDE_USE_CLOSURE_TRUE@ +KDE_USE_FINAL_FALSE = @KDE_USE_FINAL_FALSE@ +KDE_USE_FINAL_TRUE = @KDE_USE_FINAL_TRUE@ +KDE_USE_NMCHECK_FALSE = @KDE_USE_NMCHECK_FALSE@ +KDE_USE_NMCHECK_TRUE = @KDE_USE_NMCHECK_TRUE@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_AS_NEEDED = @LDFLAGS_AS_NEEDED@ +LDFLAGS_NEW_DTAGS = @LDFLAGS_NEW_DTAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NOOPT_CFLAGS = @NOOPT_CFLAGS@ +NOOPT_CXXFLAGS = @NOOPT_CXXFLAGS@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TOPSUBDIRS = @TOPSUBDIRS@ +USE_EXCEPTIONS = @USE_EXCEPTIONS@ +USE_RTTI = @USE_RTTI@ +VERSION = @VERSION@ +WOVERLOADED_VIRTUAL = @WOVERLOADED_VIRTUAL@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +all_includes = @all_includes@ +all_libraries = @all_libraries@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = \ + -I$(top_srcdir)/taglib\ + -I$(top_srcdir)/taglib/toolkit \ + -I$(top_srcdir)/taglib/trueaudio \ + -I$(top_srcdir)/taglib/mpeg \ + -I$(top_srcdir)/taglib/mpeg/id3v1 \ + -I$(top_srcdir)/taglib/mpeg/id3v2 \ + -I$(top_srcdir)/taglib/mpeg/id3v2/frames + +test_runner_SOURCES = \ + main.cpp \ + test_list.cpp \ + test_map.cpp \ + test_mpeg.cpp \ + test_synchdata.cpp \ + test_trueaudio.cpp \ + test_bytevector.cpp \ + test_string.cpp \ + test_fileref.cpp \ + test_id3v1.cpp \ + test_id3v2.cpp + +@build_tests_TRUE@LDADD = ../taglib/libtag.la -lcppunit +#>- all: all-am +#>+ 1 +all: docs-am all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +#>- @for dep in $?; do \ +#>- case '$(am__configure_deps)' in \ +#>- *$$dep*) \ +#>- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ +#>- && exit 0; \ +#>- exit 1;; \ +#>- esac; \ +#>- done; \ +#>- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ +#>- cd $(top_srcdir) && \ +#>- $(AUTOMAKE) --gnu tests/Makefile +#>+ 12 + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile + cd $(top_srcdir) && perl admin/am_edit tests/Makefile.in +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +test_runner$(EXEEXT): $(test_runner_OBJECTS) $(test_runner_DEPENDENCIES) + @rm -f test_runner$(EXEEXT) + $(CXXLINK) $(test_runner_OBJECTS) $(test_runner_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_bytevector.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_fileref.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_id3v1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_id3v2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_list.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_map.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_mpeg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_string.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_synchdata.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_trueaudio.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +#>- clean: clean-am +#>+ 1 +clean: kde-rpo-clean clean-am + +#>- clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ +#>- mostlyclean-am +#>+ 2 +clean-am: clean-bcheck clean-final clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: + +#>+ 2 +KDE_DIST=utils.h Makefile.in CMakeLists.txt Makefile.am + +#>+ 2 +docs-am: + +#>+ 15 +force-reedit: + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile + cd $(top_srcdir) && perl admin/am_edit tests/Makefile.in + + +#>+ 21 +clean-bcheck: + rm -f *.bchecktest.cc *.bchecktest.cc.class a.out + +bcheck: bcheck-am + +bcheck-am: + @for i in ; do \ + if test $(srcdir)/$$i -nt $$i.bchecktest.cc; then \ + echo "int main() {return 0;}" > $$i.bchecktest.cc ; \ + echo "#include \"$$i\"" >> $$i.bchecktest.cc ; \ + echo "$$i"; \ + if ! $(CXXCOMPILE) --dump-class-hierarchy -c $$i.bchecktest.cc; then \ + rm -f $$i.bchecktest.cc; exit 1; \ + fi ; \ + echo "" >> $$i.bchecktest.cc.class; \ + perl $(top_srcdir)/admin/bcheck.pl $$i.bchecktest.cc.class || { rm -f $$i.bchecktest.cc; exit 1; }; \ + rm -f a.out; \ + fi ; \ + done + + +#>+ 11 +test_runner.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/main.cpp $(srcdir)/test_list.cpp $(srcdir)/test_map.cpp $(srcdir)/test_mpeg.cpp $(srcdir)/test_synchdata.cpp $(srcdir)/test_trueaudio.cpp $(srcdir)/test_bytevector.cpp $(srcdir)/test_string.cpp $(srcdir)/test_fileref.cpp $(srcdir)/test_id3v1.cpp $(srcdir)/test_id3v2.cpp + @echo 'creating test_runner.all_cpp.cpp ...'; \ + rm -f test_runner.all_cpp.files test_runner.all_cpp.final; \ + echo "#define KDE_USE_FINAL 1" >> test_runner.all_cpp.final; \ + for file in main.cpp test_list.cpp test_map.cpp test_mpeg.cpp test_synchdata.cpp test_trueaudio.cpp test_bytevector.cpp test_string.cpp test_fileref.cpp test_id3v1.cpp test_id3v2.cpp ; do \ + echo "#include \"$$file\"" >> test_runner.all_cpp.files; \ + test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> test_runner.all_cpp.final; \ + done; \ + cat test_runner.all_cpp.final test_runner.all_cpp.files > test_runner.all_cpp.cpp; \ + rm -f test_runner.all_cpp.final test_runner.all_cpp.files + +#>+ 3 +clean-final: + -rm -f test_runner.all_cpp.cpp + +#>+ 3 +final: + $(MAKE) test_runner_OBJECTS="$(test_runner_final_OBJECTS)" all-am + +#>+ 3 +final-install: + $(MAKE) test_runner_OBJECTS="$(test_runner_final_OBJECTS)" install-am + +#>+ 3 +no-final: + $(MAKE) test_runner_OBJECTS="$(test_runner_nofinal_OBJECTS)" all-am + +#>+ 3 +no-final-install: + $(MAKE) test_runner_OBJECTS="$(test_runner_nofinal_OBJECTS)" install-am + +#>+ 3 +kde-rpo-clean: + -rm -f *.rpo + +#>+ 3 +nmcheck: +nmcheck-am: nmcheck diff --git a/libs/taglib/tests/data/005411.id3 b/libs/taglib/tests/data/005411.id3 Binary files differnew file mode 100644 index 0000000000..ab2e0997a0 --- /dev/null +++ b/libs/taglib/tests/data/005411.id3 diff --git a/libs/taglib/tests/data/broken-tenc.id3 b/libs/taglib/tests/data/broken-tenc.id3 Binary files differnew file mode 100644 index 0000000000..809040506f --- /dev/null +++ b/libs/taglib/tests/data/broken-tenc.id3 diff --git a/libs/taglib/tests/data/click.mpc b/libs/taglib/tests/data/click.mpc Binary files differnew file mode 100644 index 0000000000..a41f14e9ea --- /dev/null +++ b/libs/taglib/tests/data/click.mpc diff --git a/libs/taglib/tests/data/empty.ogg b/libs/taglib/tests/data/empty.ogg Binary files differnew file mode 100644 index 0000000000..aa533104d6 --- /dev/null +++ b/libs/taglib/tests/data/empty.ogg diff --git a/libs/taglib/tests/data/empty.spx b/libs/taglib/tests/data/empty.spx Binary files differnew file mode 100644 index 0000000000..70572b4587 --- /dev/null +++ b/libs/taglib/tests/data/empty.spx diff --git a/libs/taglib/tests/data/empty.tta b/libs/taglib/tests/data/empty.tta Binary files differnew file mode 100644 index 0000000000..9cc00ba815 --- /dev/null +++ b/libs/taglib/tests/data/empty.tta diff --git a/libs/taglib/tests/data/mpeg2.mp3 b/libs/taglib/tests/data/mpeg2.mp3 Binary files differnew file mode 100644 index 0000000000..13e8d53df6 --- /dev/null +++ b/libs/taglib/tests/data/mpeg2.mp3 diff --git a/libs/taglib/tests/data/no-tags.flac b/libs/taglib/tests/data/no-tags.flac Binary files differnew file mode 100644 index 0000000000..4171441676 --- /dev/null +++ b/libs/taglib/tests/data/no-tags.flac diff --git a/libs/taglib/tests/data/unsynch.id3 b/libs/taglib/tests/data/unsynch.id3 Binary files differnew file mode 100644 index 0000000000..cfe6ee1a6f --- /dev/null +++ b/libs/taglib/tests/data/unsynch.id3 diff --git a/libs/taglib/tests/data/xing.mp3 b/libs/taglib/tests/data/xing.mp3 Binary files differnew file mode 100644 index 0000000000..0c880151b6 --- /dev/null +++ b/libs/taglib/tests/data/xing.mp3 diff --git a/libs/taglib/tests/main.cpp b/libs/taglib/tests/main.cpp new file mode 100644 index 0000000000..348751e44c --- /dev/null +++ b/libs/taglib/tests/main.cpp @@ -0,0 +1,46 @@ +#include <stdexcept> +#include <cppunit/TestResult.h> +#include <cppunit/TestResultCollector.h> +#include <cppunit/TestRunner.h> +#include <cppunit/extensions/TestFactoryRegistry.h> +#include <cppunit/BriefTestProgressListener.h> +#include <cppunit/CompilerOutputter.h> + +int main(int argc, char* argv[]) +{ + std::string testPath = (argc > 1) ? std::string(argv[1]) : ""; + + // Create the event manager and test controller + CppUnit::TestResult controller; + + // Add a listener that colllects test result + CppUnit::TestResultCollector result; + controller.addListener(&result); + + // Add a listener that print dots as test run. + CppUnit::BriefTestProgressListener progress; + controller.addListener(&progress); + + // Add the top suite to the test runner + CppUnit::TestRunner runner; + runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); + + try { + std::cout << "Running " << testPath; + runner.run(controller, testPath); + + std::cerr << std::endl; + + // Print test in a compiler compatible format. + CppUnit::CompilerOutputter outputter(&result, std::cerr); + outputter.write(); + } + catch(std::invalid_argument &e){ + std::cerr << std::endl + << "ERROR: " << e.what() + << std::endl; + return 0; + } + + return result.wasSuccessful() ? 0 : 1; +} diff --git a/libs/taglib/tests/test_bytevector.cpp b/libs/taglib/tests/test_bytevector.cpp new file mode 100644 index 0000000000..f92fce0173 --- /dev/null +++ b/libs/taglib/tests/test_bytevector.cpp @@ -0,0 +1,178 @@ +/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <cppunit/extensions/HelperMacros.h> +#include <tbytevector.h> +#include <tbytevectorlist.h> + +using namespace std; +using namespace TagLib; + +class TestByteVector : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestByteVector); + CPPUNIT_TEST(testByteVector); + CPPUNIT_TEST(testFind1); + CPPUNIT_TEST(testFind2); + CPPUNIT_TEST(testRfind1); + CPPUNIT_TEST(testRfind2); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testConversion(unsigned int i, unsigned char a, unsigned char b, unsigned char c, unsigned char d) + { + ByteVector v(4, 0); + + v[3] = a; + v[2] = b; + v[1] = c; + v[0] = d; + CPPUNIT_ASSERT(v.toUInt(false) == i); + + v[0] = a; + v[1] = b; + v[2] = c; + v[3] = d; + CPPUNIT_ASSERT(v.toUInt() == i); + } + + void testByteVector() + { + ByteVector v("foobar"); + + CPPUNIT_ASSERT(v.find("ob") == 2); + CPPUNIT_ASSERT(v.find('b') == 3); + + ByteVector n(4, 0); + n[0] = 1; + CPPUNIT_ASSERT(n.toUInt(true) == 16777216); + CPPUNIT_ASSERT(n.toUInt(false) == 1); + CPPUNIT_ASSERT(ByteVector::fromUInt(16777216, true) == n); + CPPUNIT_ASSERT(ByteVector::fromUInt(1, false) == n); + + CPPUNIT_ASSERT(ByteVector::fromUInt(0xa0).toUInt() == 0xa0); + + testConversion(0x000000a0, 0x00, 0x00, 0x00, 0xa0); + testConversion(0xd50bf072, 0xd5, 0x0b, 0xf0, 0x72); + + ByteVector intVector(2, 0); + intVector[0] = char(0xfc); + intVector[1] = char(0x00); + CPPUNIT_ASSERT(intVector.toShort() == -1024); + intVector[0] = char(0x04); + intVector[1] = char(0x00); + CPPUNIT_ASSERT(intVector.toShort() == 1024); + + CPPUNIT_ASSERT(ByteVector::fromLongLong(1).toLongLong() == 1); + CPPUNIT_ASSERT(ByteVector::fromLongLong(0).toLongLong() == 0); + CPPUNIT_ASSERT(ByteVector::fromLongLong(0xffffffffffffffffLL).toLongLong() == -1); + CPPUNIT_ASSERT(ByteVector::fromLongLong(0xfffffffffffffffeLL).toLongLong() == -2); + CPPUNIT_ASSERT(ByteVector::fromLongLong(1024).toLongLong() == 1024); + + ByteVector a1("foo"); + a1.append("bar"); + CPPUNIT_ASSERT(a1 == "foobar"); + + ByteVector a2("foo"); + a2.append("b"); + CPPUNIT_ASSERT(a2 == "foob"); + + ByteVector a3; + a3.append("b"); + CPPUNIT_ASSERT(a3 == "b"); + + ByteVector s1("foo"); + CPPUNIT_ASSERT(ByteVectorList::split(s1, " ").size() == 1); + + ByteVector s2("f"); + CPPUNIT_ASSERT(ByteVectorList::split(s2, " ").size() == 1); + + + CPPUNIT_ASSERT(ByteVector().size() == 0); + CPPUNIT_ASSERT(ByteVector("asdf").clear().size() == 0); + CPPUNIT_ASSERT(ByteVector("asdf").clear() == ByteVector()); + } + + void testFind1() + { + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO")); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO", 0)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO", 1)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO", 2)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO", 3)); + CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO", 4)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 5)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 6)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 7)); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 8)); + } + + void testFind2() + { + CPPUNIT_ASSERT_EQUAL(0, ByteVector("\x01", 1).find("\x01")); + CPPUNIT_ASSERT_EQUAL(0, ByteVector("\x01\x02", 2).find("\x01\x02")); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("\x01", 1).find("\x02")); + CPPUNIT_ASSERT_EQUAL(-1, ByteVector("\x01\x02", 2).find("\x01\x03")); + } + + void testRfind1() + { + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 0)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 1)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 2)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 3)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 4)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 5)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 6)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 7)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS", 8)); + CPPUNIT_ASSERT_EQUAL(1, ByteVector(".OggS....").rfind("OggS")); + } + + void testRfind2() + { + ByteVector r0("**************"); + ByteVector r1("OggS**********"); + ByteVector r2("**********OggS"); + ByteVector r3("OggS******OggS"); + ByteVector r4("OggS*OggS*OggS"); + + CPPUNIT_ASSERT_EQUAL(-1, r0.find("OggS")); + CPPUNIT_ASSERT_EQUAL(-1, r0.rfind("OggS")); + CPPUNIT_ASSERT_EQUAL(0, r1.find("OggS")); + CPPUNIT_ASSERT_EQUAL(0, r1.rfind("OggS")); + CPPUNIT_ASSERT_EQUAL(10, r2.find("OggS")); + CPPUNIT_ASSERT_EQUAL(10, r2.rfind("OggS")); + CPPUNIT_ASSERT_EQUAL(0, r3.find("OggS")); + CPPUNIT_ASSERT_EQUAL(10, r3.rfind("OggS")); + CPPUNIT_ASSERT_EQUAL(10, r4.rfind("OggS")); + CPPUNIT_ASSERT_EQUAL(10, r4.rfind("OggS", 0)); + CPPUNIT_ASSERT_EQUAL(5, r4.rfind("OggS", 7)); + CPPUNIT_ASSERT_EQUAL(10, r4.rfind("OggS", 12)); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVector); diff --git a/libs/taglib/tests/test_fileref.cpp b/libs/taglib/tests/test_fileref.cpp new file mode 100644 index 0000000000..0752c08a43 --- /dev/null +++ b/libs/taglib/tests/test_fileref.cpp @@ -0,0 +1,101 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <string> +#include <stdio.h> +#include <tag.h> +#include <fileref.h> +#include "utils.h" + +using namespace std; +using namespace TagLib; + +class TestFileRef : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestFileRef); + CPPUNIT_TEST(testMusepack); + CPPUNIT_TEST(testVorbis); + CPPUNIT_TEST(testSpeex); + CPPUNIT_TEST(testFLAC); + CPPUNIT_TEST(testMP3); + CPPUNIT_TEST(testTrueAudio); + CPPUNIT_TEST_SUITE_END(); + +public: + + void fileRefSave(const string &filename, const string &ext) + { + string newname = copyFile(filename, ext); + + FileRef *f = new FileRef(newname.c_str()); + CPPUNIT_ASSERT(!f->isNull()); + f->tag()->setArtist("test artist"); + f->tag()->setTitle("test title"); + f->tag()->setGenre("Test!"); + f->tag()->setAlbum("albummmm"); + f->tag()->setTrack(5); + f->tag()->setYear(2020); + f->save(); + delete f; + + f = new FileRef(newname.c_str()); + CPPUNIT_ASSERT(!f->isNull()); + CPPUNIT_ASSERT_EQUAL(f->tag()->artist(), String("test artist")); + CPPUNIT_ASSERT_EQUAL(f->tag()->title(), String("test title")); + CPPUNIT_ASSERT_EQUAL(f->tag()->genre(), String("Test!")); + CPPUNIT_ASSERT_EQUAL(f->tag()->album(), String("albummmm")); + CPPUNIT_ASSERT_EQUAL(f->tag()->track(), TagLib::uint(5)); + CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2020)); + f->tag()->setArtist("ttest artist"); + f->tag()->setTitle("ytest title"); + f->tag()->setGenre("uTest!"); + f->tag()->setAlbum("ialbummmm"); + f->tag()->setTrack(7); + f->tag()->setYear(2080); + f->save(); + delete f; + + f = new FileRef(newname.c_str()); + CPPUNIT_ASSERT(!f->isNull()); + CPPUNIT_ASSERT_EQUAL(f->tag()->artist(), String("ttest artist")); + CPPUNIT_ASSERT_EQUAL(f->tag()->title(), String("ytest title")); + CPPUNIT_ASSERT_EQUAL(f->tag()->genre(), String("uTest!")); + CPPUNIT_ASSERT_EQUAL(f->tag()->album(), String("ialbummmm")); + CPPUNIT_ASSERT_EQUAL(f->tag()->track(), TagLib::uint(7)); + CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2080)); + delete f; + + deleteFile(newname); + } + + void testMusepack() + { + fileRefSave("click", ".mpc"); + } + + void testVorbis() + { + fileRefSave("empty", ".ogg"); + } + + void testSpeex() + { + fileRefSave("empty", ".spx"); + } + + void testFLAC() + { + fileRefSave("no-tags", ".flac"); + } + + void testMP3() + { + fileRefSave("xing", ".mp3"); + } + + void testTrueAudio() + { + fileRefSave("empty", ".tta"); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestFileRef); diff --git a/libs/taglib/tests/test_id3v1.cpp b/libs/taglib/tests/test_id3v1.cpp new file mode 100644 index 0000000000..308225c2f8 --- /dev/null +++ b/libs/taglib/tests/test_id3v1.cpp @@ -0,0 +1,25 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <string> +#include <stdio.h> +#include <id3v1tag.h> + +using namespace std; +using namespace TagLib; + +class TestID3v1 : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestID3v1); + CPPUNIT_TEST(testStripWhiteSpace); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testStripWhiteSpace() + { + ID3v1::StringHandler h; + CPPUNIT_ASSERT_EQUAL(String("Foo"), h.parse(ByteVector("Foo "))); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v1); diff --git a/libs/taglib/tests/test_id3v2.cpp b/libs/taglib/tests/test_id3v2.cpp new file mode 100644 index 0000000000..ed5e0b0003 --- /dev/null +++ b/libs/taglib/tests/test_id3v2.cpp @@ -0,0 +1,265 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <string> +#include <stdio.h> +#include <id3v2tag.h> +#include <mpegfile.h> +#include <id3v2frame.h> +#include <uniquefileidentifierframe.h> +#include <textidentificationframe.h> +#include <attachedpictureframe.h> +#include <generalencapsulatedobjectframe.h> +#include <relativevolumeframe.h> +#include <urllinkframe.h> +#include "utils.h" + +using namespace std; +using namespace TagLib; + +class PublicFrame : public ID3v2::Frame +{ + public: + PublicFrame() : ID3v2::Frame(ByteVector("XXXX\0\0\0\0\0\0", 10)) {} + String readStringField(const ByteVector &data, String::Type encoding, + int *positon = 0) + { return ID3v2::Frame::readStringField(data, encoding, positon); } + virtual String toString() const { return String::null; } + virtual void parseFields(const ByteVector &) {} + virtual ByteVector renderFields() const { return ByteVector::null; } +}; + +class TestID3v2 : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestID3v2); + CPPUNIT_TEST(testUnsynchDecode); + CPPUNIT_TEST(testUTF16BEDelimiter); + CPPUNIT_TEST(testUTF16Delimiter); + CPPUNIT_TEST(testReadStringField); + CPPUNIT_TEST(testParseAPIC); + CPPUNIT_TEST(testParseAPIC_UTF16_BOM); + CPPUNIT_TEST(testParseGEOB); + CPPUNIT_TEST(testParseRelativeVolumeFrame); + CPPUNIT_TEST(testParseUniqueFileIdentifierFrame); + CPPUNIT_TEST(testParseEmptyUniqueFileIdentifierFrame); + CPPUNIT_TEST(testBrokenFrame1); + CPPUNIT_TEST(testItunes24FrameSize); + CPPUNIT_TEST(testParseUrlLinkFrame); + CPPUNIT_TEST(testRenderUrlLinkFrame); + CPPUNIT_TEST(testParseUserUrlLinkFrame); + CPPUNIT_TEST(testRenderUserUrlLinkFrame); + CPPUNIT_TEST(testSaveUTF16Comment); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testUnsynchDecode() + { + MPEG::File f("data/unsynch.id3", false); + CPPUNIT_ASSERT(f.tag()); + CPPUNIT_ASSERT_EQUAL(String("My babe just cares for me"), f.tag()->title()); + } + + void testUTF16BEDelimiter() + { + ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF16BE); + StringList sl; + sl.append("Foo"); + sl.append("Bar"); + f.setText(sl); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4+4+2+1+6+2+6), f.render().size()); + } + + void testUTF16Delimiter() + { + ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF16); + StringList sl; + sl.append("Foo"); + sl.append("Bar"); + f.setText(sl); + CPPUNIT_ASSERT_EQUAL((unsigned int)(4+4+2+1+8+2+8), f.render().size()); + } + + void testBrokenFrame1() + { + MPEG::File f("data/broken-tenc.id3", false); + CPPUNIT_ASSERT(f.tag()); + CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TENC")); + } + + void testReadStringField() + { + PublicFrame f; + ByteVector data("abc\0", 4); + String str = f.readStringField(data, String::Latin1); + CPPUNIT_ASSERT_EQUAL(String("abc"), str); + } + + // http://bugs.kde.org/show_bug.cgi?id=151078 + void testParseAPIC() + { + ID3v2::AttachedPictureFrame f(ByteVector("APIC" + "\x00\x00\x00\x07" + "\x00\x00" + "\x00" + "m\x00" + "\x01" + "d\x00" + "\x00", 17)); + CPPUNIT_ASSERT_EQUAL(String("m"), f.mimeType()); + CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::FileIcon, f.type()); + CPPUNIT_ASSERT_EQUAL(String("d"), f.description()); + } + + void testParseAPIC_UTF16_BOM() + { + ID3v2::AttachedPictureFrame f(ByteVector( + "\x41\x50\x49\x43\x00\x02\x0c\x59\x00\x00\x01\x69\x6d\x61\x67\x65" + "\x2f\x6a\x70\x65\x67\x00\x00\xfe\xff\x00\x63\x00\x6f\x00\x76\x00" + "\x65\x00\x72\x00\x2e\x00\x6a\x00\x70\x00\x67\x00\x00\xff\xd8\xff", + 16 * 3)); + CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), f.mimeType()); + CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, f.type()); + CPPUNIT_ASSERT_EQUAL(String("cover.jpg"), f.description()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xd8\xff", 3), f.picture()); + } + + // http://bugs.kde.org/show_bug.cgi?id=151078 + void testParseGEOB() + { + ID3v2::GeneralEncapsulatedObjectFrame f(ByteVector("GEOB" + "\x00\x00\x00\x08" + "\x00\x00" + "\x00" + "m\x00" + "f\x00" + "d\x00" + "\x00", 18)); + CPPUNIT_ASSERT_EQUAL(String("m"), f.mimeType()); + CPPUNIT_ASSERT_EQUAL(String("f"), f.fileName()); + CPPUNIT_ASSERT_EQUAL(String("d"), f.description()); + } + + // http://bugs.kde.org/show_bug.cgi?id=150481 + void testParseRelativeVolumeFrame() + { + ID3v2::RelativeVolumeFrame f( + ByteVector("RVA2" // Frame ID + "\x00\x00\x00\x0B" // Frame size + "\x00\x00" // Frame flags + "ident\x00" // Identification + "\x02" // Type of channel + "\x00\x0F" // Volume adjustment + "\x08" // Bits representing peak + "\x45", 21)); // Peak volume + CPPUNIT_ASSERT_EQUAL(String("ident"), f.identification()); + CPPUNIT_ASSERT_EQUAL(15.0f / 512.0f, + f.volumeAdjustment(ID3v2::RelativeVolumeFrame::FrontRight)); + CPPUNIT_ASSERT_EQUAL((uchar)8, + f.peakVolume(ID3v2::RelativeVolumeFrame::FrontRight).bitsRepresentingPeak); + CPPUNIT_ASSERT_EQUAL(ByteVector("\x45"), + f.peakVolume(ID3v2::RelativeVolumeFrame::FrontRight).peakVolume); + } + + void testParseUniqueFileIdentifierFrame() + { + ID3v2::UniqueFileIdentifierFrame f( + ByteVector("UFID" // Frame ID + "\x00\x00\x00\x09" // Frame size + "\x00\x00" // Frame flags + "owner\x00" // Owner identifier + "\x00\x01\x02", 19)); // Identifier + CPPUNIT_ASSERT_EQUAL(String("owner"), + f.owner()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\x00\x01\x02", 3), + f.identifier()); + } + + void testParseEmptyUniqueFileIdentifierFrame() + { + ID3v2::UniqueFileIdentifierFrame f( + ByteVector("UFID" // Frame ID + "\x00\x00\x00\x01" // Frame size + "\x00\x00" // Frame flags + "\x00" // Owner identifier + "", 11)); // Identifier + CPPUNIT_ASSERT_EQUAL(String(), + f.owner()); + CPPUNIT_ASSERT_EQUAL(ByteVector(), + f.identifier()); + } + + void testParseUrlLinkFrame() + { + ID3v2::UrlLinkFrame f( + ByteVector("WOAF" // Frame ID + "\x00\x00\x00\x12" // Frame size + "\x00\x00" // Frame flags + "http://example.com", 28)); // URL + CPPUNIT_ASSERT_EQUAL(String("http://example.com"), f.url()); + } + + void testRenderUrlLinkFrame() + { + ID3v2::UrlLinkFrame f("WOAF"); + f.setUrl("http://example.com"); + CPPUNIT_ASSERT_EQUAL( + ByteVector("WOAF" // Frame ID + "\x00\x00\x00\x12" // Frame size + "\x00\x00" // Frame flags + "http://example.com", 28), // URL + f.render()); + } + + void testParseUserUrlLinkFrame() + { + ID3v2::UserUrlLinkFrame f( + ByteVector("WXXX" // Frame ID + "\x00\x00\x00\x17" // Frame size + "\x00\x00" // Frame flags + "\x00" // Text encoding + "foo\x00" // Description + "http://example.com", 33)); // URL + CPPUNIT_ASSERT_EQUAL(String("foo"), f.description()); + CPPUNIT_ASSERT_EQUAL(String("http://example.com"), f.url()); + } + + void testRenderUserUrlLinkFrame() + { + ID3v2::UserUrlLinkFrame f; + f.setDescription("foo"); + f.setUrl("http://example.com"); + CPPUNIT_ASSERT_EQUAL( + ByteVector("WXXX" // Frame ID + "\x00\x00\x00\x17" // Frame size + "\x00\x00" // Frame flags + "\x00" // Text encoding + "foo\x00" // Description + "http://example.com", 33), // URL + f.render()); + } + + void testItunes24FrameSize() + { + MPEG::File f("data/005411.id3", false); + CPPUNIT_ASSERT(f.tag()); + CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("TIT2")); + CPPUNIT_ASSERT_EQUAL(String("Sunshine Superman"), f.ID3v2Tag()->frameListMap()["TIT2"].front()->toString()); + } + + void testSaveUTF16Comment() + { + String::Type defaultEncoding = ID3v2::FrameFactory::instance()->defaultTextEncoding(); + string newname = copyFile("xing", ".mp3"); + ID3v2::FrameFactory::instance()->setDefaultTextEncoding(String::UTF16); + MPEG::File foo(newname.c_str()); + foo.strip(); + foo.tag()->setComment("Test comment!"); + foo.save(); + MPEG::File bar(newname.c_str()); + CPPUNIT_ASSERT_EQUAL(String("Test comment!"), bar.tag()->comment()); + deleteFile(newname); + ID3v2::FrameFactory::instance()->setDefaultTextEncoding(defaultEncoding); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2); diff --git a/libs/taglib/tests/test_list.cpp b/libs/taglib/tests/test_list.cpp new file mode 100644 index 0000000000..39cbaf0a65 --- /dev/null +++ b/libs/taglib/tests/test_list.cpp @@ -0,0 +1,58 @@ +/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <cppunit/extensions/HelperMacros.h> +#include <tlist.h> + +using namespace std; +using namespace TagLib; + +class TestList : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestList); + CPPUNIT_TEST(testList); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testList() + { + List<int> l1; + List<int> l2; + List<int> l3; + l1.append(2); + l2.append(3); + l2.append(4); + l1.append(l2); + l1.prepend(1); + l3.append(1); + l3.append(2); + l3.append(3); + l3.append(4); + CPPUNIT_ASSERT(l1 == l3); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestList); diff --git a/libs/taglib/tests/test_map.cpp b/libs/taglib/tests/test_map.cpp new file mode 100644 index 0000000000..b6f77aae32 --- /dev/null +++ b/libs/taglib/tests/test_map.cpp @@ -0,0 +1,27 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <tstring.h> +#include <tmap.h> + +using namespace std; +using namespace TagLib; + +class TestMap : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestMap); + CPPUNIT_TEST(testInsert); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testInsert() + { + Map<String, int> m; + m.insert("foo", 3); + CPPUNIT_ASSERT_EQUAL(3, m["foo"]); + m.insert("foo", 7); + CPPUNIT_ASSERT_EQUAL(7, m["foo"]); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestMap); diff --git a/libs/taglib/tests/test_mpeg.cpp b/libs/taglib/tests/test_mpeg.cpp new file mode 100644 index 0000000000..6278ff55ee --- /dev/null +++ b/libs/taglib/tests/test_mpeg.cpp @@ -0,0 +1,25 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <string> +#include <stdio.h> +#include <mpegfile.h> + +using namespace std; +using namespace TagLib; + +class TestMPEG : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestMPEG); + CPPUNIT_TEST(testVersion2DurationWithXingHeader); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testVersion2DurationWithXingHeader() + { + MPEG::File f("data/mpeg2.mp3"); + CPPUNIT_ASSERT_EQUAL(5387, f.audioProperties()->length()); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG); diff --git a/libs/taglib/tests/test_string.cpp b/libs/taglib/tests/test_string.cpp new file mode 100644 index 0000000000..ab331c89e9 --- /dev/null +++ b/libs/taglib/tests/test_string.cpp @@ -0,0 +1,135 @@ +/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <cppunit/extensions/HelperMacros.h> +#include <tstring.h> + +using namespace std; +using namespace TagLib; + +class TestString : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestString); + CPPUNIT_TEST(testString); + CPPUNIT_TEST(testUTF16Encode); + CPPUNIT_TEST(testUTF16Decode); + CPPUNIT_TEST(testUTF16DecodeInvalidBOM); + CPPUNIT_TEST(testUTF16DecodeEmptyWithBOM); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testString() + { + String s = "taglib string"; + ByteVector v = "taglib string"; + CPPUNIT_ASSERT(v == s.data(String::Latin1)); + + char str[] = "taglib string"; + CPPUNIT_ASSERT(strcmp(s.toCString(), str) == 0); + + String unicode("José Carlos", String::UTF8); + CPPUNIT_ASSERT(strcmp(unicode.toCString(), "Jos\xe9 Carlos") == 0); + + String latin = "Jos\xe9 Carlos"; + CPPUNIT_ASSERT(strcmp(latin.toCString(true), "José Carlos") == 0); + + String unicode2(unicode.to8Bit(true), String::UTF8); + CPPUNIT_ASSERT(unicode == unicode2); + + CPPUNIT_ASSERT(strcmp(String::number(0).toCString(), "0") == 0); + CPPUNIT_ASSERT(strcmp(String::number(12345678).toCString(), "12345678") == 0); + CPPUNIT_ASSERT(strcmp(String::number(-12345678).toCString(), "-12345678") == 0); + + String n = "123"; + CPPUNIT_ASSERT(n.toInt() == 123); + + n = "-123"; + CPPUNIT_ASSERT(n.toInt() == -123); + + CPPUNIT_ASSERT(String("0").toInt() == 0); + CPPUNIT_ASSERT(String("1").toInt() == 1); + + CPPUNIT_ASSERT(String(" foo ").stripWhiteSpace() == String("foo")); + CPPUNIT_ASSERT(String("foo ").stripWhiteSpace() == String("foo")); + CPPUNIT_ASSERT(String(" foo").stripWhiteSpace() == String("foo")); + + CPPUNIT_ASSERT(memcmp(String("foo").data(String::Latin1).data(), "foo", 3) == 0); + CPPUNIT_ASSERT(memcmp(String("f").data(String::Latin1).data(), "f", 1) == 0); + + ByteVector utf16 = unicode.data(String::UTF16); + + // Check to make sure that the BOM is there and that the data size is correct + + CPPUNIT_ASSERT(utf16.size() == 2 + (unicode.size() * 2)); + + CPPUNIT_ASSERT(unicode == String(utf16, String::UTF16)); + } + + void testUTF16Encode() + { + String a("foo"); + ByteVector b("\0f\0o\0o", 6); + ByteVector c("f\0o\0o\0", 6); + ByteVector d("\377\376f\0o\0o\0", 8); + CPPUNIT_ASSERT(a.data(String::UTF16BE) != a.data(String::UTF16LE)); + CPPUNIT_ASSERT(b == a.data(String::UTF16BE)); + CPPUNIT_ASSERT(c == a.data(String::UTF16LE)); + CPPUNIT_ASSERT_EQUAL(d, a.data(String::UTF16)); + } + + void testUTF16Decode() + { + String a("foo"); + ByteVector b("\0f\0o\0o", 6); + ByteVector c("f\0o\0o\0", 6); + ByteVector d("\377\376f\0o\0o\0", 8); + CPPUNIT_ASSERT_EQUAL(a, String(b, String::UTF16BE)); + CPPUNIT_ASSERT_EQUAL(a, String(c, String::UTF16LE)); + CPPUNIT_ASSERT_EQUAL(a, String(d, String::UTF16)); + } + + // this test is expected to print "TagLib: String::prepare() - + // Invalid UTF16 string." on the console 3 times + void testUTF16DecodeInvalidBOM() + { + ByteVector b(" ", 1); + ByteVector c(" ", 2); + ByteVector d(" \0f\0o\0o", 8); + CPPUNIT_ASSERT_EQUAL(String(), String(b, String::UTF16)); + CPPUNIT_ASSERT_EQUAL(String(), String(c, String::UTF16)); + CPPUNIT_ASSERT_EQUAL(String(), String(d, String::UTF16)); + } + + void testUTF16DecodeEmptyWithBOM() + { + ByteVector a("\377\376", 2); + ByteVector b("\376\377", 2); + CPPUNIT_ASSERT_EQUAL(String(), String(a, String::UTF16)); + CPPUNIT_ASSERT_EQUAL(String(), String(b, String::UTF16)); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestString); diff --git a/libs/taglib/tests/test_synchdata.cpp b/libs/taglib/tests/test_synchdata.cpp new file mode 100644 index 0000000000..04ef5359dc --- /dev/null +++ b/libs/taglib/tests/test_synchdata.cpp @@ -0,0 +1,88 @@ +/* Copyright (C) 2003 Scott Wheeler <wheeler@kde.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <cppunit/extensions/HelperMacros.h> +#include <id3v2synchdata.h> + +using namespace std; +using namespace TagLib; + +class TestID3v2SynchData : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestID3v2SynchData); + CPPUNIT_TEST(test1); + CPPUNIT_TEST(test2); + CPPUNIT_TEST(test3); + CPPUNIT_TEST(testDecode1); + CPPUNIT_TEST(testDecode2); + CPPUNIT_TEST_SUITE_END(); + +public: + + void test1() + { + char data[] = { 0, 0, 0, 127 }; + ByteVector v(data, 4); + + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), TagLib::uint(127)); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(127), v); + } + + void test2() + { + char data[] = { 0, 0, 1, 0 }; + ByteVector v(data, 4); + + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), TagLib::uint(128)); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(128), v); + } + + void test3() + { + char data[] = { 0, 0, 1, 1 }; + ByteVector v(data, 4); + + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::toUInt(v), TagLib::uint(129)); + CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(129), v); + } + + void testDecode1() + { + ByteVector a("\xff\x00\x00", 3); + a = ID3v2::SynchData::decode(a); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, a.size()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\x00", 2), a); + } + + void testDecode2() + { + ByteVector a("\xff\x44", 2); + a = ID3v2::SynchData::decode(a); + CPPUNIT_ASSERT_EQUAL((unsigned int)2, a.size()); + CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\x44", 2), a); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2SynchData); diff --git a/libs/taglib/tests/test_trueaudio.cpp b/libs/taglib/tests/test_trueaudio.cpp new file mode 100644 index 0000000000..b300eef9e3 --- /dev/null +++ b/libs/taglib/tests/test_trueaudio.cpp @@ -0,0 +1,26 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <string> +#include <stdio.h> +#include <trueaudiofile.h> + +using namespace std; +using namespace TagLib; + +class TestTrueAudio : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestTrueAudio); + CPPUNIT_TEST(testReadPropertiesWithoutID3v2); + CPPUNIT_TEST_SUITE_END(); + +public: + + void testReadPropertiesWithoutID3v2() + { + TrueAudio::File f("data/empty.tta"); + CPPUNIT_ASSERT(f.audioProperties()); + CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length()); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestTrueAudio); diff --git a/libs/taglib/tests/utils.h b/libs/taglib/tests/utils.h new file mode 100644 index 0000000000..21d94526f0 --- /dev/null +++ b/libs/taglib/tests/utils.h @@ -0,0 +1,25 @@ +#include <string> +#include <stdio.h> +#include <sys/fcntl.h> + +using namespace std; + +inline string copyFile(const string &filename, const string &ext) +{ + string newname = string(tempnam(NULL, NULL)) + ext; + string oldname = string("data/") + filename + ext; + char buffer[4096]; + int bytes; + int inf = open(oldname.c_str(), O_RDONLY); + int outf = open(newname.c_str(), O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); + while((bytes = read(inf, buffer, sizeof(buffer))) > 0) + write(outf, buffer, bytes); + close(outf); + close(inf); + return newname; +} + +inline void deleteFile(const string &filename) +{ + remove(filename.c_str()); +} |