From 7ba63ad79ff81edc4c1e0bc4aad3583a120d1dbc Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 16 Mar 2022 19:38:51 +0100 Subject: [PATCH] cli: Display at least MIME-type if field cannot be displayed as string --- cli/helper.cpp | 3 ++- tests/cli.cpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cli/helper.cpp b/cli/helper.cpp index 895c7a0..04aa277 100644 --- a/cli/helper.cpp +++ b/cli/helper.cpp @@ -262,7 +262,8 @@ static void printTagValue(const TagValue &value) cout << value.toString(TagTextEncoding::Utf8); } catch (const ConversionException &) { // handle case when value can not be displayed as string - cout << "can't display as string (see --extract)"; + const auto type = !value.mimeType().empty() ? std::string_view(value.mimeType()) : std::string_view("data"); + cout << "can't display " << type << " as string (use --extract)"; } cout << '\n'; } diff --git a/tests/cli.cpp b/tests/cli.cpp index a8f0509..100338b 100644 --- a/tests/cli.cpp +++ b/tests/cli.cpp @@ -263,12 +263,12 @@ void CliTests::testModifyingCover() CPPUNIT_ASSERT_MESSAGE("covers added", testContainsSubstrings(stdout, { " - \e[1mID3v2 tag (version 2.3.0)\e[0m\n", " Lyrics I\nam\nno\nsong\nwriter\n", - " Cover (other) can't display as string (see --extract)\n" - " Cover (front-cover) can't display as string (see --extract)\n" + " Cover (other) can't display image/png as string (use --extract)\n" + " Cover (front-cover) can't display image/png as string (use --extract)\n" " description: foo\n" - " Cover (front-cover) can't display as string (see --extract)\n" + " Cover (front-cover) can't display image/png as string (use --extract)\n" " description: bar\n" - " Cover (back-cover) can't display as string (see --extract)\n" })); + " Cover (back-cover) can't display image/png as string (use --extract)\n" })); CPPUNIT_ASSERT_EQUAL(0, remove(mp3File1Backup.data())); // test whether empty trailing ":" does *not* affect all descriptions @@ -279,12 +279,12 @@ void CliTests::testModifyingCover() testContainsSubstrings(stdout, { " - \e[1mID3v2 tag (version 2.3.0)\e[0m\n", - " Cover (other) can't display as string (see --extract)\n" - " Cover (front-cover) can't display as string (see --extract)\n" + " Cover (other) can't display image/png as string (use --extract)\n" + " Cover (front-cover) can't display image/png as string (use --extract)\n" " description: foo\n" - " Cover (front-cover) can't display as string (see --extract)\n" + " Cover (front-cover) can't display image/png as string (use --extract)\n" " description: bar\n" - " Cover (back-cover) can't display as string (see --extract)\n", + " Cover (back-cover) can't display image/png as string (use --extract)\n", })); CPPUNIT_ASSERT_EQUAL(-1, remove(mp3File1Backup.data())); @@ -297,8 +297,8 @@ void CliTests::testModifyingCover() testContainsSubstrings(stdout, { " - \e[1mID3v2 tag (version 2.3.0)\e[0m\n", - " Cover (other) can't display as string (see --extract)\n" - " Cover (back-cover) can't display as string (see --extract)\n", + " Cover (other) can't display image/png as string (use --extract)\n" + " Cover (back-cover) can't display image/png as string (use --extract)\n", })); CPPUNIT_ASSERT_EQUAL(0, remove(mp3File1Backup.data()));