1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-24 23:13:42 +02:00

Update taglib to 1.9.1.

This commit is contained in:
lllucius
2013-10-24 19:21:10 +00:00
parent 044319b373
commit fe318f3b94
418 changed files with 21318 additions and 87426 deletions

View File

@@ -1,15 +1,29 @@
if(BUILD_TESTS)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../taglib
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/toolkit
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ape
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/asf
${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/mpc
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mp4
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/riff
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/riff/aiff
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/riff/wav
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/trueaudio
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/vorbis
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/flac
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/speex
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/ogg/opus
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/flac
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/wavpack
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/mod
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/s3m
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/it
${CMAKE_CURRENT_SOURCE_DIR}/../taglib/xm
)
SET(test_runner_SRCS
@@ -20,25 +34,43 @@ SET(test_runner_SRCS
test_synchdata.cpp
test_trueaudio.cpp
test_bytevector.cpp
test_bytevectorlist.cpp
test_bytevectorstream.cpp
test_string.cpp
test_propertymap.cpp
test_fileref.cpp
test_id3v1.cpp
test_id3v2.cpp
test_xiphcomment.cpp
test_aiff.cpp
test_riff.cpp
test_ogg.cpp
test_oggflac.cpp
test_flac.cpp
test_flacpicture.cpp
test_flacunknownmetadatablock.cpp
test_ape.cpp
test_apetag.cpp
test_wav.cpp
test_info.cpp
test_wavpack.cpp
test_mp4.cpp
test_mp4item.cpp
test_mp4coverart.cpp
test_asf.cpp
test_mod.cpp
test_s3m.cpp
test_it.cpp
test_xm.cpp
test_mpc.cpp
test_opus.cpp
)
IF(WITH_MP4)
SET(test_runner_SRCS ${test_runner_SRCS} test_mp4.cpp)
ENDIF(WITH_MP4)
IF(WITH_ASF)
SET(test_runner_SRCS ${test_runner_SRCS} test_asf.cpp)
ENDIF(WITH_ASF)
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
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)
ADD_TEST(test_runner test_runner)
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} -V
DEPENDS test_runner)

View File

@@ -1,27 +0,0 @@
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

View File

@@ -1,712 +0,0 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# KDE tags expanded automatically by am_edit - $Revision: 1.1 $
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 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.@am__isrc@ -I$(top_builddir)
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_build_prefix = @top_build_prefix@
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 ) \
#>- && { if test -f $@; then exit 0; else break; fi; }; \
#>- exit 1;; \
#>- esac; \
#>- done; \
#>- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
#>- cd $(top_srcdir) && \
#>- $(AUTOMAKE) --foreign tests/Makefile
#>+ 12
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign 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; nonempty = 1; } \
END { if (nonempty) { 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; nonempty = 1; } \
END { if (nonempty) { 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=; \
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; nonempty = 1; } \
END { if (nonempty) { 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; \
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 \
*[\ \ ]$$tst[\ \ ]*) \
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 \
*[\ \ ]$$tst[\ \ ]*) \
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 "$$all" -eq 1; then \
tests="test"; \
All=""; \
else \
tests="tests"; \
All="All "; \
fi; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
banner="$$All$$all $$tests passed"; \
else \
if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
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 \
if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
fi; \
fi; \
dashes="$$banner"; \
skipped=""; \
if test "$$skip" -ne 0; then \
if test "$$skip" -eq 1; then \
skipped="($$skip test was not run)"; \
else \
skipped="($$skip tests were not run)"; \
fi; \
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=test_mp4.cpp utils.h Makefile.in test_asf.cpp Makefile.am CMakeLists.txt
#>+ 2
docs-am:
#>+ 15
force-reedit:
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign 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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <stdexcept>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
@@ -5,6 +8,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/XmlOutputter.h>
int main(int argc, char* argv[])
{
@@ -34,6 +38,13 @@ int main(int argc, char* argv[])
// Print test in a compiler compatible format.
CppUnit::CompilerOutputter outputter(&result, std::cerr);
outputter.write();
char *xml = ::getenv("CPPUNIT_XML");
if(xml && !::strcmp(xml, "1")) {
std::ofstream xmlfileout("cpptestresults.xml");
CppUnit::XmlOutputter xmlout(&result, xmlfileout);
xmlout.write();
}
}
catch(std::invalid_argument &e){
std::cerr << std::endl

View File

@@ -0,0 +1,31 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <aifffile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestAIFF : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestAIFF);
CPPUNIT_TEST(testReading);
CPPUNIT_TEST_SUITE_END();
public:
void testReading()
{
ScopedFileCopy copy("empty", ".aiff");
string filename = copy.fileName();
RIFF::AIFF::File *f = new RIFF::AIFF::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(705, f->audioProperties()->bitrate());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestAIFF);

View File

@@ -0,0 +1,52 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <apefile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestAPE : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestAPE);
CPPUNIT_TEST(testProperties399);
CPPUNIT_TEST(testProperties396);
CPPUNIT_TEST(testProperties390);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties399()
{
APE::File f(TEST_FILE_PATH_C("mac-399.ape"));
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
void testProperties396()
{
APE::File f(TEST_FILE_PATH_C("mac-396.ape"));
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
void testProperties390()
{
APE::File f(TEST_FILE_PATH_C("mac-390-hdr.ape"));
CPPUNIT_ASSERT_EQUAL(15, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestAPE);

View File

@@ -0,0 +1,122 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <apetag.h>
#include <tdebug.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestAPETag : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestAPETag);
CPPUNIT_TEST(testIsEmpty);
CPPUNIT_TEST(testIsEmpty2);
CPPUNIT_TEST(testPropertyInterface1);
CPPUNIT_TEST(testPropertyInterface2);
CPPUNIT_TEST(testInvalidKeys);
CPPUNIT_TEST(testTextBinary);
CPPUNIT_TEST_SUITE_END();
public:
void testIsEmpty()
{
APE::Tag tag;
CPPUNIT_ASSERT(tag.isEmpty());
tag.addValue("COMPOSER", "Mike Oldfield");
CPPUNIT_ASSERT(!tag.isEmpty());
}
void testIsEmpty2()
{
APE::Tag tag;
CPPUNIT_ASSERT(tag.isEmpty());
tag.setArtist("Mike Oldfield");
CPPUNIT_ASSERT(!tag.isEmpty());
}
void testPropertyInterface1()
{
APE::Tag tag;
PropertyMap dict = tag.properties();
CPPUNIT_ASSERT(dict.isEmpty());
dict["ARTIST"] = String("artist 1");
dict["ARTIST"].append("artist 2");
dict["TRACKNUMBER"].append("17");
tag.setProperties(dict);
CPPUNIT_ASSERT_EQUAL(String("17"), tag.itemListMap()["TRACK"].values()[0]);
CPPUNIT_ASSERT_EQUAL(2u, tag.itemListMap()["ARTIST"].values().size());
CPPUNIT_ASSERT_EQUAL(String("artist 1"), tag.artist());
CPPUNIT_ASSERT_EQUAL(17u, tag.track());
}
void testPropertyInterface2()
{
APE::Tag tag;
APE::Item item1 = APE::Item("TRACK", "17");
tag.setItem("TRACK", item1);
APE::Item item2 = APE::Item();
item2.setType(APE::Item::Binary);
tag.setItem("TESTBINARY", item2);
PropertyMap properties = tag.properties();
CPPUNIT_ASSERT_EQUAL(1u, properties.unsupportedData().size());
CPPUNIT_ASSERT(properties.contains("TRACKNUMBER"));
CPPUNIT_ASSERT(!properties.contains("TRACK"));
CPPUNIT_ASSERT(tag.itemListMap().contains("TESTBINARY"));
tag.removeUnsupportedProperties(properties.unsupportedData());
CPPUNIT_ASSERT(!tag.itemListMap().contains("TESTBINARY"));
APE::Item item3 = APE::Item("TRACKNUMBER", "29");
tag.setItem("TRACKNUMBER", item3);
properties = tag.properties();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), properties["TRACKNUMBER"].size());
CPPUNIT_ASSERT_EQUAL(String("17"), properties["TRACKNUMBER"][0]);
CPPUNIT_ASSERT_EQUAL(String("29"), properties["TRACKNUMBER"][1]);
}
void testInvalidKeys()
{
PropertyMap properties;
properties["A"] = String("invalid key: one character");
properties["MP+"] = String("invalid key: forbidden string");
properties["A B~C"] = String("valid key: space and tilde");
properties["ARTIST"] = String("valid key: normal one");
APE::Tag tag;
PropertyMap unsuccessful = tag.setProperties(properties);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), unsuccessful.size());
CPPUNIT_ASSERT(unsuccessful.contains("A"));
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
}
void testTextBinary()
{
APE::Item item = APE::Item("DUMMY", "Test Text");
CPPUNIT_ASSERT_EQUAL(String("Test Text"), item.toString());
CPPUNIT_ASSERT_EQUAL(ByteVector::null, item.binaryData());
ByteVector data("Test Data");
item.setBinaryData(data);
CPPUNIT_ASSERT(item.values().isEmpty());
CPPUNIT_ASSERT_EQUAL(String::null, item.toString());
CPPUNIT_ASSERT_EQUAL(data, item.binaryData());
item.setValue("Test Text 2");
CPPUNIT_ASSERT_EQUAL(String("Test Text 2"), item.toString());
CPPUNIT_ASSERT_EQUAL(ByteVector::null, item.binaryData());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestAPETag);

View File

@@ -1,10 +1,11 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <asffile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -13,18 +14,23 @@ using namespace TagLib;
class TestASF : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestASF);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testAudioProperties);
CPPUNIT_TEST(testRead);
CPPUNIT_TEST(testSaveMultipleValues);
CPPUNIT_TEST(testSaveStream);
CPPUNIT_TEST(testSaveLanguage);
CPPUNIT_TEST(testDWordTrackNumber);
CPPUNIT_TEST(testSaveLargeValue);
CPPUNIT_TEST(testSavePicture);
CPPUNIT_TEST(testSaveMultiplePictures);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties()
void testAudioProperties()
{
ASF::File f("data/silence-1.wma");
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
CPPUNIT_ASSERT_EQUAL(4, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(64, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
@@ -33,13 +39,14 @@ public:
void testRead()
{
ASF::File f("data/silence-1.wma");
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
CPPUNIT_ASSERT_EQUAL(String("test"), f.tag()->title());
}
void testSaveMultipleValues()
{
string newname = copyFile("silence-1", ".wma");
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
ASF::AttributeList values;
@@ -52,13 +59,38 @@ public:
f = new ASF::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(2, (int)f->tag()->attributeListMap()["WM/AlbumTitle"].size());
delete f;
}
deleteFile(newname);
void testDWordTrackNumber()
{
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
CPPUNIT_ASSERT(!f->tag()->attributeListMap().contains("WM/TrackNumber"));
f->tag()->setAttribute("WM/TrackNumber", (unsigned int)(123));
f->save();
delete f;
f = new ASF::File(newname.c_str());
CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(123), f->tag()->track());
f->tag()->setTrack(234);
f->save();
delete f;
f = new ASF::File(newname.c_str());
CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(234), f->tag()->track());
delete f;
}
void testSaveStream()
{
string newname = copyFile("silence-1", ".wma");
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
ASF::AttributeList values;
@@ -72,13 +104,12 @@ public:
f = new ASF::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(43, f->tag()->attributeListMap()["WM/AlbumTitle"][0].stream());
delete f;
deleteFile(newname);
}
void testSaveLanguage()
{
string newname = copyFile("silence-1", ".wma");
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
ASF::AttributeList values;
@@ -94,8 +125,129 @@ public:
CPPUNIT_ASSERT_EQUAL(32, f->tag()->attributeListMap()["WM/AlbumTitle"][0].stream());
CPPUNIT_ASSERT_EQUAL(56, f->tag()->attributeListMap()["WM/AlbumTitle"][0].language());
delete f;
}
deleteFile(newname);
void testSaveLargeValue()
{
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
ASF::AttributeList values;
ASF::Attribute attr(ByteVector(70000, 'x'));
values.append(attr);
f->tag()->attributeListMap()["WM/Blob"] = values;
f->save();
delete f;
f = new ASF::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(ByteVector(70000, 'x'), f->tag()->attributeListMap()["WM/Blob"][0].toByteVector());
delete f;
}
void testSavePicture()
{
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
ASF::AttributeList values;
ASF::Picture picture;
picture.setMimeType("image/jpeg");
picture.setType(ASF::Picture::FrontCover);
picture.setDescription("description");
picture.setPicture("data");
ASF::Attribute attr(picture);
values.append(attr);
f->tag()->attributeListMap()["WM/Picture"] = values;
f->save();
delete f;
f = new ASF::File(newname.c_str());
ASF::AttributeList values2 = f->tag()->attributeListMap()["WM/Picture"];
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), values2.size());
ASF::Attribute attr2 = values2.front();
ASF::Picture picture2 = attr2.toPicture();
CPPUNIT_ASSERT(picture2.isValid());
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), picture2.mimeType());
CPPUNIT_ASSERT_EQUAL(ASF::Picture::FrontCover, picture2.type());
CPPUNIT_ASSERT_EQUAL(String("description"), picture2.description());
CPPUNIT_ASSERT_EQUAL(ByteVector("data"), picture2.picture());
delete f;
}
void testSaveMultiplePictures()
{
ScopedFileCopy copy("silence-1", ".wma");
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
ASF::AttributeList values;
ASF::Picture picture;
picture.setMimeType("image/jpeg");
picture.setType(ASF::Picture::FrontCover);
picture.setDescription("description");
picture.setPicture("data");
values.append(ASF::Attribute(picture));
ASF::Picture picture2;
picture2.setMimeType("image/png");
picture2.setType(ASF::Picture::BackCover);
picture2.setDescription("back cover");
picture2.setPicture("PNG data");
values.append(ASF::Attribute(picture2));
f->tag()->attributeListMap()["WM/Picture"] = values;
f->save();
delete f;
f = new ASF::File(newname.c_str());
ASF::AttributeList values2 = f->tag()->attributeListMap()["WM/Picture"];
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), values2.size());
ASF::Picture picture3 = values2[1].toPicture();
CPPUNIT_ASSERT(picture3.isValid());
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), picture3.mimeType());
CPPUNIT_ASSERT_EQUAL(ASF::Picture::FrontCover, picture3.type());
CPPUNIT_ASSERT_EQUAL(String("description"), picture3.description());
CPPUNIT_ASSERT_EQUAL(ByteVector("data"), picture3.picture());
ASF::Picture picture4 = values2[0].toPicture();
CPPUNIT_ASSERT(picture4.isValid());
CPPUNIT_ASSERT_EQUAL(String("image/png"), picture4.mimeType());
CPPUNIT_ASSERT_EQUAL(ASF::Picture::BackCover, picture4.type());
CPPUNIT_ASSERT_EQUAL(String("back cover"), picture4.description());
CPPUNIT_ASSERT_EQUAL(ByteVector("PNG data"), picture4.picture());
delete f;
}
void testProperties()
{
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
PropertyMap tags = f.properties();
tags["TRACKNUMBER"] = StringList("2");
tags["DISCNUMBER"] = StringList("3");
tags["BPM"] = StringList("123");
tags["ARTIST"] = StringList("Foo Bar");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), f.tag()->artist());
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/BeatsPerMinute"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/BeatsPerMinute"].size());
CPPUNIT_ASSERT_EQUAL(String("123"), f.tag()->attributeListMap()["WM/BeatsPerMinute"].front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/TrackNumber"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/TrackNumber"].size());
CPPUNIT_ASSERT_EQUAL(String("2"), f.tag()->attributeListMap()["WM/TrackNumber"].front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("2"), tags["TRACKNUMBER"]);
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/PartOfSet"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/PartOfSet"].size());
CPPUNIT_ASSERT_EQUAL(String("3"), f.tag()->attributeListMap()["WM/PartOfSet"].front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
}
};

View File

@@ -22,9 +22,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <tbytevector.h>
#include <tbytevectorlist.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;
@@ -37,6 +37,9 @@ class TestByteVector : public CppUnit::TestFixture
CPPUNIT_TEST(testFind2);
CPPUNIT_TEST(testRfind1);
CPPUNIT_TEST(testRfind2);
CPPUNIT_TEST(testToHex);
CPPUNIT_TEST(testToUShort);
CPPUNIT_TEST(testReplace);
CPPUNIT_TEST_SUITE_END();
public:
@@ -109,12 +112,17 @@ public:
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());
}
ByteVector i("blah blah");
ByteVector j("blah");
CPPUNIT_ASSERT(i.containsAt(j, 5, 0));
CPPUNIT_ASSERT(i.containsAt(j, 6, 1));
CPPUNIT_ASSERT(i.containsAt(j, 6, 1, 3));
}
void testFind1()
{
CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO"));
@@ -173,6 +181,66 @@ public:
CPPUNIT_ASSERT_EQUAL(10, r4.rfind("OggS", 12));
}
void testToHex()
{
ByteVector v("\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f", 16);
CPPUNIT_ASSERT_EQUAL(ByteVector("f0e1d2c3b4a5968778695a4b3c2d1e0f"), v.toHex());
}
void testToUShort()
{
CPPUNIT_ASSERT_EQUAL((unsigned short)0xFFFF, ByteVector("\xff\xff", 2).toUShort());
CPPUNIT_ASSERT_EQUAL((unsigned short)0x0001, ByteVector("\x00\x01", 2).toUShort());
CPPUNIT_ASSERT_EQUAL((unsigned short)0x0100, ByteVector("\x00\x01", 2).toUShort(false));
CPPUNIT_ASSERT_EQUAL((unsigned short)0xFF01, ByteVector("\xFF\x01", 2).toUShort());
CPPUNIT_ASSERT_EQUAL((unsigned short)0x01FF, ByteVector("\xFF\x01", 2).toUShort(false));
}
void testReplace()
{
{
ByteVector a("abcdabf");
a.replace(ByteVector(""), ByteVector("<a>"));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("foobartoolong"), ByteVector("<a>"));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("xx"), ByteVector("yy"));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcdabf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("a"), ByteVector("x"));
CPPUNIT_ASSERT_EQUAL(ByteVector("xbcdxbf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("ab"), ByteVector("xy"));
CPPUNIT_ASSERT_EQUAL(ByteVector("xycdxyf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("a"), ByteVector("<a>"));
CPPUNIT_ASSERT_EQUAL(ByteVector("<a>bcd<a>bf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("ab"), ByteVector("x"));
CPPUNIT_ASSERT_EQUAL(ByteVector("xcdxf"), a);
}
{
ByteVector a("abcdabf");
a.replace(ByteVector("ab"), ByteVector());
CPPUNIT_ASSERT_EQUAL(ByteVector("cdf"), a);
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVector);

View File

@@ -0,0 +1,38 @@
#include <tbytevector.h>
#include <tbytevectorlist.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;
class TestByteVectorList : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestByteVectorList);
CPPUNIT_TEST(testSplitSingleChar);
CPPUNIT_TEST(testSplitSingleChar_2);
CPPUNIT_TEST_SUITE_END();
public:
void testSplitSingleChar()
{
ByteVector v("a b");
ByteVectorList l = ByteVectorList::split(v, " ");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
CPPUNIT_ASSERT_EQUAL(ByteVector("a"), l[0]);
CPPUNIT_ASSERT_EQUAL(ByteVector("b"), l[1]);
}
void testSplitSingleChar_2()
{
ByteVector v("a");
ByteVectorList l = ByteVectorList::split(v, " ");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), l.size());
CPPUNIT_ASSERT_EQUAL(ByteVector("a"), l[0]);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVectorList);

View File

@@ -0,0 +1,92 @@
#include <tbytevectorstream.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;
class TestByteVectorStream : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestByteVectorStream);
CPPUNIT_TEST(testInitialData);
CPPUNIT_TEST(testWriteBlock);
CPPUNIT_TEST(testWriteBlockResize);
CPPUNIT_TEST(testReadBlock);
CPPUNIT_TEST(testRemoveBlock);
CPPUNIT_TEST(testInsert);
CPPUNIT_TEST_SUITE_END();
public:
void testInitialData()
{
ByteVector v("abcd");
ByteVectorStream stream(v);
CPPUNIT_ASSERT_EQUAL(ByteVector("abcd"), *stream.data());
}
void testWriteBlock()
{
ByteVector v("abcd");
ByteVectorStream stream(v);
stream.seek(1);
stream.writeBlock(ByteVector("xx"));
CPPUNIT_ASSERT_EQUAL(ByteVector("axxd"), *stream.data());
}
void testWriteBlockResize()
{
ByteVector v("abcd");
ByteVectorStream stream(v);
stream.seek(3);
stream.writeBlock(ByteVector("xx"));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcxx"), *stream.data());
stream.seek(5);
stream.writeBlock(ByteVector("yy"));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcxxyy"), *stream.data());
}
void testReadBlock()
{
ByteVector v("abcd");
ByteVectorStream stream(v);
CPPUNIT_ASSERT_EQUAL(ByteVector("a"), stream.readBlock(1));
CPPUNIT_ASSERT_EQUAL(ByteVector("bc"), stream.readBlock(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("d"), stream.readBlock(3));
CPPUNIT_ASSERT_EQUAL(ByteVector::null, stream.readBlock(3));
}
void testRemoveBlock()
{
ByteVector v("abcd");
ByteVectorStream stream(v);
stream.removeBlock(1, 1);
CPPUNIT_ASSERT_EQUAL(ByteVector("acd"), *stream.data());
stream.removeBlock(0, 2);
CPPUNIT_ASSERT_EQUAL(ByteVector("d"), *stream.data());
stream.removeBlock(0, 2);
CPPUNIT_ASSERT_EQUAL(ByteVector(""), *stream.data());
}
void testInsert()
{
ByteVector v("abcd");
ByteVectorStream stream(v);
stream.insert(ByteVector("xx"), 1, 1);
CPPUNIT_ASSERT_EQUAL(ByteVector("axxcd"), *stream.data());
stream.insert(ByteVector("yy"), 0, 2);
CPPUNIT_ASSERT_EQUAL(ByteVector("yyxcd"), *stream.data());
stream.insert(ByteVector("foa"), 3, 2);
CPPUNIT_ASSERT_EQUAL(ByteVector("yyxfoa"), *stream.data());
stream.insert(ByteVector("123"), 3, 0);
CPPUNIT_ASSERT_EQUAL(ByteVector("yyx123foa"), *stream.data());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVectorStream);

View File

@@ -1,8 +1,10 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <fileref.h>
#include <oggflacfile.h>
#include <vorbisfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -17,17 +19,23 @@ class TestFileRef : public CppUnit::TestFixture
CPPUNIT_TEST(testSpeex);
CPPUNIT_TEST(testFLAC);
CPPUNIT_TEST(testMP3);
CPPUNIT_TEST(testOGA_FLAC);
CPPUNIT_TEST(testOGA_Vorbis);
CPPUNIT_TEST(testMP4_1);
CPPUNIT_TEST(testMP4_2);
CPPUNIT_TEST(testMP4_3);
CPPUNIT_TEST(testTrueAudio);
CPPUNIT_TEST(testAPE);
CPPUNIT_TEST(testWav);
CPPUNIT_TEST(testUnsupported);
CPPUNIT_TEST_SUITE_END();
public:
void fileRefSave(const string &filename, const string &ext)
{
string newname = copyFile(filename, ext);
ScopedFileCopy copy(filename, ext);
string newname = copy.fileName();
FileRef *f = new FileRef(newname.c_str());
CPPUNIT_ASSERT(!f->isNull());
@@ -66,8 +74,6 @@ public:
CPPUNIT_ASSERT_EQUAL(f->tag()->track(), TagLib::uint(7));
CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2080));
delete f;
deleteFile(newname);
}
void testMusepack()
@@ -120,6 +126,38 @@ public:
fileRefSave("no-tags", ".3g2");
}
void testWav()
{
fileRefSave("empty", ".wav");
}
void testOGA_FLAC()
{
FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_flac.oga"));
CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) == NULL);
CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f->file()) != NULL);
}
void testOGA_Vorbis()
{
FileRef *f = new FileRef(TEST_FILE_PATH_C("empty_vorbis.oga"));
CPPUNIT_ASSERT(dynamic_cast<Ogg::Vorbis::File *>(f->file()) != NULL);
CPPUNIT_ASSERT(dynamic_cast<Ogg::FLAC::File *>(f->file()) == NULL);
}
void testAPE()
{
fileRefSave("mac-399", ".ape");
}
void testUnsupported()
{
FileRef f1(TEST_FILE_PATH_C("no-extension"));
CPPUNIT_ASSERT(f1.isNull());
FileRef f2(TEST_FILE_PATH_C("unsupported-extension.xxx"));
CPPUNIT_ASSERT(f2.isNull());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFileRef);

View File

@@ -0,0 +1,248 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <flacfile.h>
#include <xiphcomment.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestFLAC : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestFLAC);
CPPUNIT_TEST(testSignature);
CPPUNIT_TEST(testMultipleCommentBlocks);
CPPUNIT_TEST(testReadPicture);
CPPUNIT_TEST(testAddPicture);
CPPUNIT_TEST(testReplacePicture);
CPPUNIT_TEST(testRemoveAllPictures);
CPPUNIT_TEST(testRepeatedSave);
CPPUNIT_TEST(testSaveMultipleValues);
CPPUNIT_TEST(testDict);
CPPUNIT_TEST(testInvalid);
CPPUNIT_TEST_SUITE_END();
public:
void testSignature()
{
FLAC::File f(TEST_FILE_PATH_C("no-tags.flac"));
CPPUNIT_ASSERT_EQUAL(ByteVector("a1b141f766e9849ac3db1030a20a3c77"), f.audioProperties()->signature().toHex());
}
void testMultipleCommentBlocks()
{
ScopedFileCopy copy("multiple-vc", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("Artist 1"), f->tag()->artist());
f->tag()->setArtist("The Artist");
f->save();
delete f;
f = new FLAC::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
delete f;
}
void testReadPicture()
{
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
List<FLAC::Picture *> lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size());
FLAC::Picture *pic = lst.front();
CPPUNIT_ASSERT_EQUAL(FLAC::Picture::FrontCover, pic->type());
CPPUNIT_ASSERT_EQUAL(1, pic->width());
CPPUNIT_ASSERT_EQUAL(1, pic->height());
CPPUNIT_ASSERT_EQUAL(24, pic->colorDepth());
CPPUNIT_ASSERT_EQUAL(0, pic->numColors());
CPPUNIT_ASSERT_EQUAL(String("image/png"), pic->mimeType());
CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic->description());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic->data().size());
}
void testAddPicture()
{
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
List<FLAC::Picture *> lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size());
FLAC::Picture *newpic = new FLAC::Picture();
newpic->setType(FLAC::Picture::BackCover);
newpic->setWidth(5);
newpic->setHeight(6);
newpic->setColorDepth(16);
newpic->setNumColors(7);
newpic->setMimeType("image/jpeg");
newpic->setDescription("new image");
newpic->setData("JPEG data");
f->addPicture(newpic);
f->save();
f = new FLAC::File(newname.c_str());
lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), lst.size());
FLAC::Picture *pic = lst[0];
CPPUNIT_ASSERT_EQUAL(FLAC::Picture::FrontCover, pic->type());
CPPUNIT_ASSERT_EQUAL(1, pic->width());
CPPUNIT_ASSERT_EQUAL(1, pic->height());
CPPUNIT_ASSERT_EQUAL(24, pic->colorDepth());
CPPUNIT_ASSERT_EQUAL(0, pic->numColors());
CPPUNIT_ASSERT_EQUAL(String("image/png"), pic->mimeType());
CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic->description());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic->data().size());
pic = lst[1];
CPPUNIT_ASSERT_EQUAL(FLAC::Picture::BackCover, pic->type());
CPPUNIT_ASSERT_EQUAL(5, pic->width());
CPPUNIT_ASSERT_EQUAL(6, pic->height());
CPPUNIT_ASSERT_EQUAL(16, pic->colorDepth());
CPPUNIT_ASSERT_EQUAL(7, pic->numColors());
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), pic->mimeType());
CPPUNIT_ASSERT_EQUAL(String("new image"), pic->description());
CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), pic->data());
}
void testReplacePicture()
{
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
List<FLAC::Picture *> lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size());
FLAC::Picture *newpic = new FLAC::Picture();
newpic->setType(FLAC::Picture::BackCover);
newpic->setWidth(5);
newpic->setHeight(6);
newpic->setColorDepth(16);
newpic->setNumColors(7);
newpic->setMimeType("image/jpeg");
newpic->setDescription("new image");
newpic->setData("JPEG data");
f->removePictures();
f->addPicture(newpic);
f->save();
f = new FLAC::File(newname.c_str());
lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size());
FLAC::Picture *pic = lst[0];
CPPUNIT_ASSERT_EQUAL(FLAC::Picture::BackCover, pic->type());
CPPUNIT_ASSERT_EQUAL(5, pic->width());
CPPUNIT_ASSERT_EQUAL(6, pic->height());
CPPUNIT_ASSERT_EQUAL(16, pic->colorDepth());
CPPUNIT_ASSERT_EQUAL(7, pic->numColors());
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), pic->mimeType());
CPPUNIT_ASSERT_EQUAL(String("new image"), pic->description());
CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), pic->data());
}
void testRemoveAllPictures()
{
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
List<FLAC::Picture *> lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), lst.size());
f->removePictures();
f->save();
f = new FLAC::File(newname.c_str());
lst = f->pictureList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), lst.size());
}
void testRepeatedSave()
{
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
Tag *tag = f->tag();
CPPUNIT_ASSERT_EQUAL(String("Silence"), tag->title());
tag->setTitle("NEW TITLE");
f->save();
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE"), tag->title());
tag->setTitle("NEW TITLE 2");
f->save();
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE 2"), tag->title());
f = new FLAC::File(newname.c_str());
tag = f->tag();
CPPUNIT_ASSERT_EQUAL(String("NEW TITLE 2"), tag->title());
}
void testSaveMultipleValues()
{
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
Ogg::XiphComment* c = f->xiphComment(true);
c->addField("ARTIST", "artist 1", true);
c->addField("ARTIST", "artist 2", false);
f->save();
delete f;
f = new FLAC::File(newname.c_str());
c = f->xiphComment(true);
Ogg::FieldListMap m = c->fieldListMap();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), m["ARTIST"].size());
CPPUNIT_ASSERT_EQUAL(String("artist 1"), m["ARTIST"][0]);
CPPUNIT_ASSERT_EQUAL(String("artist 2"), m["ARTIST"][1]);
}
void testDict()
{
// test unicode & multiple values with dict interface
ScopedFileCopy copy("silence-44-s", ".flac");
string newname = copy.fileName();
FLAC::File *f = new FLAC::File(newname.c_str());
PropertyMap dict;
dict["ARTIST"].append("artøst 1");
dict["ARTIST"].append("artöst 2");
f->setProperties(dict);
f->save();
delete f;
f = new FLAC::File(newname.c_str());
dict = f->properties();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["ARTIST"].size());
CPPUNIT_ASSERT_EQUAL(String("artøst 1"), dict["ARTIST"][0]);
CPPUNIT_ASSERT_EQUAL(String("artöst 2"), dict["ARTIST"][1]);
}
void testInvalid()
{
ScopedFileCopy copy("silence-44-s", ".flac");
PropertyMap map;
map["HÄÖ"] = String("bla");
FLAC::File f(copy.fileName().c_str());
PropertyMap invalid = f.setProperties(map);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), invalid.size());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f.properties().size());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);

View File

@@ -0,0 +1,52 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <flacfile.h>
#include <flacmetadatablock.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestFLACPicture : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestFLACPicture);
CPPUNIT_TEST(testParse);
CPPUNIT_TEST(testPassThrough);
CPPUNIT_TEST_SUITE_END();
public:
void testParse()
{
const unsigned char data[] = { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x2F, 0x70, 0x6E, 0x67, 0x00, 0x00, 0x00, 0x08, 0x41, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x2E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0B, 0x13, 0x00, 0x00, 0x0B, 0x13, 0x01, 0x00, 0x9A, 0x9C, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4D, 0x45, 0x07, 0xD6, 0x0B, 0x1C, 0x0A, 0x36, 0x06, 0x08, 0x44, 0x3D, 0x32, 0x00, 0x00, 0x00, 0x1D, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6F, 0x6D, 0x6D, 0x65, 0x6E, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4D, 0x50, 0xEF, 0x64, 0x25, 0x6E, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x08, 0xD7, 0x63, 0xF8, 0xFF, 0xFF, 0x3F, 0x00, 0x05, 0xFE, 0x02, 0xFE, 0xDC, 0xCC, 0x59, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 };
const char *pdata = reinterpret_cast<const char*>(data);
FLAC::Picture pic(ByteVector(pdata, 199));
CPPUNIT_ASSERT_EQUAL(3, int(pic.type()));
CPPUNIT_ASSERT_EQUAL(1, pic.width());
CPPUNIT_ASSERT_EQUAL(1, pic.height());
CPPUNIT_ASSERT_EQUAL(24, pic.colorDepth());
CPPUNIT_ASSERT_EQUAL(0, pic.numColors());
CPPUNIT_ASSERT_EQUAL(String("image/png"), pic.mimeType());
CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic.description());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(150), pic.data().size());
}
void testPassThrough()
{
const unsigned char data[] = { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x2F, 0x70, 0x6E, 0x67, 0x00, 0x00, 0x00, 0x08, 0x41, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x2E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0B, 0x13, 0x00, 0x00, 0x0B, 0x13, 0x01, 0x00, 0x9A, 0x9C, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4D, 0x45, 0x07, 0xD6, 0x0B, 0x1C, 0x0A, 0x36, 0x06, 0x08, 0x44, 0x3D, 0x32, 0x00, 0x00, 0x00, 0x1D, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6F, 0x6D, 0x6D, 0x65, 0x6E, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4D, 0x50, 0xEF, 0x64, 0x25, 0x6E, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x08, 0xD7, 0x63, 0xF8, 0xFF, 0xFF, 0x3F, 0x00, 0x05, 0xFE, 0x02, 0xFE, 0xDC, 0xCC, 0x59, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 };
const char *pdata = reinterpret_cast<const char*>(data);
FLAC::Picture pic(ByteVector(pdata, 199));
CPPUNIT_ASSERT_EQUAL(ByteVector(pdata, 199), pic.render());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLACPicture);

View File

@@ -0,0 +1,38 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <flacunknownmetadatablock.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestFLACUnknownMetadataBlock : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestFLACUnknownMetadataBlock);
CPPUNIT_TEST(testAccessors);
CPPUNIT_TEST_SUITE_END();
public:
void testAccessors()
{
ByteVector data("abc\x01", 4);
FLAC::UnknownMetadataBlock block(42, data);
CPPUNIT_ASSERT_EQUAL(42, block.code());
CPPUNIT_ASSERT_EQUAL(data, block.data());
CPPUNIT_ASSERT_EQUAL(data, block.render());
ByteVector data2("xxx", 3);
block.setCode(13);
block.setData(data2);
CPPUNIT_ASSERT_EQUAL(13, block.code());
CPPUNIT_ASSERT_EQUAL(data2, block.data());
CPPUNIT_ASSERT_EQUAL(data2, block.render());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLACUnknownMetadataBlock);

View File

@@ -1,7 +1,10 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tstring.h>
#include <mpegfile.h>
#include <id3v1tag.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
@@ -16,8 +19,20 @@ public:
void testStripWhiteSpace()
{
ID3v1::StringHandler h;
CPPUNIT_ASSERT_EQUAL(String("Foo"), h.parse(ByteVector("Foo ")));
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
{
MPEG::File f(newname.c_str());
f.ID3v1Tag(true)->setArtist("Artist ");
f.save();
}
{
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT(f.ID3v1Tag(false));
CPPUNIT_ASSERT_EQUAL(String("Artist"), f.ID3v1Tag(false)->artist());
}
}
};

View File

@@ -1,16 +1,28 @@
#include <cppunit/extensions/HelperMacros.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string>
#include <stdio.h>
// so evil :(
#define protected public
#include <id3v2tag.h>
#include <mpegfile.h>
#include <id3v2frame.h>
#undef protected
#include <uniquefileidentifierframe.h>
#include <textidentificationframe.h>
#include <attachedpictureframe.h>
#include <unsynchronizedlyricsframe.h>
#include <generalencapsulatedobjectframe.h>
#include <relativevolumeframe.h>
#include <popularimeterframe.h>
#include <urllinkframe.h>
#include <ownershipframe.h>
#include <unknownframe.h>
#include <tdebug.h>
#include <tpropertymap.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -32,11 +44,14 @@ class TestID3v2 : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestID3v2);
CPPUNIT_TEST(testUnsynchDecode);
CPPUNIT_TEST(testDowngradeUTF8ForID3v23);
CPPUNIT_TEST(testUTF16BEDelimiter);
CPPUNIT_TEST(testUTF16Delimiter);
CPPUNIT_TEST(testReadStringField);
CPPUNIT_TEST(testParseAPIC);
CPPUNIT_TEST(testParseAPIC_UTF16_BOM);
CPPUNIT_TEST(testParseAPICv22);
CPPUNIT_TEST(testDontRender22);
CPPUNIT_TEST(testParseGEOB);
CPPUNIT_TEST(testPOPMtoString);
CPPUNIT_TEST(testParsePOPM);
@@ -52,18 +67,46 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testRenderUrlLinkFrame);
CPPUNIT_TEST(testParseUserUrlLinkFrame);
CPPUNIT_TEST(testRenderUserUrlLinkFrame);
CPPUNIT_TEST(testParseOwnershipFrame);
CPPUNIT_TEST(testRenderOwnershipFrame);
CPPUNIT_TEST(testSaveUTF16Comment);
CPPUNIT_TEST(testUpdateGenre23_1);
CPPUNIT_TEST(testUpdateGenre23_2);
CPPUNIT_TEST(testUpdateGenre24);
CPPUNIT_TEST(testUpdateDate22);
CPPUNIT_TEST(testDowngradeTo23);
// CPPUNIT_TEST(testUpdateFullDate22); TODO TYE+TDA should be upgraded to TDRC together
CPPUNIT_TEST(testCompressedFrameWithBrokenLength);
CPPUNIT_TEST(testW000);
CPPUNIT_TEST(testPropertyInterface);
CPPUNIT_TEST(testPropertyInterface2);
CPPUNIT_TEST(testDeleteFrame);
CPPUNIT_TEST(testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2);
CPPUNIT_TEST_SUITE_END();
public:
void testUnsynchDecode()
{
MPEG::File f("data/unsynch.id3", false);
MPEG::File f(TEST_FILE_PATH_C("unsynch.id3"), false);
CPPUNIT_ASSERT(f.tag());
CPPUNIT_ASSERT_EQUAL(String("My babe just cares for me"), f.tag()->title());
}
void testDowngradeUTF8ForID3v23()
{
ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF8);
StringList sl;
sl.append("Foo");
f.setText(sl);
f.header()->setVersion(3);
ByteVector data = f.render();
CPPUNIT_ASSERT_EQUAL((unsigned int)(4+4+2+1+6+2), data.size());
ID3v2::TextIdentificationFrame f2(data);
CPPUNIT_ASSERT_EQUAL(sl, f2.fieldList());
CPPUNIT_ASSERT_EQUAL(String::UTF16, f2.textEncoding());
}
void testUTF16BEDelimiter()
{
ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF16BE);
@@ -86,7 +129,7 @@ public:
void testBrokenFrame1()
{
MPEG::File f("data/broken-tenc.id3", false);
MPEG::File f(TEST_FILE_PATH_C("broken-tenc.id3"), false);
CPPUNIT_ASSERT(f.tag());
CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TENC"));
}
@@ -128,6 +171,45 @@ public:
CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xd8\xff", 3), f.picture());
}
void testParseAPICv22()
{
ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance();
ByteVector data = ByteVector("PIC"
"\x00\x00\x08"
"\x00"
"JPG"
"\x01"
"d\x00"
"\x00", 18);
ID3v2::AttachedPictureFrame *frame =
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(factory->createFrame(data, TagLib::uint(2)));
CPPUNIT_ASSERT(frame);
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), frame->mimeType());
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::FileIcon, frame->type());
CPPUNIT_ASSERT_EQUAL(String("d"), frame->description());
}
void testDontRender22()
{
ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance();
ByteVector data = ByteVector("FOO"
"\x00\x00\x08"
"\x00"
"JPG"
"\x01"
"d\x00"
"\x00", 18);
ID3v2::AttachedPictureFrame *frame =
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(factory->createFrame(data, TagLib::uint(2)));
CPPUNIT_ASSERT(frame);
ID3v2::Tag tag;
tag.addFrame(frame);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1034), tag.render().size());
}
// http://bugs.kde.org/show_bug.cgi?id=151078
void testParseGEOB()
{
@@ -197,7 +279,8 @@ public:
void testPOPMFromFile()
{
string newname = copyFile("xing", ".mp3");
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
ID3v2::PopularimeterFrame *f = new ID3v2::PopularimeterFrame();
f->setEmail("email@example.com");
@@ -211,7 +294,6 @@ public:
MPEG::File bar(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("email@example.com"), dynamic_cast<ID3v2::PopularimeterFrame *>(bar.ID3v2Tag()->frameList("POPM").front())->email());
CPPUNIT_ASSERT_EQUAL(200, dynamic_cast<ID3v2::PopularimeterFrame *>(bar.ID3v2Tag()->frameList("POPM").front())->rating());
deleteFile(newname);
}
// http://bugs.kde.org/show_bug.cgi?id=150481
@@ -312,10 +394,42 @@ public:
"http://example.com", 33), // URL
f.render());
}
void testParseOwnershipFrame()
{
ID3v2::OwnershipFrame f(
ByteVector("OWNE" // Frame ID
"\x00\x00\x00\x19" // Frame size
"\x00\x00" // Frame flags
"\x00" // Text encoding
"GBP1.99\x00" // Price paid
"20120905" // Date of purchase
"Beatport", 35)); // Seller
CPPUNIT_ASSERT_EQUAL(String("GBP1.99"), f.pricePaid());
CPPUNIT_ASSERT_EQUAL(String("20120905"), f.datePurchased());
CPPUNIT_ASSERT_EQUAL(String("Beatport"), f.seller());
}
void testRenderOwnershipFrame()
{
ID3v2::OwnershipFrame f;
f.setPricePaid("GBP1.99");
f.setDatePurchased("20120905");
f.setSeller("Beatport");
CPPUNIT_ASSERT_EQUAL(
ByteVector("OWNE" // Frame ID
"\x00\x00\x00\x19" // Frame size
"\x00\x00" // Frame flags
"\x00" // Text encoding
"GBP1.99\x00" // Price paid
"20120905" // Date of purchase
"Beatport", 35), // URL
f.render());
}
void testItunes24FrameSize()
{
MPEG::File f("data/005411.id3", false);
MPEG::File f(TEST_FILE_PATH_C("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());
@@ -324,7 +438,8 @@ public:
void testSaveUTF16Comment()
{
String::Type defaultEncoding = ID3v2::FrameFactory::instance()->defaultTextEncoding();
string newname = copyFile("xing", ".mp3");
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
ID3v2::FrameFactory::instance()->setDefaultTextEncoding(String::UTF16);
MPEG::File foo(newname.c_str());
foo.strip();
@@ -332,10 +447,312 @@ public:
foo.save();
MPEG::File bar(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("Test comment!"), bar.tag()->comment());
deleteFile(newname);
ID3v2::FrameFactory::instance()->setDefaultTextEncoding(defaultEncoding);
}
void testUpdateGenre23_1()
{
// "Refinement" is the same as the ID3v1 genre - duplicate
ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance();
ByteVector data = ByteVector("TCON" // Frame ID
"\x00\x00\x00\x10" // Frame size
"\x00\x00" // Frame flags
"\x00" // Encoding
"(22)Death Metal", 26); // Text
ID3v2::TextIdentificationFrame *frame =
static_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, TagLib::uint(3)));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), frame->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("Death Metal"), frame->fieldList()[0]);
ID3v2::Tag tag;
tag.addFrame(frame);
CPPUNIT_ASSERT_EQUAL(String("Death Metal"), tag.genre());
}
void testUpdateGenre23_2()
{
// "Refinement" is different from the ID3v1 genre
ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance();
ByteVector data = ByteVector("TCON" // Frame ID
"\x00\x00\x00\x13" // Frame size
"\x00\x00" // Frame flags
"\x00" // Encoding
"(4)Eurodisco", 23); // Text
ID3v2::TextIdentificationFrame *frame =
static_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, TagLib::uint(3)));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), frame->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("4"), frame->fieldList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]);
ID3v2::Tag tag;
tag.addFrame(frame);
CPPUNIT_ASSERT_EQUAL(String("Disco Eurodisco"), tag.genre());
}
void testUpdateGenre24()
{
ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance();
ByteVector data = ByteVector("TCON" // Frame ID
"\x00\x00\x00\x0D" // Frame size
"\x00\x00" // Frame flags
"\0" // Encoding
"14\0Eurodisco", 23); // Text
ID3v2::TextIdentificationFrame *frame =
static_cast<TagLib::ID3v2::TextIdentificationFrame*>(factory->createFrame(data, TagLib::uint(4)));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), frame->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("14"), frame->fieldList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Eurodisco"), frame->fieldList()[1]);
ID3v2::Tag tag;
tag.addFrame(frame);
CPPUNIT_ASSERT_EQUAL(String("R&B Eurodisco"), tag.genre());
}
void testUpdateDate22()
{
MPEG::File f(TEST_FILE_PATH_C("id3v22-tda.mp3"), false);
CPPUNIT_ASSERT(f.tag());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2010), f.tag()->year());
}
void testUpdateFullDate22()
{
MPEG::File f(TEST_FILE_PATH_C("id3v22-tda.mp3"), false);
CPPUNIT_ASSERT(f.tag());
CPPUNIT_ASSERT_EQUAL(String("2010-04-03"), f.ID3v2Tag()->frameListMap()["TDRC"].front()->toString());
}
void testDowngradeTo23()
{
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
ID3v2::TextIdentificationFrame *tf;
MPEG::File foo(newname.c_str());
tf = new ID3v2::TextIdentificationFrame("TDOR", String::Latin1);
tf->setText("2011-03-16");
foo.ID3v2Tag()->addFrame(tf);
tf = new ID3v2::TextIdentificationFrame("TDRC", String::Latin1);
tf->setText("2012-04-17T12:01");
foo.ID3v2Tag()->addFrame(tf);
tf = new ID3v2::TextIdentificationFrame("TMCL", String::Latin1);
tf->setText(StringList().append("Guitar").append("Artist 1").append("Drums").append("Artist 2"));
foo.ID3v2Tag()->addFrame(tf);
tf = new ID3v2::TextIdentificationFrame("TIPL", String::Latin1);
tf->setText(StringList().append("Producer").append("Artist 3").append("Mastering").append("Artist 4"));
foo.ID3v2Tag()->addFrame(tf);
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TDRL", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TDTG", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TMOO", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TPRO", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TSOA", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TSOT", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TSST", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TSOP", String::Latin1));
foo.save(MPEG::File::AllTags, true, 3);
MPEG::File bar(newname.c_str());
tf = static_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDOR").front());
CPPUNIT_ASSERT(tf);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("2011"), tf->fieldList().front());
tf = static_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDRC").front());
CPPUNIT_ASSERT(tf);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("2012"), tf->fieldList().front());
tf = dynamic_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TIPL").front());
CPPUNIT_ASSERT(tf);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), tf->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("Guitar"), tf->fieldList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Artist 1"), tf->fieldList()[1]);
CPPUNIT_ASSERT_EQUAL(String("Drums"), tf->fieldList()[2]);
CPPUNIT_ASSERT_EQUAL(String("Artist 2"), tf->fieldList()[3]);
CPPUNIT_ASSERT_EQUAL(String("Producer"), tf->fieldList()[4]);
CPPUNIT_ASSERT_EQUAL(String("Artist 3"), tf->fieldList()[5]);
CPPUNIT_ASSERT_EQUAL(String("Mastering"), tf->fieldList()[6]);
CPPUNIT_ASSERT_EQUAL(String("Artist 4"), tf->fieldList()[7]);
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TDRL"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TDTG"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TMOO"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TPRO"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSOA"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSOT"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSST"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSOP"));
}
void testCompressedFrameWithBrokenLength()
{
MPEG::File f(TEST_FILE_PATH_C("compressed_id3_frame.mp3"), false);
CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("APIC"));
#ifdef HAVE_ZLIB
ID3v2::AttachedPictureFrame *frame
= dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
CPPUNIT_ASSERT(frame);
CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType());
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type());
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size());
#else
// Skip the test if ZLIB is not installed.
// The message "Compressed frames are currently not supported." will be displayed.
ID3v2::UnknownFrame *frame
= dynamic_cast<TagLib::ID3v2::UnknownFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
CPPUNIT_ASSERT(frame);
#endif
}
void testW000()
{
MPEG::File f(TEST_FILE_PATH_C("w000.mp3"), false);
CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("W000"));
ID3v2::UrlLinkFrame *frame =
dynamic_cast<TagLib::ID3v2::UrlLinkFrame*>(f.ID3v2Tag()->frameListMap()["W000"].front());
CPPUNIT_ASSERT(frame);
CPPUNIT_ASSERT_EQUAL(String("lukas.lalinsky@example.com____"), frame->url());
}
void testPropertyInterface()
{
ScopedFileCopy copy("rare_frames", ".mp3");
string newname = copy.fileName();
MPEG::File f(newname.c_str());
PropertyMap dict = f.ID3v2Tag(false)->properties();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(6), dict.size());
CPPUNIT_ASSERT(dict.contains("USERTEXTDESCRIPTION1"));
CPPUNIT_ASSERT(dict.contains("QuodLibet::USERTEXTDESCRIPTION2"));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["USERTEXTDESCRIPTION1"].size());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), dict["QuodLibet::USERTEXTDESCRIPTION2"].size());
CPPUNIT_ASSERT_EQUAL(String("userTextData1"), dict["USERTEXTDESCRIPTION1"][0]);
CPPUNIT_ASSERT_EQUAL(String("userTextData2"), dict["USERTEXTDESCRIPTION1"][1]);
CPPUNIT_ASSERT_EQUAL(String("userTextData1"), dict["QuodLibet::USERTEXTDESCRIPTION2"][0]);
CPPUNIT_ASSERT_EQUAL(String("userTextData2"), dict["QuodLibet::USERTEXTDESCRIPTION2"][1]);
CPPUNIT_ASSERT_EQUAL(String("Pop"), dict["GENRE"].front());
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url"), dict["URL:USERURL"].front());
CPPUNIT_ASSERT_EQUAL(String("http://a.user.url/with/empty/description"), dict["URL"].front());
CPPUNIT_ASSERT_EQUAL(String("A COMMENT"), dict["COMMENT"].front());
CPPUNIT_ASSERT_EQUAL(1u, dict.unsupportedData().size());
CPPUNIT_ASSERT_EQUAL(String("UFID/supermihi@web.de"), dict.unsupportedData().front());
}
void testPropertyInterface2()
{
ID3v2::Tag tag;
ID3v2::UnsynchronizedLyricsFrame *frame1 = new ID3v2::UnsynchronizedLyricsFrame();
frame1->setDescription("test");
frame1->setText("la-la-la test");
tag.addFrame(frame1);
ID3v2::UnsynchronizedLyricsFrame *frame2 = new ID3v2::UnsynchronizedLyricsFrame();
frame2->setDescription("");
frame2->setText("la-la-la nodescription");
tag.addFrame(frame2);
ID3v2::AttachedPictureFrame *frame3 = new ID3v2::AttachedPictureFrame();
frame3->setDescription("test picture");
tag.addFrame(frame3);
ID3v2::TextIdentificationFrame *frame4 = new ID3v2::TextIdentificationFrame("TIPL");
frame4->setText("single value is invalid for TIPL");
tag.addFrame(frame4);
ID3v2::TextIdentificationFrame *frame5 = new ID3v2::TextIdentificationFrame("TMCL");
StringList tmclData;
tmclData.append("VIOLIN");
tmclData.append("a violinist");
tmclData.append("PIANO");
tmclData.append("a pianist");
frame5->setText(tmclData);
tag.addFrame(frame5);
ID3v2::UniqueFileIdentifierFrame *frame6 = new ID3v2::UniqueFileIdentifierFrame("http://musicbrainz.org", "152454b9-19ba-49f3-9fc9-8fc26545cf41");
tag.addFrame(frame6);
ID3v2::UniqueFileIdentifierFrame *frame7 = new ID3v2::UniqueFileIdentifierFrame("http://example.com", "123");
tag.addFrame(frame7);
ID3v2::UserTextIdentificationFrame *frame8 = new ID3v2::UserTextIdentificationFrame();
frame8->setDescription("MusicBrainz Album Id");
frame8->setText("95c454a5-d7e0-4d8f-9900-db04aca98ab3");
tag.addFrame(frame8);
PropertyMap properties = tag.properties();
CPPUNIT_ASSERT_EQUAL(3u, properties.unsupportedData().size());
CPPUNIT_ASSERT(properties.unsupportedData().contains("TIPL"));
CPPUNIT_ASSERT(properties.unsupportedData().contains("APIC"));
CPPUNIT_ASSERT(properties.unsupportedData().contains("UFID/http://example.com"));
CPPUNIT_ASSERT(properties.contains("PERFORMER:VIOLIN"));
CPPUNIT_ASSERT(properties.contains("PERFORMER:PIANO"));
CPPUNIT_ASSERT_EQUAL(String("a violinist"), properties["PERFORMER:VIOLIN"].front());
CPPUNIT_ASSERT_EQUAL(String("a pianist"), properties["PERFORMER:PIANO"].front());
CPPUNIT_ASSERT(properties.contains("LYRICS"));
CPPUNIT_ASSERT(properties.contains("LYRICS:TEST"));
CPPUNIT_ASSERT(properties.contains("MUSICBRAINZ_TRACKID"));
CPPUNIT_ASSERT_EQUAL(String("152454b9-19ba-49f3-9fc9-8fc26545cf41"), properties["MUSICBRAINZ_TRACKID"].front());
CPPUNIT_ASSERT(properties.contains("MUSICBRAINZ_ALBUMID"));
CPPUNIT_ASSERT_EQUAL(String("95c454a5-d7e0-4d8f-9900-db04aca98ab3"), properties["MUSICBRAINZ_ALBUMID"].front());
tag.removeUnsupportedProperties(properties.unsupportedData());
CPPUNIT_ASSERT(tag.frameList("APIC").isEmpty());
CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty());
CPPUNIT_ASSERT_EQUAL((ID3v2::UniqueFileIdentifierFrame *)0, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://example.com"));
CPPUNIT_ASSERT_EQUAL(frame6, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://musicbrainz.org"));
}
void testDeleteFrame()
{
ScopedFileCopy copy("rare_frames", ".mp3");
string newname = copy.fileName();
MPEG::File f(newname.c_str());
ID3v2::Tag *t = f.ID3v2Tag();
ID3v2::Frame *frame = t->frameList("TCON")[0];
CPPUNIT_ASSERT_EQUAL(1u, t->frameList("TCON").size());
t->removeFrame(frame, true);
f.save(MPEG::File::ID3v2);
MPEG::File f2(newname.c_str());
t = f2.ID3v2Tag();
CPPUNIT_ASSERT(t->frameList("TCON").isEmpty());
}
void testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2()
{
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
{
MPEG::File foo(newname.c_str());
foo.tag()->setArtist("Artist");
foo.save(MPEG::File::ID3v1 | MPEG::File::ID3v2);
}
{
MPEG::File bar(newname.c_str());
bar.ID3v2Tag()->removeFrames("TPE1");
// Should strip ID3v1 here and not add old values to ID3v2 again
bar.save(MPEG::File::ID3v2, true);
}
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TPE1"));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);

View File

@@ -0,0 +1,49 @@
#include <string>
#include <stdio.h>
#include <infotag.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestInfoTag : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestInfoTag);
CPPUNIT_TEST(testTitle);
CPPUNIT_TEST(testNumericFields);
CPPUNIT_TEST_SUITE_END();
public:
void testTitle()
{
RIFF::Info::Tag tag;
CPPUNIT_ASSERT_EQUAL(String(""), tag.title());
tag.setTitle("Test title 1");
tag.setFieldText("TEST", "Dummy Text");
CPPUNIT_ASSERT_EQUAL(String("Test title 1"), tag.title());
RIFF::Info::FieldListMap map = tag.fieldListMap();
CPPUNIT_ASSERT_EQUAL(String("Test title 1"), map["INAM"]);
CPPUNIT_ASSERT_EQUAL(String("Dummy Text"), map["TEST"]);
}
void testNumericFields()
{
RIFF::Info::Tag tag;
CPPUNIT_ASSERT_EQUAL((uint)0, tag.track());
tag.setTrack(1234);
CPPUNIT_ASSERT_EQUAL((uint)1234, tag.track());
CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("IPRT"));
CPPUNIT_ASSERT_EQUAL((uint)0, tag.year());
tag.setYear(1234);
CPPUNIT_ASSERT_EQUAL((uint)1234, tag.year());
CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("ICRD"));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestInfoTag);

View File

@@ -0,0 +1,136 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#include <itfile.h>
#include <tstringlist.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
using TagLib::uint;
static const String titleBefore("test song name");
static const String titleAfter("changed title");
static const String commentBefore(
"This is a sample name.\n"
"In module file formats\n"
"sample names are abused\n"
"as multiline comments.\n"
" ");
static const String newComment(
"This is a sample name!\n"
"In module file formats\n"
"sample names are abused\n"
"as multiline comments.\n"
"-----------------------------------\n"
"The previous line is truncated but starting with this line\n"
"the comment is not limeted in the line length but to 8000\n"
"additional characters (bytes).\n"
"\n"
"This is because it is saved in the 'message' proportion of\n"
"IT files.");
static const String commentAfter(
"This is a sample name!\n"
"In module file formats\n"
"sample names are abused\n"
"as multiline comments.\n"
"-------------------------\n"
"The previous line is truncated but starting with this line\n"
"the comment is not limeted in the line length but to 8000\n"
"additional characters (bytes).\n"
"\n"
"This is because it is saved in the 'message' proportion of\n"
"IT files.");
class TestIT : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestIT);
CPPUNIT_TEST(testReadTags);
CPPUNIT_TEST(testWriteTags);
CPPUNIT_TEST_SUITE_END();
public:
void testReadTags()
{
testRead(TEST_FILE_PATH_C("test.it"), titleBefore, commentBefore);
}
void testWriteTags()
{
ScopedFileCopy copy("test", ".it");
{
IT::File file(copy.fileName().c_str());
CPPUNIT_ASSERT(file.tag() != 0);
file.tag()->setTitle(titleAfter);
file.tag()->setComment(newComment);
file.tag()->setTrackerName("won't be saved");
CPPUNIT_ASSERT(file.save());
}
testRead(copy.fileName().c_str(), titleAfter, commentAfter);
}
private:
void testRead(FileName fileName, const String &title, const String &comment)
{
IT::File file(fileName);
CPPUNIT_ASSERT(file.isValid());
IT::Properties *p = file.audioProperties();
Mod::Tag *t = file.tag();
CPPUNIT_ASSERT(0 != p);
CPPUNIT_ASSERT(0 != t);
CPPUNIT_ASSERT_EQUAL( 0, p->length());
CPPUNIT_ASSERT_EQUAL( 0, p->bitrate());
CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate());
CPPUNIT_ASSERT_EQUAL(64, p->channels());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL(true, p->stereo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->instrumentCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)535, p->version());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)532, p->compatibleVersion());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 9, p->flags());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)128, p->globalVolume());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 48, p->mixVolume());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)125, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 6, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)128, p->panningSeparation());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 0, p->pitchWheelDepth());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("Impulse Tracker"), t->trackerName());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestIT);

View File

@@ -0,0 +1,126 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#include <modfile.h>
#include <tpropertymap.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
static const String titleBefore("title of song");
static const String titleAfter("changed title");
static const String commentBefore(
"Instrument names\n"
"are abused as\n"
"comments in\n"
"module file formats.\n"
"-+-+-+-+-+-+-+-+-+-+-+\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
static const String newComment(
"This line will be truncated because it is too long for a mod instrument name.\n"
"This line is ok.");
static const String commentAfter(
"This line will be trun\n"
"This line is ok.\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
class TestMod : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestMod);
CPPUNIT_TEST(testReadTags);
CPPUNIT_TEST(testWriteTags);
CPPUNIT_TEST(testPropertyInterface);
CPPUNIT_TEST_SUITE_END();
public:
void testReadTags()
{
testRead(TEST_FILE_PATH_C("test.mod"), titleBefore, commentBefore);
}
void testWriteTags()
{
ScopedFileCopy copy("test", ".mod");
{
Mod::File file(copy.fileName().c_str());
CPPUNIT_ASSERT(file.tag() != 0);
file.tag()->setTitle(titleAfter);
file.tag()->setComment(newComment);
CPPUNIT_ASSERT(file.save());
}
testRead(copy.fileName().c_str(), titleAfter, commentAfter);
CPPUNIT_ASSERT(fileEqual(
copy.fileName(),
TEST_FILE_PATH_C("changed.mod")));
}
void testPropertyInterface()
{
Mod::Tag t;
PropertyMap properties;
properties["BLA"] = String("bla");
properties["ARTIST"] = String("artist1");
properties["ARTIST"].append("artist2");
properties["TITLE"] = String("title");
PropertyMap unsupported = t.setProperties(properties);
CPPUNIT_ASSERT(unsupported.contains("BLA"));
CPPUNIT_ASSERT(unsupported.contains("ARTIST"));
CPPUNIT_ASSERT_EQUAL(properties["ARTIST"], unsupported["ARTIST"]);
CPPUNIT_ASSERT(!unsupported.contains("TITLE"));
}
private:
void testRead(FileName fileName, const String &title, const String &comment)
{
Mod::File file(fileName);
CPPUNIT_ASSERT(file.isValid());
Mod::Properties *p = file.audioProperties();
Mod::Tag *t = file.tag();
CPPUNIT_ASSERT(0 != p);
CPPUNIT_ASSERT(0 != t);
CPPUNIT_ASSERT_EQUAL(0, p->length());
CPPUNIT_ASSERT_EQUAL(0, p->bitrate());
CPPUNIT_ASSERT_EQUAL(0, p->sampleRate());
CPPUNIT_ASSERT_EQUAL(8, p->channels());
CPPUNIT_ASSERT_EQUAL(31U, p->instrumentCount());
CPPUNIT_ASSERT_EQUAL((uchar)1, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("StarTrekker"), t->trackerName());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMod);

View File

@@ -1,11 +1,12 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <mp4tag.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <mp4atom.h>
#include <mp4file.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
@@ -14,26 +15,56 @@ using namespace TagLib;
class TestMP4 : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestMP4);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testPropertiesAAC);
CPPUNIT_TEST(testPropertiesALAC);
CPPUNIT_TEST(testFreeForm);
CPPUNIT_TEST(testCheckValid);
CPPUNIT_TEST(testUpdateStco);
CPPUNIT_TEST(testSaveExisingWhenIlstIsLast);
CPPUNIT_TEST(test64BitAtom);
CPPUNIT_TEST(testGnre);
CPPUNIT_TEST(testCovrRead);
CPPUNIT_TEST(testCovrWrite);
CPPUNIT_TEST(testCovrRead2);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties()
void testPropertiesAAC()
{
MP4::File f("data/has-tags.m4a");
MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(16, ((MP4::Properties *)f.audioProperties())->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(MP4::Properties::AAC, ((MP4::Properties *)f.audioProperties())->codec());
}
void testPropertiesALAC()
{
MP4::File f(TEST_FILE_PATH_C("empty_alac.m4a"));
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(16, ((MP4::Properties *)f.audioProperties())->bitsPerSample());
CPPUNIT_ASSERT_EQUAL(MP4::Properties::ALAC, ((MP4::Properties *)f.audioProperties())->codec());
}
void testCheckValid()
{
MP4::File f(TEST_FILE_PATH_C("empty.aiff"));
CPPUNIT_ASSERT(!f.isValid());
MP4::File f2(TEST_FILE_PATH_C("has-tags.m4a"));
CPPUNIT_ASSERT(f2.isValid());
}
void testUpdateStco()
{
string filename = copyFile("no-tags", ".3g2");
ScopedFileCopy copy("no-tags", ".3g2");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
f->tag()->setArtist(ByteVector(3000, 'x'));
@@ -75,13 +106,12 @@ public:
}
delete f;
deleteFile(filename);
}
void testFreeForm()
{
string filename = copyFile("has-tags", ".m4a");
ScopedFileCopy copy("has-tags", ".m4a");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("----:com.apple.iTunes:iTunNORM"));
@@ -94,8 +124,157 @@ public:
CPPUNIT_ASSERT_EQUAL(String("Bar"), f->tag()->itemListMap()["----:org.kde.TagLib:Foo"].toStringList()[0]);
f->save();
delete f;
}
deleteFile(filename);
void testSaveExisingWhenIlstIsLast()
{
ScopedFileCopy copy("ilst-is-last", ".m4a");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
f->tag()->setComment("foo");
f->save();
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(String("82,164"), f->tag()->itemListMap()["----:com.apple.iTunes:replaygain_track_minmax"].toStringList()[0]);
CPPUNIT_ASSERT_EQUAL(String("Pearl Jam"), f->tag()->artist());
CPPUNIT_ASSERT_EQUAL(String("foo"), f->tag()->comment());
}
void test64BitAtom()
{
ScopedFileCopy copy("64bit", ".mp4");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemListMap()["cpil"].toBool());
MP4::Atoms *atoms = new MP4::Atoms(f);
MP4::Atom *moov = atoms->atoms[0];
CPPUNIT_ASSERT_EQUAL(long(77), moov->length);
f->tag()->itemListMap()["pgap"] = true;
f->save();
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemListMap()["cpil"].toBool());
CPPUNIT_ASSERT_EQUAL(true, f->tag()->itemListMap()["pgap"].toBool());
atoms = new MP4::Atoms(f);
moov = atoms->atoms[0];
// original size + 'pgap' size + padding
CPPUNIT_ASSERT_EQUAL(long(77 + 25 + 974), moov->length);
}
void testGnre()
{
MP4::File *f = new MP4::File(TEST_FILE_PATH_C("gnre.m4a"));
CPPUNIT_ASSERT_EQUAL(TagLib::String("Ska"), f->tag()->genre());
delete f;
}
void testCovrRead()
{
MP4::File *f = new MP4::File(TEST_FILE_PATH_C("has-tags.m4a"));
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
delete f;
}
void testCovrWrite()
{
ScopedFileCopy copy("has-tags", ".m4a");
string filename = copy.fileName();
MP4::File *f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo"));
f->tag()->itemListMap()["covr"] = l;
f->save();
delete f;
f = new MP4::File(filename.c_str());
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
l = f->tag()->itemListMap()["covr"].toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[2].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), l[2].data().size());
delete f;
}
void testCovrRead2()
{
MP4::File *f = new MP4::File(TEST_FILE_PATH_C("covr-junk.m4a"));
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
delete f;
}
void testProperties()
{
MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
PropertyMap tags = f.properties();
CPPUNIT_ASSERT_EQUAL(StringList("Test Artist"), tags["ARTIST"]);
tags["TRACKNUMBER"] = StringList("2/4");
tags["DISCNUMBER"] = StringList("3/5");
tags["BPM"] = StringList("123");
tags["ARTIST"] = StringList("Foo Bar");
tags["COMPILATION"] = StringList("1");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("trkn"));
CPPUNIT_ASSERT_EQUAL(2, f.tag()->itemListMap()["trkn"].toIntPair().first);
CPPUNIT_ASSERT_EQUAL(4, f.tag()->itemListMap()["trkn"].toIntPair().second);
CPPUNIT_ASSERT_EQUAL(StringList("2/4"), tags["TRACKNUMBER"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("disk"));
CPPUNIT_ASSERT_EQUAL(3, f.tag()->itemListMap()["disk"].toIntPair().first);
CPPUNIT_ASSERT_EQUAL(5, f.tag()->itemListMap()["disk"].toIntPair().second);
CPPUNIT_ASSERT_EQUAL(StringList("3/5"), tags["DISCNUMBER"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("tmpo"));
CPPUNIT_ASSERT_EQUAL(123, f.tag()->itemListMap()["tmpo"].toInt());
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("\251ART"));
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), f.tag()->itemListMap()["\251ART"].toStringList());
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("cpil"));
CPPUNIT_ASSERT_EQUAL(true, f.tag()->itemListMap()["cpil"].toBool());
CPPUNIT_ASSERT_EQUAL(StringList("1"), tags["COMPILATION"]);
tags["COMPILATION"] = StringList("0");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("cpil"));
CPPUNIT_ASSERT_EQUAL(false, f.tag()->itemListMap()["cpil"].toBool());
CPPUNIT_ASSERT_EQUAL(StringList("0"), tags["COMPILATION"]);
}
};

View File

@@ -0,0 +1,49 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <mp4coverart.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestMP4CoverArt : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestMP4CoverArt);
CPPUNIT_TEST(testSimple);
CPPUNIT_TEST(testList);
CPPUNIT_TEST_SUITE_END();
public:
void testSimple()
{
MP4::CoverArt c(MP4::CoverArt::PNG, "foo");
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c.format());
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c.data());
MP4::CoverArt c2(c);
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c2.format());
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c2.data());
MP4::CoverArt c3 = c;
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c3.format());
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c3.data());
}
void testList()
{
MP4::CoverArtList l;
l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo"));
l.append(MP4::CoverArt(MP4::CoverArt::JPEG, "bar"));
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), l[0].data());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(ByteVector("bar"), l[1].data());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4CoverArt);

View File

@@ -0,0 +1,37 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <mp4coverart.h>
#include <mp4item.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestMP4Item : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestMP4Item);
CPPUNIT_TEST(testCoverArtList);
CPPUNIT_TEST_SUITE_END();
public:
void testCoverArtList()
{
MP4::CoverArtList l;
l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo"));
l.append(MP4::CoverArt(MP4::CoverArt::JPEG, "bar"));
MP4::Item i(l);
MP4::CoverArtList l2 = i.toCoverArtList();
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), l[0].data());
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
CPPUNIT_ASSERT_EQUAL(ByteVector("bar"), l[1].data());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4Item);

View File

@@ -0,0 +1,66 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <mpcfile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestMPC : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestMPC);
CPPUNIT_TEST(testPropertiesSV8);
CPPUNIT_TEST(testPropertiesSV7);
CPPUNIT_TEST(testPropertiesSV5);
CPPUNIT_TEST(testPropertiesSV4);
CPPUNIT_TEST_SUITE_END();
public:
void testPropertiesSV8()
{
MPC::File f(TEST_FILE_PATH_C("sv8_header.mpc"));
CPPUNIT_ASSERT_EQUAL(8, f.audioProperties()->mpcVersion());
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
void testPropertiesSV7()
{
MPC::File f(TEST_FILE_PATH_C("click.mpc"));
CPPUNIT_ASSERT_EQUAL(7, f.audioProperties()->mpcVersion());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
void testPropertiesSV5()
{
MPC::File f(TEST_FILE_PATH_C("sv5_header.mpc"));
CPPUNIT_ASSERT_EQUAL(5, f.audioProperties()->mpcVersion());
CPPUNIT_ASSERT_EQUAL(26, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
void testPropertiesSV4()
{
MPC::File f(TEST_FILE_PATH_C("sv4_header.mpc"));
CPPUNIT_ASSERT_EQUAL(4, f.audioProperties()->mpcVersion());
CPPUNIT_ASSERT_EQUAL(26, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPC);

View File

@@ -1,7 +1,10 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tstring.h>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
@@ -10,16 +13,76 @@ class TestMPEG : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestMPEG);
CPPUNIT_TEST(testVersion2DurationWithXingHeader);
CPPUNIT_TEST(testSaveID3v24);
CPPUNIT_TEST(testSaveID3v24WrongParam);
CPPUNIT_TEST(testSaveID3v23);
CPPUNIT_TEST_SUITE_END();
public:
void testVersion2DurationWithXingHeader()
{
MPEG::File f("data/mpeg2.mp3");
MPEG::File f(TEST_FILE_PATH_C("mpeg2.mp3"));
CPPUNIT_ASSERT_EQUAL(5387, f.audioProperties()->length());
}
void testSaveID3v24()
{
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
String xxx = ByteVector(254, 'X');
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT_EQUAL(false, f.hasID3v2Tag());
f.tag()->setTitle(xxx);
f.tag()->setArtist("Artist A");
f.save(MPEG::File::AllTags, true, 4);
CPPUNIT_ASSERT_EQUAL(true, f.hasID3v2Tag());
MPEG::File f2(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f2.ID3v2Tag()->header()->majorVersion());
CPPUNIT_ASSERT_EQUAL(String("Artist A"), f2.tag()->artist());
CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title());
}
void testSaveID3v24WrongParam()
{
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
String xxx = ByteVector(254, 'X');
MPEG::File f(newname.c_str());
f.tag()->setTitle(xxx);
f.tag()->setArtist("Artist A");
f.save(MPEG::File::AllTags, true, 8);
MPEG::File f2(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f2.ID3v2Tag()->header()->majorVersion());
CPPUNIT_ASSERT_EQUAL(String("Artist A"), f2.tag()->artist());
CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title());
}
void testSaveID3v23()
{
ScopedFileCopy copy("xing", ".mp3");
string newname = copy.fileName();
String xxx = ByteVector(254, 'X');
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT_EQUAL(false, f.hasID3v2Tag());
f.tag()->setTitle(xxx);
f.tag()->setArtist("Artist A");
f.save(MPEG::File::AllTags, true, 3);
CPPUNIT_ASSERT_EQUAL(true, f.hasID3v2Tag());
MPEG::File f2(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f2.ID3v2Tag()->header()->majorVersion());
CPPUNIT_ASSERT_EQUAL(String("Artist A"), f2.tag()->artist());
CPPUNIT_ASSERT_EQUAL(xxx, f2.tag()->title());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);

View File

@@ -0,0 +1,104 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <oggfile.h>
#include <vorbisfile.h>
#include <oggpageheader.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestOGG : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestOGG);
CPPUNIT_TEST(testSimple);
CPPUNIT_TEST(testSplitPackets);
CPPUNIT_TEST(testDictInterface1);
CPPUNIT_TEST(testDictInterface2);
CPPUNIT_TEST_SUITE_END();
public:
void testSimple()
{
ScopedFileCopy copy("empty", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
f->tag()->setArtist("The Artist");
f->save();
delete f;
f = new Vorbis::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
delete f;
}
void testSplitPackets()
{
ScopedFileCopy copy("empty", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
f->tag()->addField("test", ByteVector(128 * 1024, 'x') + ByteVector(1, '\0'));
f->save();
delete f;
f = new Vorbis::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(19, f->lastPageHeader()->pageSequenceNumber());
delete f;
}
void testDictInterface1()
{
ScopedFileCopy copy("empty", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->tag()->properties().size());
PropertyMap newTags;
StringList values("value 1");
values.append("value 2");
newTags["ARTIST"] = values;
f->tag()->setProperties(newTags);
PropertyMap map = f->tag()->properties();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), map.size());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), map["ARTIST"].size());
CPPUNIT_ASSERT_EQUAL(String("value 1"), map["ARTIST"][0]);
delete f;
}
void testDictInterface2()
{
ScopedFileCopy copy("test", ".ogg");
string newname = copy.fileName();
Vorbis::File *f = new Vorbis::File(newname.c_str());
PropertyMap tags = f->tag()->properties();
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), tags["UNUSUALTAG"].size());
CPPUNIT_ASSERT_EQUAL(String("usual value"), tags["UNUSUALTAG"][0]);
CPPUNIT_ASSERT_EQUAL(String("another value"), tags["UNUSUALTAG"][1]);
CPPUNIT_ASSERT_EQUAL(String("öäüoΣø", String::UTF8), tags["UNICODETAG"][0]);
tags["UNICODETAG"][0] = String("νεω ναλυε", String::UTF8);
tags.erase("UNUSUALTAG");
f->tag()->setProperties(tags);
CPPUNIT_ASSERT_EQUAL(String("νεω ναλυε", String::UTF8), f->tag()->properties()["UNICODETAG"][0]);
CPPUNIT_ASSERT_EQUAL(false, f->tag()->properties().contains("UNUSUALTAG"));
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestOGG);

View File

@@ -0,0 +1,44 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <oggfile.h>
#include <oggflacfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestOggFLAC : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestOggFLAC);
CPPUNIT_TEST(testFramingBit);
CPPUNIT_TEST_SUITE_END();
public:
void testFramingBit()
{
ScopedFileCopy copy("empty_flac", ".oga");
string newname = copy.fileName();
Ogg::FLAC::File *f = new Ogg::FLAC::File(newname.c_str());
f->tag()->setArtist("The Artist");
f->save();
delete f;
f = new Ogg::FLAC::File(newname.c_str());
CPPUNIT_ASSERT_EQUAL(String("The Artist"), f->tag()->artist());
f->seek(0, File::End);
int size = f->tell();
CPPUNIT_ASSERT_EQUAL(9134, size);
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestOggFLAC);

View File

@@ -0,0 +1,61 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <opusfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestOpus : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestOpus);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testReadComments);
CPPUNIT_TEST(testWriteComments);
CPPUNIT_TEST_SUITE_END();
public:
void testProperties()
{
Ogg::Opus::File f(TEST_FILE_PATH_C("correctness_gain_silent_output.opus"));
CPPUNIT_ASSERT_EQUAL(7, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(48000, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT_EQUAL(48000, ((Ogg::Opus::Properties *)f.audioProperties())->inputSampleRate());
}
void testReadComments()
{
Ogg::Opus::File f(TEST_FILE_PATH_C("correctness_gain_silent_output.opus"));
CPPUNIT_ASSERT_EQUAL(StringList("Xiph.Org Opus testvectormaker"), f.tag()->fieldListMap()["ENCODER"]);
CPPUNIT_ASSERT(f.tag()->fieldListMap().contains("TESTDESCRIPTION"));
CPPUNIT_ASSERT(!f.tag()->fieldListMap().contains("ARTIST"));
CPPUNIT_ASSERT_EQUAL(String("libopus 0.9.11-66-g64c2dd7"), f.tag()->vendorID());
}
void testWriteComments()
{
ScopedFileCopy copy("correctness_gain_silent_output", ".opus");
string filename = copy.fileName();
Ogg::Opus::File *f = new Ogg::Opus::File(filename.c_str());
f->tag()->setArtist("Your Tester");
f->save();
delete f;
f = new Ogg::Opus::File(filename.c_str());
CPPUNIT_ASSERT_EQUAL(StringList("Xiph.Org Opus testvectormaker"), f->tag()->fieldListMap()["ENCODER"]);
CPPUNIT_ASSERT(f->tag()->fieldListMap().contains("TESTDESCRIPTION"));
CPPUNIT_ASSERT_EQUAL(StringList("Your Tester"), f->tag()->fieldListMap()["ARTIST"]);
CPPUNIT_ASSERT_EQUAL(String("libopus 0.9.11-66-g64c2dd7"), f->tag()->vendorID());
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestOpus);

View File

@@ -0,0 +1,32 @@
#include <cppunit/extensions/HelperMacros.h>
#include <tpropertymap.h>
class TestPropertyMap : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestPropertyMap);
CPPUNIT_TEST(testInvalidKeys);
CPPUNIT_TEST_SUITE_END();
public:
void testInvalidKeys()
{
TagLib::PropertyMap map1;
CPPUNIT_ASSERT(map1.isEmpty());
map1["ÄÖÜ"].append("test");
CPPUNIT_ASSERT_EQUAL(map1.size(), 1u);
TagLib::PropertyMap map2;
map2["ÄÖÜ"].append("test");
CPPUNIT_ASSERT(map1 == map2);
CPPUNIT_ASSERT(map1.contains(map2));
map2["ARTIST"] = TagLib::String("Test Artist");
CPPUNIT_ASSERT(map1 != map2);
CPPUNIT_ASSERT(map2.contains(map1));
map2["ÄÖÜ"].append("test 2");
CPPUNIT_ASSERT(!map2.contains(map1));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestPropertyMap);

View File

@@ -0,0 +1,198 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <rifffile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class PublicRIFF : public RIFF::File
{
public:
PublicRIFF(FileName file) : RIFF::File(file, BigEndian) {};
TagLib::uint riffSize() { return RIFF::File::riffSize(); };
TagLib::uint chunkCount() { return RIFF::File::chunkCount(); };
TagLib::uint chunkOffset(TagLib::uint i) { return RIFF::File::chunkOffset(i); };
TagLib::uint chunkPadding(TagLib::uint i) { return RIFF::File::chunkPadding(i); };
TagLib::uint chunkDataSize(TagLib::uint i) { return RIFF::File::chunkDataSize(i); };
ByteVector chunkName(TagLib::uint i) { return RIFF::File::chunkName(i); };
ByteVector chunkData(TagLib::uint i) { return RIFF::File::chunkData(i); };
void setChunkData(const ByteVector &name, const ByteVector &data) {
RIFF::File::setChunkData(name, data);
};
virtual TagLib::Tag* tag() const { return 0; };
virtual TagLib::AudioProperties* audioProperties() const { return 0;};
virtual bool save() { return false; };
};
class TestRIFF : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestRIFF);
CPPUNIT_TEST(testPadding);
CPPUNIT_TEST(testLastChunkAtEvenPosition);
CPPUNIT_TEST(testLastChunkAtEvenPosition2);
CPPUNIT_TEST(testLastChunkAtEvenPosition3);
CPPUNIT_TEST_SUITE_END();
public:
void testPadding()
{
ScopedFileCopy copy("empty", ".aiff");
string filename = copy.fileName();
PublicRIFF *f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x1728 + 8), f->chunkOffset(2));
f->setChunkData("TEST", "foo");
delete f;
f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f->chunkData(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0x1728 + 8), f->chunkOffset(2));
f->setChunkData("SSND", "abcd");
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(1));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcd"), f->chunkData(1));
f->seek(f->chunkOffset(1));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcd"), f->readBlock(4));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f->chunkData(2));
f->seek(f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f->readBlock(3));
delete f;
f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(1));
CPPUNIT_ASSERT_EQUAL(ByteVector("abcd"), f->chunkData(1));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f->chunkData(2));
}
void testLastChunkAtEvenPosition()
{
ScopedFileCopy copy("noise", ".aif");
string filename = copy.fileName();
PublicRIFF *f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0xff0 + 8), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(long(4400), f->length());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4399 - 8), f->riffSize());
f->setChunkData("TEST", "abcd");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f->chunkOffset(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f->chunkDataSize(3));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->chunkPadding(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4412 - 8), f->riffSize());
delete f;
f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f->chunkOffset(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f->chunkDataSize(3));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->chunkPadding(3));
CPPUNIT_ASSERT_EQUAL(long(4412), f->length());
delete f;
}
void testLastChunkAtEvenPosition2()
{
ScopedFileCopy copy("noise_odd", ".aif");
string filename = copy.fileName();
PublicRIFF *f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0xff0 + 8), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(long(4399), f->length());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4399 - 8), f->riffSize());
f->setChunkData("TEST", "abcd");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f->chunkOffset(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f->chunkDataSize(3));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->chunkPadding(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4412 - 8), f->riffSize());
delete f;
f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f->chunkOffset(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4), f->chunkDataSize(3));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->chunkPadding(3));
CPPUNIT_ASSERT_EQUAL(long(4412), f->length());
delete f;
}
void testLastChunkAtEvenPosition3()
{
ScopedFileCopy copy("noise_odd", ".aif");
string filename = copy.fileName();
PublicRIFF *f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0xff0 + 8), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(long(4399), f->length());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4399 - 8), f->riffSize());
f->setChunkData("TEST", "abc");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f->chunkOffset(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f->chunkDataSize(3));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4411 - 8), f->riffSize());
delete f;
f = new PublicRIFF(filename.c_str());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4088), f->chunkOffset(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(311), f->chunkDataSize(2));
CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f->chunkName(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(2));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4408), f->chunkOffset(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), f->chunkDataSize(3));
CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f->chunkName(3));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), f->chunkPadding(3));
CPPUNIT_ASSERT_EQUAL(long(4412), f->length());
delete f;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestRIFF);

View File

@@ -0,0 +1,123 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#include <s3mfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
static const String titleBefore("test song name");
static const String titleAfter("changed title");
static const String commentBefore(
"This is an instrument name.\n"
"Module file formats\n"
"abuse instrument names\n"
"as multiline comments.\n"
" ");
static const String newComment(
"This is an instrument name!\n"
"Module file formats\n"
"abuse instrument names\n"
"as multiline comments.\n"
"-----------------------------------\n"
"This line will be dropped and the previous is truncated.");
static const String commentAfter(
"This is an instrument name!\n"
"Module file formats\n"
"abuse instrument names\n"
"as multiline comments.\n"
"---------------------------");
class TestS3M : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestS3M);
CPPUNIT_TEST(testReadTags);
CPPUNIT_TEST(testWriteTags);
CPPUNIT_TEST_SUITE_END();
public:
void testReadTags()
{
testRead(TEST_FILE_PATH_C("test.s3m"), titleBefore, commentBefore);
}
void testWriteTags()
{
ScopedFileCopy copy("test", ".s3m");
{
S3M::File file(copy.fileName().c_str());
CPPUNIT_ASSERT(file.tag() != 0);
file.tag()->setTitle(titleAfter);
file.tag()->setComment(newComment);
file.tag()->setTrackerName("won't be saved");
CPPUNIT_ASSERT(file.save());
}
testRead(copy.fileName().c_str(), titleAfter, commentAfter);
CPPUNIT_ASSERT(fileEqual(
copy.fileName(),
TEST_FILE_PATH_C("changed.s3m")));
}
private:
void testRead(FileName fileName, const String &title, const String &comment)
{
S3M::File file(fileName);
CPPUNIT_ASSERT(file.isValid());
S3M::Properties *p = file.audioProperties();
Mod::Tag *t = file.tag();
CPPUNIT_ASSERT(0 != p);
CPPUNIT_ASSERT(0 != t);
CPPUNIT_ASSERT_EQUAL( 0, p->length());
CPPUNIT_ASSERT_EQUAL( 0, p->bitrate());
CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate());
CPPUNIT_ASSERT_EQUAL(16, p->channels());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL(false, p->stereo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->flags());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)4896, p->trackerVersion());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 2, p->fileFormatVersion());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 64, p->globalVolume());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 48, p->masterVolume());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar)125, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::uchar) 6, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String("ScreamTracker III"), t->trackerName());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestS3M);

View File

@@ -22,9 +22,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <tstring.h>
#include <string.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;
@@ -33,10 +33,16 @@ class TestString : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestString);
CPPUNIT_TEST(testString);
CPPUNIT_TEST(testRfind);
CPPUNIT_TEST(testUTF16Encode);
CPPUNIT_TEST(testUTF16Decode);
CPPUNIT_TEST(testUTF16DecodeInvalidBOM);
CPPUNIT_TEST(testUTF16DecodeEmptyWithBOM);
CPPUNIT_TEST(testAppendCharDetach);
CPPUNIT_TEST(testAppendStringDetach);
CPPUNIT_TEST(testToInt);
CPPUNIT_TEST(testSubstr);
CPPUNIT_TEST(testNewline);
CPPUNIT_TEST_SUITE_END();
public:
@@ -56,9 +62,19 @@ public:
String latin = "Jos\xe9 Carlos";
CPPUNIT_ASSERT(strcmp(latin.toCString(true), "José Carlos") == 0);
String c;
c = "1";
CPPUNIT_ASSERT(c == L"1");
c = L'\u4E00';
CPPUNIT_ASSERT(c == L"\u4E00");
String unicode2(unicode.to8Bit(true), String::UTF8);
CPPUNIT_ASSERT(unicode == unicode2);
String unicode3(L"\u65E5\u672C\u8A9E");
CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
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);
@@ -131,6 +147,87 @@ public:
CPPUNIT_ASSERT_EQUAL(String(), String(b, String::UTF16));
}
void testAppendStringDetach()
{
String a("a");
String b = a;
a += "b";
CPPUNIT_ASSERT_EQUAL(String("ab"), a);
CPPUNIT_ASSERT_EQUAL(String("a"), b);
}
void testAppendCharDetach()
{
String a("a");
String b = a;
a += 'b';
CPPUNIT_ASSERT_EQUAL(String("ab"), a);
CPPUNIT_ASSERT_EQUAL(String("a"), b);
}
void testRfind()
{
CPPUNIT_ASSERT_EQUAL(-1, String("foo.bar").rfind(".", 0));
CPPUNIT_ASSERT_EQUAL(-1, String("foo.bar").rfind(".", 1));
CPPUNIT_ASSERT_EQUAL(-1, String("foo.bar").rfind(".", 2));
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 3));
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 4));
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 5));
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 6));
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind(".", 7));
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind("."));
}
void testToInt()
{
bool ok;
CPPUNIT_ASSERT_EQUAL(String("123").toInt(&ok), 123);
CPPUNIT_ASSERT_EQUAL(ok, true);
CPPUNIT_ASSERT_EQUAL(String("-123").toInt(&ok), -123);
CPPUNIT_ASSERT_EQUAL(ok, true);
CPPUNIT_ASSERT_EQUAL(String("abc").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("1x").toInt(&ok), 1);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("-").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("123").toInt(), 123);
CPPUNIT_ASSERT_EQUAL(String("-123").toInt(), -123);
CPPUNIT_ASSERT_EQUAL(String("123aa").toInt(), 123);
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
}
void testSubstr()
{
CPPUNIT_ASSERT_EQUAL(String("01"), String("0123456").substr(0, 2));
CPPUNIT_ASSERT_EQUAL(String("12"), String("0123456").substr(1, 2));
CPPUNIT_ASSERT_EQUAL(String("123456"), String("0123456").substr(1, 200));
}
void testNewline()
{
ByteVector cr("abc\x0dxyz", 7);
ByteVector lf("abc\x0axyz", 7);
ByteVector crlf("abc\x0d\x0axyz", 8);
CPPUNIT_ASSERT_EQUAL(uint(7), String(cr).size());
CPPUNIT_ASSERT_EQUAL(uint(7), String(lf).size());
CPPUNIT_ASSERT_EQUAL(uint(8), String(crlf).size());
CPPUNIT_ASSERT_EQUAL(L'\x0d', String(cr)[3]);
CPPUNIT_ASSERT_EQUAL(L'\x0a', String(lf)[3]);
CPPUNIT_ASSERT_EQUAL(L'\x0d', String(crlf)[3]);
CPPUNIT_ASSERT_EQUAL(L'\x0a', String(crlf)[4]);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);

View File

@@ -22,8 +22,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <id3v2synchdata.h>
#include <cppunit/extensions/HelperMacros.h>
using namespace std;
using namespace TagLib;
@@ -34,6 +34,8 @@ class TestID3v2SynchData : public CppUnit::TestFixture
CPPUNIT_TEST(test1);
CPPUNIT_TEST(test2);
CPPUNIT_TEST(test3);
CPPUNIT_TEST(testToUIntBroken);
CPPUNIT_TEST(testToUIntBrokenAndTooLarge);
CPPUNIT_TEST(testDecode1);
CPPUNIT_TEST(testDecode2);
CPPUNIT_TEST_SUITE_END();
@@ -67,6 +69,23 @@ public:
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(129), v);
}
void testToUIntBroken()
{
char data[] = { 0, 0, 0, -1 };
char data2[] = { 0, 0, -1, -1 };
CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(ByteVector(data, 4)));
CPPUNIT_ASSERT_EQUAL(TagLib::uint(65535), ID3v2::SynchData::toUInt(ByteVector(data2, 4)));
}
void testToUIntBrokenAndTooLarge()
{
char data[] = { 0, 0, 0, -1, 0 };
ByteVector v(data, 5);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(v));
}
void testDecode1()
{
ByteVector a("\xff\x00\x00", 3);

View File

@@ -2,6 +2,7 @@
#include <string>
#include <stdio.h>
#include <trueaudiofile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
@@ -16,7 +17,7 @@ public:
void testReadPropertiesWithoutID3v2()
{
TrueAudio::File f("data/empty.tta");
TrueAudio::File f(TEST_FILE_PATH_C("empty.tta"));
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
}

View File

@@ -0,0 +1,36 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <wavfile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestWAV : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestWAV);
CPPUNIT_TEST(testLength);
CPPUNIT_TEST(testZeroSizeDataChunk);
CPPUNIT_TEST_SUITE_END();
public:
void testLength()
{
RIFF::WAV::File f(TEST_FILE_PATH_C("empty.wav"));
CPPUNIT_ASSERT_EQUAL(true, f.isValid());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
}
void testZeroSizeDataChunk()
{
RIFF::WAV::File f(TEST_FILE_PATH_C("zero-size-chunk.wav"));
CPPUNIT_ASSERT_EQUAL(false, f.isValid());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestWAV);

View File

@@ -0,0 +1,40 @@
#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <stdio.h>
#include <tag.h>
#include <tbytevectorlist.h>
#include <wavpackfile.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestWavPack : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestWavPack);
CPPUNIT_TEST(testBasic);
CPPUNIT_TEST(testLengthScan);
CPPUNIT_TEST_SUITE_END();
public:
void testBasic()
{
WavPack::File f(TEST_FILE_PATH_C("no_length.wv"));
WavPack::Properties *props = f.audioProperties();
CPPUNIT_ASSERT_EQUAL(44100, props->sampleRate());
CPPUNIT_ASSERT_EQUAL(2, props->channels());
CPPUNIT_ASSERT_EQUAL(1, props->bitrate());
CPPUNIT_ASSERT_EQUAL(0x407, props->version());
}
void testLengthScan()
{
WavPack::File f(TEST_FILE_PATH_C("no_length.wv"));
WavPack::Properties *props = f.audioProperties();
CPPUNIT_ASSERT_EQUAL(4, props->length());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestWavPack);

View File

@@ -0,0 +1,79 @@
#include <string>
#include <stdio.h>
#include <xiphcomment.h>
#include <tpropertymap.h>
#include <tdebug.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
class TestXiphComment : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestXiphComment);
CPPUNIT_TEST(testYear);
CPPUNIT_TEST(testSetYear);
CPPUNIT_TEST(testTrack);
CPPUNIT_TEST(testSetTrack);
CPPUNIT_TEST(testInvalidKeys);
CPPUNIT_TEST_SUITE_END();
public:
void testYear()
{
Ogg::XiphComment cmt;
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), cmt.year());
cmt.addField("YEAR", "2009");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2009), cmt.year());
cmt.addField("DATE", "2008");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2008), cmt.year());
}
void testSetYear()
{
Ogg::XiphComment cmt;
cmt.addField("YEAR", "2009");
cmt.addField("DATE", "2008");
cmt.setYear(1995);
CPPUNIT_ASSERT(cmt.fieldListMap()["YEAR"].isEmpty());
CPPUNIT_ASSERT_EQUAL(String("1995"), cmt.fieldListMap()["DATE"].front());
}
void testTrack()
{
Ogg::XiphComment cmt;
CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), cmt.track());
cmt.addField("TRACKNUM", "7");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(7), cmt.track());
cmt.addField("TRACKNUMBER", "8");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), cmt.track());
}
void testSetTrack()
{
Ogg::XiphComment cmt;
cmt.addField("TRACKNUM", "7");
cmt.addField("TRACKNUMBER", "8");
cmt.setTrack(3);
CPPUNIT_ASSERT(cmt.fieldListMap()["TRACKNUM"].isEmpty());
CPPUNIT_ASSERT_EQUAL(String("3"), cmt.fieldListMap()["TRACKNUMBER"].front());
}
void testInvalidKeys()
{
PropertyMap map;
map[""] = String("invalid key: empty string");
map["A=B"] = String("invalid key: contains '='");
map["A~B"] = String("invalid key: contains '~'");
Ogg::XiphComment cmt;
PropertyMap unsuccessful = cmt.setProperties(map);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3), unsuccessful.size());
CPPUNIT_ASSERT(cmt.properties().isEmpty());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestXiphComment);

View File

@@ -0,0 +1,216 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#include <xmfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
using namespace std;
using namespace TagLib;
static const String titleBefore("title of song");
static const String titleAfter("changed title");
static const String trackerNameBefore("MilkyTracker ");
static const String trackerNameAfter("TagLib");
static const String commentBefore(
"Instrument names\n"
"are abused as\n"
"comments in\n"
"module file formats.\n"
"-+-+-+-+-+-+-+-+-+-+-+\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n"
"Sample\n"
"names\n"
"are sometimes\n"
"also abused as\n"
"comments.");
static const String newCommentShort(
"Instrument names\n"
"are abused as\n"
"comments in\n"
"module file formats.\n"
"======================\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n"
"Sample names\n"
"are sometimes\n"
"also abused as\n"
"comments.");
static const String newCommentLong(
"Instrument names\n"
"are abused as\n"
"comments in\n"
"module file formats.\n"
"======================\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n"
"Sample names\n"
"are sometimes\n"
"also abused as\n"
"comments.\n"
"\n\n\n\n\n\n\n"
"TEST");
static const String commentAfter(
"Instrument names\n"
"are abused as\n"
"comments in\n"
"module file formats.\n"
"======================\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n"
"Sample names\n"
"are sometimes\n"
"also abused as\n"
"comments.\n");
class TestXM : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestXM);
CPPUNIT_TEST(testReadTags);
CPPUNIT_TEST(testReadStrippedTags);
CPPUNIT_TEST(testWriteTagsShort);
CPPUNIT_TEST(testWriteTagsLong);
CPPUNIT_TEST_SUITE_END();
public:
void testReadTags()
{
testRead(TEST_FILE_PATH_C("test.xm"), titleBefore,
commentBefore, trackerNameBefore);
}
void testReadStrippedTags()
{
XM::File file(TEST_FILE_PATH_C("stripped.xm"));
CPPUNIT_ASSERT(file.isValid());
XM::Properties *p = file.audioProperties();
Mod::Tag *t = file.tag();
CPPUNIT_ASSERT(0 != p);
CPPUNIT_ASSERT(0 != t);
CPPUNIT_ASSERT_EQUAL(0, p->length());
CPPUNIT_ASSERT_EQUAL(0, p->bitrate());
CPPUNIT_ASSERT_EQUAL(0, p->sampleRate());
CPPUNIT_ASSERT_EQUAL(8, p->channels());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->version());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0 , p->restartPosition());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->instrumentCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->flags());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(titleBefore, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(String::null, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(String::null, t->trackerName());
}
void testWriteTagsShort()
{
testWriteTags(newCommentShort);
}
void testWriteTagsLong()
{
testWriteTags(newCommentLong);
}
private:
void testRead(FileName fileName, const String &title,
const String &comment, const String &trackerName)
{
XM::File file(fileName);
CPPUNIT_ASSERT(file.isValid());
XM::Properties *p = file.audioProperties();
Mod::Tag *t = file.tag();
CPPUNIT_ASSERT(0 != p);
CPPUNIT_ASSERT(0 != t);
CPPUNIT_ASSERT_EQUAL(0, p->length());
CPPUNIT_ASSERT_EQUAL(0, p->bitrate());
CPPUNIT_ASSERT_EQUAL(0, p->sampleRate());
CPPUNIT_ASSERT_EQUAL(8, p->channels());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)260, p->version());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->restartPosition());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)128, p->instrumentCount());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->flags());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo());
CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed());
CPPUNIT_ASSERT_EQUAL(title, t->title());
CPPUNIT_ASSERT_EQUAL(String::null, t->artist());
CPPUNIT_ASSERT_EQUAL(String::null, t->album());
CPPUNIT_ASSERT_EQUAL(comment, t->comment());
CPPUNIT_ASSERT_EQUAL(String::null, t->genre());
CPPUNIT_ASSERT_EQUAL(0U, t->year());
CPPUNIT_ASSERT_EQUAL(0U, t->track());
CPPUNIT_ASSERT_EQUAL(trackerName, t->trackerName());
}
void testWriteTags(const String &comment)
{
ScopedFileCopy copy("test", ".xm");
{
XM::File file(copy.fileName().c_str());
CPPUNIT_ASSERT(file.tag() != 0);
file.tag()->setTitle(titleAfter);
file.tag()->setComment(comment);
file.tag()->setTrackerName(trackerNameAfter);
CPPUNIT_ASSERT(file.save());
}
testRead(copy.fileName().c_str(), titleAfter,
commentAfter, trackerNameAfter);
CPPUNIT_ASSERT(fileEqual(
copy.fileName(),
TEST_FILE_PATH_C("changed.xm")));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestXM);

View File

@@ -1,15 +1,37 @@
#include <string>
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <fcntl.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#endif
#include <stdio.h>
#include <string.h>
#include <string>
#include <fstream>
using namespace std;
inline string testFilePath(const string &filename)
{
return string(TESTS_DIR "data/") + filename;
}
#define TEST_FILE_PATH_C(f) testFilePath(f).c_str()
inline string copyFile(const string &filename, const string &ext)
{
string newname = string(tempnam(NULL, NULL)) + ext;
string oldname = string("data/") + filename + ext;
string oldname = testFilePath(filename) + ext;
#ifdef _WIN32
CopyFile(oldname.c_str(), newname.c_str(), FALSE);
SetFileAttributes(newname.c_str(), GetFileAttributes(newname.c_str()) & ~FILE_ATTRIBUTE_READONLY);
#else
char buffer[4096];
int bytes;
int inf = open(oldname.c_str(), O_RDONLY);
@@ -18,6 +40,7 @@ inline string copyFile(const string &filename, const string &ext)
write(outf, buffer, bytes);
close(outf);
close(inf);
#endif
return newname;
}
@@ -25,3 +48,57 @@ inline void deleteFile(const string &filename)
{
remove(filename.c_str());
}
inline bool fileEqual(const string &filename1, const string &filename2)
{
char buf1[BUFSIZ];
char buf2[BUFSIZ];
ifstream stream1(filename1.c_str(), ios_base::in | ios_base::binary);
ifstream stream2(filename2.c_str(), ios_base::in | ios_base::binary);
if(!stream1 && !stream2) return true;
if(!stream1 || !stream2) return false;
for(;;)
{
stream1.read(buf1, BUFSIZ);
stream2.read(buf2, BUFSIZ);
streamsize n1 = stream1.gcount();
streamsize n2 = stream2.gcount();
if(n1 != n2) return false;
if(n1 == 0) break;
if(memcmp(buf1, buf2, n1) != 0) return false;
}
return stream1.good() == stream2.good();
}
class ScopedFileCopy
{
public:
ScopedFileCopy(const string &filename, const string &ext, bool deleteFile=true)
{
m_deleteFile = deleteFile;
m_filename = copyFile(filename, ext);
}
~ScopedFileCopy()
{
if(m_deleteFile)
deleteFile(m_filename);
}
string fileName()
{
return m_filename;
}
private:
bool m_deleteFile;
string m_filename;
};