diff options
author | Max Kellermann <max@musicpd.org> | 2019-07-29 11:15:04 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-07-29 11:32:00 +0200 |
commit | 991bbea87527e401704e6e4a3b8efc017bf6c71d (patch) | |
tree | 5054e904074ef384a7d38361fdde0058414285f0 /test | |
parent | a2d2210713ef12aee68198416150234e8981c4be (diff) | |
parent | b95533488283a9ea35a82084c8496715d38a0ba3 (diff) |
Merge branch 'v0.21.x'
Diffstat (limited to 'test')
-rw-r--r-- | test/RunChromaprint.cxx | 11 | ||||
-rw-r--r-- | test/run_decoder.cxx | 11 | ||||
-rw-r--r-- | test/test_translate_song.cxx | 26 |
3 files changed, 38 insertions, 10 deletions
diff --git a/test/RunChromaprint.cxx b/test/RunChromaprint.cxx index 4e8b03148..abcce7696 100644 --- a/test/RunChromaprint.cxx +++ b/test/RunChromaprint.cxx @@ -23,6 +23,7 @@ #include "event/Thread.hxx" #include "decoder/DecoderList.hxx" #include "decoder/DecoderPlugin.hxx" +#include "decoder/DecoderAPI.hxx" /* for class StopDecoder */ #include "input/Init.hxx" #include "input/InputStream.hxx" #include "fs/Path.hxx" @@ -126,10 +127,16 @@ try { MyChromaprintDecoderClient client; if (plugin->file_decode != nullptr) { - plugin->FileDecode(client, Path::FromFS(c.uri)); + try { + plugin->FileDecode(client, Path::FromFS(c.uri)); + } catch (StopDecoder) { + } } else if (plugin->stream_decode != nullptr) { auto is = InputStream::OpenReady(c.uri, client.mutex); - plugin->StreamDecode(client, *is); + try { + plugin->StreamDecode(client, *is); + } catch (StopDecoder) { + } } else { fprintf(stderr, "Decoder plugin is not usable\n"); return EXIT_FAILURE; diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx index c94b5ee07..f7e3d6739 100644 --- a/test/run_decoder.cxx +++ b/test/run_decoder.cxx @@ -21,6 +21,7 @@ #include "event/Thread.hxx" #include "decoder/DecoderList.hxx" #include "decoder/DecoderPlugin.hxx" +#include "decoder/DecoderAPI.hxx" /* for class StopDecoder */ #include "DumpDecoderClient.hxx" #include "input/Init.hxx" #include "input/InputStream.hxx" @@ -116,10 +117,16 @@ try { DumpDecoderClient client; if (plugin->file_decode != nullptr) { - plugin->FileDecode(client, Path::FromFS(c.uri)); + try { + plugin->FileDecode(client, Path::FromFS(c.uri)); + } catch (StopDecoder) { + } } else if (plugin->stream_decode != nullptr) { auto is = InputStream::OpenReady(c.uri, client.mutex); - plugin->StreamDecode(client, *is); + try { + plugin->StreamDecode(client, *is); + } catch (StopDecoder) { + } } else { fprintf(stderr, "Decoder plugin is not usable\n"); return EXIT_FAILURE; diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index abd2d0cd6..7b4b6b777 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -207,7 +207,6 @@ TEST_F(TranslateSongTest, Insecure) TEST_F(TranslateSongTest, Secure) { DetachedSong song1(uri1, MakeTag1b()); - auto s1 = ToString(song1); auto se = ToString(DetachedSong(uri1, MakeTag1c())); const SongLoader loader(nullptr, nullptr); @@ -226,14 +225,12 @@ TEST_F(TranslateSongTest, InDatabase) loader)); DetachedSong song2(uri2, MakeTag2b()); - auto s1 = ToString(song2); auto se = ToString(DetachedSong(uri2, MakeTag2c())); EXPECT_TRUE(playlist_check_translate_song(song2, nullptr, loader)); EXPECT_EQ(se, ToString(song2)); DetachedSong song3("/music/foo/bar.ogg", MakeTag2b()); - s1 = ToString(song3); se = ToString(DetachedSong(uri2, MakeTag2c())); EXPECT_TRUE(playlist_check_translate_song(song3, nullptr, loader)); @@ -249,7 +246,6 @@ TEST_F(TranslateSongTest, Relative) /* map to music_directory */ DetachedSong song1("bar.ogg", MakeTag2b()); - auto s1 = ToString(song1); auto se = ToString(DetachedSong(uri2, MakeTag2c())); EXPECT_TRUE(playlist_check_translate_song(song1, "/music/foo", insecure_loader)); @@ -262,7 +258,6 @@ TEST_F(TranslateSongTest, Relative) /* legal because secure=true */ DetachedSong song3("bar.ogg", MakeTag1b()); - s1 = ToString(song3); se = ToString(DetachedSong(uri1, MakeTag1c())); EXPECT_TRUE(playlist_check_translate_song(song3, "/foo", secure_loader)); @@ -270,9 +265,28 @@ TEST_F(TranslateSongTest, Relative) /* relative to http:// */ DetachedSong song4("bar.ogg", MakeTag2a()); - s1 = ToString(song4); se = ToString(DetachedSong("http://example.com/foo/bar.ogg", MakeTag2a())); EXPECT_TRUE(playlist_check_translate_song(song4, "http://example.com/foo", insecure_loader)); EXPECT_EQ(se, ToString(song4)); } + +TEST_F(TranslateSongTest, Backslash) +{ + const SongLoader loader(reinterpret_cast<const Database *>(1), + storage); + + DetachedSong song1("foo\\bar.ogg", MakeTag2b()); +#ifdef _WIN32 + /* on Windows, all backslashes are converted to slashes in + relative paths from playlists */ + auto se = ToString(DetachedSong(uri2, MakeTag2c())); + EXPECT_TRUE(playlist_check_translate_song(song1, nullptr, + loader)); + EXPECT_EQ(se, ToString(song1)); +#else + /* backslash only supported on Windows */ + EXPECT_FALSE(playlist_check_translate_song(song1, nullptr, + loader)); +#endif +} |