diff --git a/tests/src/collectionbackend_test.cpp b/tests/src/collectionbackend_test.cpp index eb2729bbc..efe300e45 100644 --- a/tests/src/collectionbackend_test.cpp +++ b/tests/src/collectionbackend_test.cpp @@ -56,7 +56,7 @@ class CollectionBackendTest : public ::testing::Test { // Returns a valid song with all the required fields set Song ret; ret.set_directory_id(directory_id); - ret.set_url(QUrl::fromLocalFile(QStringLiteral("foo.flac"))); + ret.set_url(QUrl::fromLocalFile(u"foo.flac"_s)); ret.set_mtime(1); ret.set_ctime(1); ret.set_filesize(1); @@ -82,12 +82,12 @@ TEST_F(CollectionBackendTest, AddDirectory) { QSignalSpy spy(&*backend_, &CollectionBackend::DirectoryAdded); - backend_->AddDirectory(QStringLiteral("/tmp")); + backend_->AddDirectory(u"/tmp"_s); // Check the signal was emitted correctly ASSERT_EQ(1, spy.count()); CollectionDirectory dir = spy[0][0].value(); - EXPECT_EQ(QStringLiteral("/tmp"), dir.path); + EXPECT_EQ(u"/tmp"_s, dir.path); EXPECT_EQ(1, dir.id); EXPECT_EQ(0, spy[0][1].value().size()); @@ -98,7 +98,7 @@ TEST_F(CollectionBackendTest, RemoveDirectory) { // Add a directory CollectionDirectory dir; dir.id = 1; - dir.path = QStringLiteral("/tmp"); + dir.path = u"/tmp"_s; backend_->AddDirectory(dir.path); QSignalSpy spy(&*backend_, &CollectionBackend::DirectoryDeleted); @@ -109,7 +109,7 @@ TEST_F(CollectionBackendTest, RemoveDirectory) { // Check the signal was emitted correctly ASSERT_EQ(1, spy.count()); dir = spy[0][0].value(); - EXPECT_EQ(QStringLiteral("/tmp"), dir.path); + EXPECT_EQ(u"/tmp"_s, dir.path); EXPECT_EQ(1, dir.id); } @@ -123,14 +123,14 @@ class SingleSong : public CollectionBackendTest { CollectionBackendTest::SetUp(); // Add a directory - this will get ID 1 - backend_->AddDirectory(QStringLiteral("/tmp")); + backend_->AddDirectory(u"/tmp"_s); // Make a song in that directory song_ = MakeDummySong(1); - song_.set_title(QStringLiteral("Title")); - song_.set_artist(QStringLiteral("Artist")); - song_.set_album(QStringLiteral("Album")); - song_.set_url(QUrl::fromLocalFile(QStringLiteral("foo.flac"))); + song_.set_title(u"Title"_s); + song_.set_artist(u"Artist"_s); + song_.set_album(u"Album"_s); + song_.set_url(QUrl::fromLocalFile(u"foo.flac"_s)); } void AddDummySong() { @@ -166,7 +166,7 @@ TEST_F(SingleSong, GetSongWithNoAlbum) { EXPECT_EQ(1, backend_->GetAllArtists().size()); CollectionBackend::AlbumList albums = backend_->GetAllAlbums(); EXPECT_EQ(1, albums.size()); - EXPECT_EQ(QStringLiteral("Artist"), albums[0].album_artist); + EXPECT_EQ(u"Artist"_s, albums[0].album_artist); EXPECT_EQ(""_L1, albums[0].album); } @@ -199,7 +199,7 @@ TEST_F(SingleSong, GetAlbumsByArtist) { AddDummySong(); if (HasFatalFailure()) return; - CollectionBackend::AlbumList albums = backend_->GetAlbumsByArtist(QStringLiteral("Artist")); + CollectionBackend::AlbumList albums = backend_->GetAlbumsByArtist(u"Artist"_s); ASSERT_EQ(1, albums.size()); EXPECT_EQ(song_.album(), albums[0].album); EXPECT_EQ(song_.artist(), albums[0].album_artist); @@ -211,7 +211,7 @@ TEST_F(SingleSong, GetAlbumArt) { AddDummySong(); if (HasFatalFailure()) return; - CollectionBackend::Album album = backend_->GetAlbumArt(QStringLiteral("Artist"), QStringLiteral("Album")); + CollectionBackend::Album album = backend_->GetAlbumArt(u"Artist"_s, u"Album"_s); EXPECT_EQ(song_.album(), album.album); EXPECT_EQ(song_.effective_albumartist(), album.album_artist); @@ -222,7 +222,7 @@ TEST_F(SingleSong, GetSongs) { AddDummySong(); if (HasFatalFailure()) return; - SongList songs = backend_->GetAlbumSongs(QStringLiteral("Artist"), QStringLiteral("Album")); + SongList songs = backend_->GetAlbumSongs(u"Artist"_s, u"Album"_s); ASSERT_EQ(1, songs.size()); EXPECT_EQ(song_.album(), songs[0].album()); EXPECT_EQ(song_.artist(), songs[0].artist()); @@ -265,7 +265,7 @@ TEST_F(SingleSong, UpdateSong) { Song new_song(song_); new_song.set_id(1); - new_song.set_title(QStringLiteral("A different title")); + new_song.set_title(u"A different title"_s); QSignalSpy added_spy(&*backend_, &CollectionBackend::SongsAdded); QSignalSpy changed_spy(&*backend_, &CollectionBackend::SongsChanged); @@ -279,7 +279,7 @@ TEST_F(SingleSong, UpdateSong) { SongList songs_changed = *(reinterpret_cast(changed_spy[0][0].data())); ASSERT_EQ(1, songs_changed.size()); - EXPECT_EQ(QStringLiteral("A different title"), songs_changed[0].title()); + EXPECT_EQ(u"A different title"_s, songs_changed[0].title()); EXPECT_EQ(1, songs_changed[0].id()); } @@ -300,7 +300,7 @@ TEST_F(SingleSong, DeleteSongs) { SongList songs_deleted = *(reinterpret_cast(deleted_spy[0][0].data())); ASSERT_EQ(1, songs_deleted.size()); - EXPECT_EQ(QStringLiteral("Title"), songs_deleted[0].title()); + EXPECT_EQ(u"Title"_s, songs_deleted[0].title()); EXPECT_EQ(1, songs_deleted[0].id()); // Check we can't retrieve that song any more @@ -333,7 +333,7 @@ TEST_F(SingleSong, MarkSongsUnavailable) { SongList songs_deleted = *(reinterpret_cast(deleted_spy[0][0].data())); ASSERT_EQ(1, songs_deleted.size()); - EXPECT_EQ(QStringLiteral("Title"), songs_deleted[0].title()); + EXPECT_EQ(u"Title"_s, songs_deleted[0].title()); EXPECT_EQ(1, songs_deleted[0].id()); // Check the song is marked as deleted. @@ -354,16 +354,16 @@ class TestUrls : public CollectionBackendTest { protected: void SetUp() override { CollectionBackendTest::SetUp(); - backend_->AddDirectory(QStringLiteral("/mnt/music")); + backend_->AddDirectory(u"/mnt/music"_s); } }; TEST_F(TestUrls, TestUrls) { - QStringList strings = QStringList() << QStringLiteral("file:///mnt/music/01 - Pink Floyd - Echoes.flac") - << QStringLiteral("file:///mnt/music/02 - Björn Afzelius - Det räcker nu.flac") - << QStringLiteral("file:///mnt/music/03 - Vazelina Bilopphøggers - Bomull i øra.flac") - << QStringLiteral("file:///mnt/music/Test !#$%&'()-@^_`{}~..flac"); + QStringList strings = QStringList() << u"file:///mnt/music/01 - Pink Floyd - Echoes.flac"_s + << u"file:///mnt/music/02 - Björn Afzelius - Det räcker nu.flac"_s + << u"file:///mnt/music/03 - Vazelina Bilopphøggers - Bomull i øra.flac"_s + << u"file:///mnt/music/Test !#$%&'()-@^_`{}~..flac"_s; const QList urls = QUrl::fromStringList(strings); SongList songs; @@ -375,9 +375,9 @@ TEST_F(TestUrls, TestUrls) { Song song(Song::Source::Collection); song.set_directory_id(1); - song.set_title(QStringLiteral("Test Title")); - song.set_album(QStringLiteral("Test Album")); - song.set_artist(QStringLiteral("Test Artist")); + song.set_title(u"Test Title"_s); + song.set_album(u"Test Album"_s); + song.set_artist(u"Test Artist"_s); song.set_url(url); song.set_length_nanosec(kNsecPerSec); song.set_mtime(1); @@ -419,7 +419,7 @@ TEST_F(TestUrls, TestUrls) { QSqlQuery q(db); q.prepare(QStringLiteral("SELECT url FROM %1 WHERE url = :url").arg(QLatin1String(SCollection::kSongsTable))); - q.bindValue(QStringLiteral(":url"), url.toString(QUrl::FullyEncoded)); + q.bindValue(u":url"_s, url.toString(QUrl::FullyEncoded)); EXPECT_TRUE(q.exec()); while (q.next()) { @@ -435,18 +435,18 @@ class UpdateSongsBySongID : public CollectionBackendTest { protected: void SetUp() override { CollectionBackendTest::SetUp(); - backend_->AddDirectory(QStringLiteral("/mnt/music")); + backend_->AddDirectory(u"/mnt/music"_s); } }; TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { - const QStringList song_ids = QStringList() << QStringLiteral("song1") - << QStringLiteral("song2") - << QStringLiteral("song3") - << QStringLiteral("song4") - << QStringLiteral("song5") - << QStringLiteral("song6"); + const QStringList song_ids = QStringList() << u"song1"_s + << u"song2"_s + << u"song3"_s + << u"song4"_s + << u"song5"_s + << u"song6"_s; { // Add songs SongMap songs; @@ -454,15 +454,15 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { for (const QString &song_id : song_ids) { QUrl url; - url.setScheme(QStringLiteral("file")); - url.setPath(QStringLiteral("/music/") + song_id); + url.setScheme(u"file"_s); + url.setPath(u"/music/"_s + song_id); Song song(Song::Source::Collection); song.set_song_id(song_id); song.set_directory_id(1); - song.set_title(QStringLiteral("Test Title ") + song_id); - song.set_album(QStringLiteral("Test Album")); - song.set_artist(QStringLiteral("Test Artist")); + song.set_title(u"Test Title "_s + song_id); + song.set_album(u"Test Album"_s); + song.set_artist(u"Test Artist"_s); song.set_url(url); song.set_length_nanosec(kNsecPerSec); song.set_mtime(1); @@ -517,23 +517,23 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { SongMap songs; - const QStringList song_ids2 = QStringList() << QStringLiteral("song1") - << QStringLiteral("song4") - << QStringLiteral("song5") - << QStringLiteral("song6"); + const QStringList song_ids2 = QStringList() << u"song1"_s + << u"song4"_s + << u"song5"_s + << u"song6"_s; for (const QString &song_id : song_ids2) { QUrl url; - url.setScheme(QStringLiteral("file")); - url.setPath(QStringLiteral("/music/") + song_id); + url.setScheme(u"file"_s); + url.setPath(u"/music/"_s + song_id); Song song(Song::Source::Collection); song.set_song_id(song_id); song.set_directory_id(1); - song.set_title(QStringLiteral("Test Title ") + song_id); - song.set_album(QStringLiteral("Test Album")); - song.set_artist(QStringLiteral("Test Artist")); + song.set_title(u"Test Title "_s + song_id); + song.set_album(u"Test Album"_s); + song.set_artist(u"Test Artist"_s); song.set_url(url); song.set_length_nanosec(kNsecPerSec); song.set_mtime(1); @@ -551,8 +551,8 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { ASSERT_EQ(1, spy2.count()); SongList deleted_songs = spy2[0][0].value(); EXPECT_EQ(deleted_songs.count(), 2); - EXPECT_EQ(deleted_songs[0].song_id(), QStringLiteral("song2")); - EXPECT_EQ(deleted_songs[1].song_id(), QStringLiteral("song3")); + EXPECT_EQ(deleted_songs[0].song_id(), u"song2"_s); + EXPECT_EQ(deleted_songs[1].song_id(), u"song3"_s); } @@ -563,23 +563,23 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { SongMap songs; - const QStringList song_ids2 = QStringList() << QStringLiteral("song1") - << QStringLiteral("song4") - << QStringLiteral("song5") - << QStringLiteral("song6"); + const QStringList song_ids2 = QStringList() << u"song1"_s + << u"song4"_s + << u"song5"_s + << u"song6"_s; for (const QString &song_id : song_ids2) { QUrl url; - url.setScheme(QStringLiteral("file")); - url.setPath(QStringLiteral("/music/") + song_id); + url.setScheme(u"file"_s); + url.setPath(u"/music/"_s + song_id); Song song(Song::Source::Collection); song.set_song_id(song_id); song.set_directory_id(1); - song.set_title(QStringLiteral("Test Title ") + song_id); - song.set_album(QStringLiteral("Test Album")); - song.set_artist(QStringLiteral("Test Artist")); + song.set_title(u"Test Title "_s + song_id); + song.set_album(u"Test Album"_s); + song.set_artist(u"Test Artist"_s); song.set_url(url); song.set_length_nanosec(kNsecPerSec); song.set_mtime(1); @@ -591,8 +591,8 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { } - songs[QStringLiteral("song1")].set_artist(QStringLiteral("New artist")); - songs[QStringLiteral("song6")].set_artist(QStringLiteral("New artist")); + songs[u"song1"_s].set_artist(u"New artist"_s); + songs[u"song6"_s].set_artist(u"New artist"_s); backend_->UpdateSongsBySongID(songs); @@ -602,8 +602,8 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) { SongList changed_songs = spy3[0][0].value(); EXPECT_EQ(changed_songs.count(), 2); - EXPECT_EQ(changed_songs[0].song_id(), QStringLiteral("song1")); - EXPECT_EQ(changed_songs[1].song_id(), QStringLiteral("song6")); + EXPECT_EQ(changed_songs[0].song_id(), u"song1"_s); + EXPECT_EQ(changed_songs[1].song_id(), u"song6"_s); } diff --git a/tests/src/collectionmodel_test.cpp b/tests/src/collectionmodel_test.cpp index daaf6241a..3d75b935a 100644 --- a/tests/src/collectionmodel_test.cpp +++ b/tests/src/collectionmodel_test.cpp @@ -67,11 +67,11 @@ class CollectionModelTest : public ::testing::Test { song.set_directory_id(1); if (song.mtime() == 0) song.set_mtime(1); if (song.ctime() == 0) song.set_ctime(1); - if (song.url().isEmpty()) song.set_url(QUrl(QStringLiteral("file:///tmp/foo"))); + if (song.url().isEmpty()) song.set_url(QUrl(u"file:///tmp/foo"_s)); if (song.filesize() == -1) song.set_filesize(1); if (!added_dir_) { - backend_->AddDirectory(QStringLiteral("/tmp")); + backend_->AddDirectory(u"/tmp"_s); added_dir_ = true; } @@ -105,23 +105,23 @@ TEST_F(CollectionModelTest, Initialization) { TEST_F(CollectionModelTest, WithInitialArtists) { - AddSong(QStringLiteral("Title"), QStringLiteral("Artist 1"), QStringLiteral("Album"), 123); - AddSong(QStringLiteral("Title"), QStringLiteral("Artist 2"), QStringLiteral("Album"), 123); - AddSong(QStringLiteral("Title"), QStringLiteral("Foo"), QStringLiteral("Album"), 123); + AddSong(u"Title"_s, u"Artist 1"_s, u"Album"_s, 123); + AddSong(u"Title"_s, u"Artist 2"_s, u"Album"_s, 123); + AddSong(u"Title"_s, u"Foo"_s, u"Album"_s, 123); ASSERT_EQ(5, collection_filter_->rowCount(QModelIndex())); - EXPECT_EQ(QStringLiteral("A"), collection_filter_->index(0, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("Artist 1"), collection_filter_->index(1, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("Artist 2"), collection_filter_->index(2, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("F"), collection_filter_->index(3, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("Foo"), collection_filter_->index(4, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"A"_s, collection_filter_->index(0, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"Artist 1"_s, collection_filter_->index(1, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"Artist 2"_s, collection_filter_->index(2, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"F"_s, collection_filter_->index(3, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"Foo"_s, collection_filter_->index(4, 0, QModelIndex()).data().toString()); } TEST_F(CollectionModelTest, CompilationAlbums) { Song song; - song.Init(QStringLiteral("Title"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); + song.Init(u"Title"_s, u"Artist"_s, u"Album"_s, 123); song.set_compilation(true); song.set_mtime(0); song.set_ctime(0); @@ -131,62 +131,62 @@ TEST_F(CollectionModelTest, CompilationAlbums) { ASSERT_EQ(1, model_->rowCount(QModelIndex())); QModelIndex va_index = model_->index(0, 0, QModelIndex()); - EXPECT_EQ(QStringLiteral("Various artists"), va_index.data().toString()); + EXPECT_EQ(u"Various artists"_s, va_index.data().toString()); EXPECT_TRUE(model_->hasChildren(va_index)); ASSERT_EQ(model_->rowCount(va_index), 1); QModelIndex album_index = model_->index(0, 0, va_index); - EXPECT_EQ(model_->data(album_index).toString(), QStringLiteral("Album")); + EXPECT_EQ(model_->data(album_index).toString(), u"Album"_s); EXPECT_TRUE(model_->hasChildren(album_index)); } TEST_F(CollectionModelTest, NumericHeaders) { - AddSong(QStringLiteral("Title"), QStringLiteral("1artist"), QStringLiteral("Album"), 123); - AddSong(QStringLiteral("Title"), QStringLiteral("2artist"), QStringLiteral("Album"), 123); - AddSong(QStringLiteral("Title"), QStringLiteral("0artist"), QStringLiteral("Album"), 123); - AddSong(QStringLiteral("Title"), QStringLiteral("zartist"), QStringLiteral("Album"), 123); + AddSong(u"Title"_s, u"1artist"_s, u"Album"_s, 123); + AddSong(u"Title"_s, u"2artist"_s, u"Album"_s, 123); + AddSong(u"Title"_s, u"0artist"_s, u"Album"_s, 123); + AddSong(u"Title"_s, u"zartist"_s, u"Album"_s, 123); ASSERT_EQ(6, collection_filter_->rowCount(QModelIndex())); - EXPECT_EQ(QStringLiteral("0-9"), collection_filter_->index(0, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("0artist"), collection_filter_->index(1, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("1artist"), collection_filter_->index(2, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("2artist"), collection_filter_->index(3, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("Z"), collection_filter_->index(4, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("zartist"), collection_filter_->index(5, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"0-9"_s, collection_filter_->index(0, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"0artist"_s, collection_filter_->index(1, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"1artist"_s, collection_filter_->index(2, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"2artist"_s, collection_filter_->index(3, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"Z"_s, collection_filter_->index(4, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"zartist"_s, collection_filter_->index(5, 0, QModelIndex()).data().toString()); } TEST_F(CollectionModelTest, MixedCaseHeaders) { - AddSong(QStringLiteral("Title"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); - AddSong(QStringLiteral("Title"), QStringLiteral("artist"), QStringLiteral("Album"), 123); + AddSong(u"Title"_s, u"Artist"_s, u"Album"_s, 123); + AddSong(u"Title"_s, u"artist"_s, u"Album"_s, 123); ASSERT_EQ(3, collection_filter_->rowCount(QModelIndex())); - EXPECT_EQ(QStringLiteral("A"), collection_filter_->index(0, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("Artist"), collection_filter_->index(1, 0, QModelIndex()).data().toString()); - EXPECT_EQ(QStringLiteral("artist"), collection_filter_->index(2, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"A"_s, collection_filter_->index(0, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"Artist"_s, collection_filter_->index(1, 0, QModelIndex()).data().toString()); + EXPECT_EQ(u"artist"_s, collection_filter_->index(2, 0, QModelIndex()).data().toString()); } TEST_F(CollectionModelTest, UnknownArtists) { - AddSong(QStringLiteral("Title"), ""_L1, QStringLiteral("Album"), 123); + AddSong(u"Title"_s, ""_L1, u"Album"_s, 123); ASSERT_EQ(1, model_->rowCount(QModelIndex())); QModelIndex unknown_index = model_->index(0, 0, QModelIndex()); - EXPECT_EQ(QStringLiteral("Unknown"), unknown_index.data().toString()); + EXPECT_EQ(u"Unknown"_s, unknown_index.data().toString()); ASSERT_EQ(1, model_->rowCount(unknown_index)); - EXPECT_EQ(QStringLiteral("Album"), model_->index(0, 0, unknown_index).data().toString()); + EXPECT_EQ(u"Album"_s, model_->index(0, 0, unknown_index).data().toString()); } TEST_F(CollectionModelTest, UnknownAlbums) { - AddSong(QStringLiteral("Title"), QStringLiteral("Artist"), ""_L1, 123); - AddSong(QStringLiteral("Title"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); + AddSong(u"Title"_s, u"Artist"_s, ""_L1, 123); + AddSong(u"Title"_s, u"Artist"_s, u"Album"_s, 123); QModelIndex artist_index = model_->index(1, 0, QModelIndex()); EXPECT_EQ(artist_index.isValid(), true); @@ -195,8 +195,8 @@ TEST_F(CollectionModelTest, UnknownAlbums) { QModelIndex unknown_album_index = model_->index(0, 0, artist_index); QModelIndex real_album_index = model_->index(1, 0, artist_index); - EXPECT_EQ(QStringLiteral("Unknown"), unknown_album_index.data().toString()); - EXPECT_EQ(QStringLiteral("Album"), real_album_index.data().toString()); + EXPECT_EQ(u"Unknown"_s, unknown_album_index.data().toString()); + EXPECT_EQ(u"Album"_s, real_album_index.data().toString()); } @@ -206,7 +206,7 @@ TEST_F(CollectionModelTest, VariousArtistSongs) { for (int i=0 ; i < 4 ; ++i) { QString n = QString::number(i+1); Song song; - song.Init(QStringLiteral("Title ") + n, QStringLiteral("Artist ") + n, QStringLiteral("Album"), 0); + song.Init(u"Title "_s + n, u"Artist "_s + n, u"Album"_s, 0); song.set_mtime(0); song.set_ctime(0); songs << song; // clazy:exclude=reserve-candidates @@ -216,7 +216,7 @@ TEST_F(CollectionModelTest, VariousArtistSongs) { songs[0].set_compilation_detected(true); songs[1].set_compilation(true); songs[2].set_compilation_on(true); - songs[3].set_compilation_detected(true); songs[3].set_artist(QStringLiteral("Various Artists")); + songs[3].set_compilation_detected(true); songs[3].set_artist(u"Various Artists"_s); for (int i=0 ; i < 4 ; ++i) AddSong(songs[i]); @@ -227,18 +227,18 @@ TEST_F(CollectionModelTest, VariousArtistSongs) { QModelIndex album_index = model_->index(0, 0, artist_index); ASSERT_EQ(4, model_->rowCount(album_index)); - EXPECT_EQ(QStringLiteral("Artist 1 - Title 1"), model_->index(0, 0, album_index).data().toString()); - EXPECT_EQ(QStringLiteral("Artist 2 - Title 2"), model_->index(1, 0, album_index).data().toString()); - EXPECT_EQ(QStringLiteral("Artist 3 - Title 3"), model_->index(2, 0, album_index).data().toString()); - EXPECT_EQ(QStringLiteral("Title 4"), model_->index(3, 0, album_index).data().toString()); + EXPECT_EQ(u"Artist 1 - Title 1"_s, model_->index(0, 0, album_index).data().toString()); + EXPECT_EQ(u"Artist 2 - Title 2"_s, model_->index(1, 0, album_index).data().toString()); + EXPECT_EQ(u"Artist 3 - Title 3"_s, model_->index(2, 0, album_index).data().toString()); + EXPECT_EQ(u"Title 4"_s, model_->index(3, 0, album_index).data().toString()); } TEST_F(CollectionModelTest, RemoveSongs) { - Song one = AddSong(QStringLiteral("Title 1"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); one.set_id(1); - Song two = AddSong(QStringLiteral("Title 2"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); two.set_id(2); - AddSong(QStringLiteral("Title 3"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); + Song one = AddSong(u"Title 1"_s, u"Artist"_s, u"Album"_s, 123); one.set_id(1); + Song two = AddSong(u"Title 2"_s, u"Artist"_s, u"Album"_s, 123); two.set_id(2); + AddSong(u"Title 3"_s, u"Artist"_s, u"Album"_s, 123); QModelIndex artist_index = model_->index(1, 0, QModelIndex()); ASSERT_EQ(1, model_->rowCount(artist_index)); @@ -264,15 +264,15 @@ TEST_F(CollectionModelTest, RemoveSongs) { ASSERT_EQ(1, model_->rowCount(artist_index)); album_index = model_->index(0, 0, artist_index); ASSERT_EQ(1, model_->rowCount(album_index)); - EXPECT_EQ(QStringLiteral("Title 3"), model_->index(0, 0, album_index).data().toString()); + EXPECT_EQ(u"Title 3"_s, model_->index(0, 0, album_index).data().toString()); } TEST_F(CollectionModelTest, RemoveEmptyAlbums) { - Song one = AddSong(QStringLiteral("Title 1"), QStringLiteral("Artist"), QStringLiteral("Album 1"), 123); one.set_id(1); - Song two = AddSong(QStringLiteral("Title 2"), QStringLiteral("Artist"), QStringLiteral("Album 2"), 123); two.set_id(2); - Song three = AddSong(QStringLiteral("Title 3"), QStringLiteral("Artist"), QStringLiteral("Album 2"), 123); three.set_id(3); + Song one = AddSong(u"Title 1"_s, u"Artist"_s, u"Album 1"_s, 123); one.set_id(1); + Song two = AddSong(u"Title 2"_s, u"Artist"_s, u"Album 2"_s, 123); two.set_id(2); + Song three = AddSong(u"Title 3"_s, u"Artist"_s, u"Album 2"_s, 123); three.set_id(3); QModelIndex artist_index = model_->index(1, 0, QModelIndex()); ASSERT_EQ(2, model_->rowCount(artist_index)); @@ -288,16 +288,16 @@ TEST_F(CollectionModelTest, RemoveEmptyAlbums) { ASSERT_EQ(1, model_->rowCount(artist_index)); QModelIndex album_index = model_->index(0, 0, artist_index); - EXPECT_EQ(QStringLiteral("Album 2"), album_index.data().toString()); + EXPECT_EQ(u"Album 2"_s, album_index.data().toString()); ASSERT_EQ(1, model_->rowCount(album_index)); - EXPECT_EQ(QStringLiteral("Title 3"), model_->index(0, 0, album_index).data().toString()); + EXPECT_EQ(u"Title 3"_s, model_->index(0, 0, album_index).data().toString()); } TEST_F(CollectionModelTest, RemoveEmptyArtists) { - Song one = AddSong(QStringLiteral("Title"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); one.set_id(1); + Song one = AddSong(u"Title"_s, u"Artist"_s, u"Album"_s, 123); one.set_id(1); QModelIndex artist_index = model_->index(1, 0, QModelIndex()); ASSERT_EQ(1, model_->rowCount(artist_index)); diff --git a/tests/src/logging_env.h b/tests/src/logging_env.h index 504fd77ca..dd82a476c 100644 --- a/tests/src/logging_env.h +++ b/tests/src/logging_env.h @@ -25,12 +25,14 @@ #include "core/logging.h" +using namespace Qt::Literals::StringLiterals; + class LoggingEnvironment : public ::testing::Environment { public: LoggingEnvironment() = default; void SetUp() override { logging::Init(); - logging::SetLevels(QStringLiteral("*:4")); + logging::SetLevels(u"*:4"_s); } private: Q_DISABLE_COPY(LoggingEnvironment) diff --git a/tests/src/mergedproxymodel_test.cpp b/tests/src/mergedproxymodel_test.cpp index 91d35c194..9258dfcfc 100644 --- a/tests/src/mergedproxymodel_test.cpp +++ b/tests/src/mergedproxymodel_test.cpp @@ -26,6 +26,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + // clazy:excludeall=non-pod-global-static,returning-void-expression,function-args-by-value class MergedProxyModelTest : public ::testing::Test { @@ -41,15 +43,15 @@ class MergedProxyModelTest : public ::testing::Test { TEST_F(MergedProxyModelTest, Flat) { - source_.appendRow(new QStandardItem(QStringLiteral("one"))); - source_.appendRow(new QStandardItem(QStringLiteral("two"))); + source_.appendRow(new QStandardItem(u"one"_s)); + source_.appendRow(new QStandardItem(u"two"_s)); ASSERT_EQ(2, merged_.rowCount(QModelIndex())); QModelIndex one_i = merged_.index(0, 0, QModelIndex()); QModelIndex two_i = merged_.index(1, 0, QModelIndex()); - EXPECT_EQ(QStringLiteral("one"), one_i.data().toString()); - EXPECT_EQ(QStringLiteral("two"), two_i.data().toString()); + EXPECT_EQ(u"one"_s, one_i.data().toString()); + EXPECT_EQ(u"two"_s, two_i.data().toString()); EXPECT_FALSE(merged_.parent(one_i).isValid()); EXPECT_FALSE(merged_.hasChildren(one_i)); @@ -57,8 +59,8 @@ TEST_F(MergedProxyModelTest, Flat) { TEST_F(MergedProxyModelTest, Tree) { - QStandardItem* one = new QStandardItem(QStringLiteral("one")); - QStandardItem* two = new QStandardItem(QStringLiteral("two")); + QStandardItem* one = new QStandardItem(u"one"_s); + QStandardItem* two = new QStandardItem(u"two"_s); source_.appendRow(one); one->appendRow(two); @@ -68,31 +70,31 @@ TEST_F(MergedProxyModelTest, Tree) { ASSERT_EQ(1, merged_.rowCount(one_i)); QModelIndex two_i = merged_.index(0, 0, one_i); - EXPECT_EQ(QStringLiteral("one"), one_i.data().toString()); - EXPECT_EQ(QStringLiteral("two"), two_i.data().toString()); - EXPECT_EQ(QStringLiteral("one"), two_i.parent().data().toString()); + EXPECT_EQ(u"one"_s, one_i.data().toString()); + EXPECT_EQ(u"two"_s, two_i.data().toString()); + EXPECT_EQ(u"one"_s, two_i.parent().data().toString()); } TEST_F(MergedProxyModelTest, Merged) { - source_.appendRow(new QStandardItem(QStringLiteral("one"))); + source_.appendRow(new QStandardItem(u"one"_s)); QStandardItemModel submodel; - submodel.appendRow(new QStandardItem(QStringLiteral("two"))); + submodel.appendRow(new QStandardItem(u"two"_s)); merged_.AddSubModel(source_.index(0, 0, QModelIndex()), &submodel); ASSERT_EQ(1, merged_.rowCount(QModelIndex())); QModelIndex one_i = merged_.index(0, 0, QModelIndex()); - EXPECT_EQ(QStringLiteral("one"), merged_.data(one_i).toString()); + EXPECT_EQ(u"one"_s, merged_.data(one_i).toString()); EXPECT_TRUE(merged_.hasChildren(one_i)); ASSERT_EQ(1, merged_.rowCount(one_i)); QModelIndex two_i = merged_.index(0, 0, one_i); - EXPECT_EQ(QStringLiteral("two"), merged_.data(two_i).toString()); + EXPECT_EQ(u"two"_s, merged_.data(two_i).toString()); EXPECT_EQ(0, merged_.rowCount(two_i)); EXPECT_FALSE(merged_.hasChildren(two_i)); @@ -103,7 +105,7 @@ TEST_F(MergedProxyModelTest, SourceInsert) { QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeInserted); QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsInserted); - source_.appendRow(new QStandardItem(QStringLiteral("one"))); + source_.appendRow(new QStandardItem(u"one"_s)); ASSERT_EQ(1, before_spy.count()); ASSERT_EQ(1, after_spy.count()); @@ -118,7 +120,7 @@ TEST_F(MergedProxyModelTest, SourceInsert) { TEST_F(MergedProxyModelTest, SourceRemove) { - source_.appendRow(new QStandardItem(QStringLiteral("one"))); + source_.appendRow(new QStandardItem(u"one"_s)); QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeRemoved); QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsRemoved); @@ -138,21 +140,21 @@ TEST_F(MergedProxyModelTest, SourceRemove) { TEST_F(MergedProxyModelTest, SubInsert) { - source_.appendRow(new QStandardItem(QStringLiteral("one"))); + source_.appendRow(new QStandardItem(u"one"_s)); QStandardItemModel submodel; merged_.AddSubModel(source_.index(0, 0, QModelIndex()), &submodel); QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeInserted); QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsInserted); - submodel.appendRow(new QStandardItem(QStringLiteral("two"))); + submodel.appendRow(new QStandardItem(u"two"_s)); ASSERT_EQ(1, before_spy.count()); ASSERT_EQ(1, after_spy.count()); - EXPECT_EQ(QStringLiteral("one"), before_spy[0][0].toModelIndex().data()); + EXPECT_EQ(u"one"_s, before_spy[0][0].toModelIndex().data()); EXPECT_EQ(0, before_spy[0][1].toInt()); EXPECT_EQ(0, before_spy[0][2].toInt()); - EXPECT_EQ(QStringLiteral("one"), after_spy[0][0].toModelIndex().data()); + EXPECT_EQ(u"one"_s, after_spy[0][0].toModelIndex().data()); EXPECT_EQ(0, after_spy[0][1].toInt()); EXPECT_EQ(0, after_spy[0][2].toInt()); @@ -160,11 +162,11 @@ TEST_F(MergedProxyModelTest, SubInsert) { TEST_F(MergedProxyModelTest, SubRemove) { - source_.appendRow(new QStandardItem(QStringLiteral("one"))); + source_.appendRow(new QStandardItem(u"one"_s)); QStandardItemModel submodel; merged_.AddSubModel(source_.index(0, 0, QModelIndex()), &submodel); - submodel.appendRow(new QStandardItem(QStringLiteral("two"))); + submodel.appendRow(new QStandardItem(u"two"_s)); QSignalSpy before_spy(&merged_, &MergedProxyModel::rowsAboutToBeRemoved); QSignalSpy after_spy(&merged_, &MergedProxyModel::rowsRemoved); @@ -173,10 +175,10 @@ TEST_F(MergedProxyModelTest, SubRemove) { ASSERT_EQ(1, before_spy.count()); ASSERT_EQ(1, after_spy.count()); - EXPECT_EQ(QStringLiteral("one"), before_spy[0][0].toModelIndex().data()); + EXPECT_EQ(u"one"_s, before_spy[0][0].toModelIndex().data()); EXPECT_EQ(0, before_spy[0][1].toInt()); EXPECT_EQ(0, before_spy[0][2].toInt()); - EXPECT_EQ(QStringLiteral("one"), after_spy[0][0].toModelIndex().data()); + EXPECT_EQ(u"one"_s, after_spy[0][0].toModelIndex().data()); EXPECT_EQ(0, after_spy[0][1].toInt()); EXPECT_EQ(0, after_spy[0][2].toInt()); diff --git a/tests/src/organizeformat_test.cpp b/tests/src/organizeformat_test.cpp index c032547e5..203567564 100644 --- a/tests/src/organizeformat_test.cpp +++ b/tests/src/organizeformat_test.cpp @@ -42,137 +42,137 @@ protected: TEST_F(OrganizeFormatTest, BasicReplace) { - song_.set_title(QStringLiteral("title")); - song_.set_album(QStringLiteral("album")); - song_.set_artist(QStringLiteral("artist")); - song_.set_albumartist(QStringLiteral("albumartist")); + song_.set_title(u"title"_s); + song_.set_album(u"album"_s); + song_.set_artist(u"artist"_s); + song_.set_albumartist(u"albumartist"_s); song_.set_track(321); song_.set_disc(789); song_.set_year(2010); song_.set_originalyear(1995); - song_.set_genre(QStringLiteral("genre")); - song_.set_composer(QStringLiteral("composer")); - song_.set_performer(QStringLiteral("performer")); - song_.set_grouping(QStringLiteral("grouping")); - song_.set_comment(QStringLiteral("comment")); + song_.set_genre(u"genre"_s); + song_.set_composer(u"composer"_s); + song_.set_performer(u"performer"_s); + song_.set_grouping(u"grouping"_s); + song_.set_comment(u"comment"_s); song_.set_length_nanosec(987 * kNsecPerSec); song_.set_samplerate(654); song_.set_bitdepth(32); song_.set_bitrate(123); - format_.set_format(QStringLiteral("%album %albumartist %artist %bitrate %comment %composer %performer %grouping %disc %genre %length %samplerate %bitdepth %title %track %year")); + format_.set_format(u"%album %albumartist %artist %bitrate %comment %composer %performer %grouping %disc %genre %length %samplerate %bitdepth %title %track %year"_s); ASSERT_TRUE(format_.IsValid()); - EXPECT_EQ(QStringLiteral("album_albumartist_artist_123_comment_composer_performer_grouping_789_genre_987_654_32_title_321_2010"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"album_albumartist_artist_123_comment_composer_performer_grouping_789_genre_987_654_32_title_321_2010"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, BasicReplacePaths) { - song_.set_title(QStringLiteral("title")); - song_.set_album(QStringLiteral("album")); - song_.set_artist(QStringLiteral("artist")); - song_.set_albumartist(QStringLiteral("albumartist")); + song_.set_title(u"title"_s); + song_.set_album(u"album"_s); + song_.set_artist(u"artist"_s); + song_.set_albumartist(u"albumartist"_s); song_.set_track(321); - format_.set_format(QStringLiteral("%albumartist/%album/%track %albumartist %artist %album %title")); + format_.set_format(u"%albumartist/%album/%track %albumartist %artist %album %title"_s); ASSERT_TRUE(format_.IsValid()); - EXPECT_EQ(QStringLiteral("albumartist/album/321_albumartist_artist_album_title"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"albumartist/album/321_albumartist_artist_album_title"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, ArtistInitial) { - song_.set_artist(QStringLiteral("bob")); + song_.set_artist(u"bob"_s); - format_.set_format(QStringLiteral("%artistinitial")); + format_.set_format(u"%artistinitial"_s); ASSERT_TRUE(format_.IsValid()); - EXPECT_EQ(QStringLiteral("B"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"B"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, AlbumArtistInitial) { - song_.set_albumartist(QStringLiteral("bob")); + song_.set_albumartist(u"bob"_s); - format_.set_format(QStringLiteral("%artistinitial")); + format_.set_format(u"%artistinitial"_s); ASSERT_TRUE(format_.IsValid()); - EXPECT_EQ(QStringLiteral("B"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"B"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, InvalidTag) { - format_.set_format(QStringLiteral("%invalid")); + format_.set_format(u"%invalid"_s); EXPECT_FALSE(format_.IsValid()); } TEST_F(OrganizeFormatTest, Blocks) { - format_.set_format(QStringLiteral("Before{Inside%year}After")); + format_.set_format(u"Before{Inside%year}After"_s); ASSERT_TRUE(format_.IsValid()); song_.set_year(-1); - EXPECT_EQ(QStringLiteral("BeforeAfter"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"BeforeAfter"_s, format_.GetFilenameForSong(song_).filename); song_.set_year(0); - EXPECT_EQ(QStringLiteral("BeforeAfter"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"BeforeAfter"_s, format_.GetFilenameForSong(song_).filename); song_.set_year(123); - EXPECT_EQ(QStringLiteral("BeforeInside123After"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"BeforeInside123After"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, ReplaceSpaces) { - song_.set_title(QStringLiteral("The Song Title")); - format_.set_format(QStringLiteral("The Format String %title")); + song_.set_title(u"The Song Title"_s); + format_.set_format(u"The Format String %title"_s); format_.set_replace_spaces(false); - EXPECT_EQ(QStringLiteral("The Format String The Song Title"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"The Format String The Song Title"_s, format_.GetFilenameForSong(song_).filename); format_.set_replace_spaces(true); - EXPECT_EQ(QStringLiteral("The_Format_String_The_Song_Title"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"The_Format_String_The_Song_Title"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, ReplaceNonAscii) { - song_.set_artist(QStringLiteral("Röyksopp")); - format_.set_format(QStringLiteral("%artist")); + song_.set_artist(u"Röyksopp"_s); + format_.set_format(u"%artist"_s); format_.set_remove_non_ascii(false); - EXPECT_EQ(QStringLiteral("Röyksopp"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"Röyksopp"_s, format_.GetFilenameForSong(song_).filename); format_.set_remove_non_ascii(true); - EXPECT_EQ(QStringLiteral("Royksopp"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"Royksopp"_s, format_.GetFilenameForSong(song_).filename); song_.set_artist(""_L1); EXPECT_EQ(QLatin1String(""), format_.GetFilenameForSong(song_).filename); - song_.set_artist(QStringLiteral("Владимир Высоцкий")); - EXPECT_EQ(QStringLiteral("Vladimir_Vysockij"), format_.GetFilenameForSong(song_).filename); + song_.set_artist(u"Владимир Высоцкий"_s); + EXPECT_EQ(u"Vladimir_Vysockij"_s, format_.GetFilenameForSong(song_).filename); - song_.set_artist(QStringLiteral("エックス・ジャパン")); - EXPECT_EQ(QStringLiteral("ekkusujapan"), format_.GetFilenameForSong(song_).filename); + song_.set_artist(u"エックス・ジャパン"_s); + EXPECT_EQ(u"ekkusujapan"_s, format_.GetFilenameForSong(song_).filename); } TEST_F(OrganizeFormatTest, TrackNumberPadding) { - format_.set_format(QStringLiteral("%track")); + format_.set_format(u"%track"_s); song_.set_track(9); - EXPECT_EQ(QStringLiteral("09"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"09"_s, format_.GetFilenameForSong(song_).filename); song_.set_track(99); - EXPECT_EQ(QStringLiteral("99"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"99"_s, format_.GetFilenameForSong(song_).filename); song_.set_track(999); - EXPECT_EQ(QStringLiteral("999"), format_.GetFilenameForSong(song_).filename); + EXPECT_EQ(u"999"_s, format_.GetFilenameForSong(song_).filename); song_.set_track(0); EXPECT_EQ(QLatin1String(""), format_.GetFilenameForSong(song_).filename); @@ -181,8 +181,8 @@ TEST_F(OrganizeFormatTest, TrackNumberPadding) { TEST_F(OrganizeFormatTest, ReplaceSlashes) { - format_.set_format(QStringLiteral("%title")); - song_.set_title(QStringLiteral("foo/bar\\baz")); - EXPECT_EQ(QStringLiteral("foobarbaz"), format_.GetFilenameForSong(song_).filename); + format_.set_format(u"%title"_s); + song_.set_title(u"foo/bar\\baz"_s); + EXPECT_EQ(u"foobarbaz"_s, format_.GetFilenameForSong(song_).filename); } diff --git a/tests/src/playlist_test.cpp b/tests/src/playlist_test.cpp index b0e81e9af..3429c766b 100644 --- a/tests/src/playlist_test.cpp +++ b/tests/src/playlist_test.cpp @@ -35,6 +35,8 @@ using ::testing::Return; +using namespace Qt::Literals::StringLiterals; + // clazy:excludeall=non-pod-global-static,returning-void-expression namespace { @@ -76,7 +78,7 @@ TEST_F(PlaylistTest, Basic) { TEST_F(PlaylistTest, InsertItems) { - MockPlaylistItem *item = MakeMockItem(QStringLiteral("Title"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); + MockPlaylistItem *item = MakeMockItem(u"Title"_s, u"Artist"_s, u"Album"_s, 123); PlaylistItemPtr item_ptr(item); // Insert the item @@ -85,22 +87,22 @@ TEST_F(PlaylistTest, InsertItems) { ASSERT_EQ(1, playlist_.rowCount(QModelIndex())); // Get the metadata - EXPECT_EQ(QStringLiteral("Title"), playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); - EXPECT_EQ(QStringLiteral("Artist"), playlist_.data(playlist_.index(0, static_cast(static_cast(Playlist::Column::Artist))))); - EXPECT_EQ(QStringLiteral("Album"), playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Album)))); + EXPECT_EQ(u"Title"_s, playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Artist"_s, playlist_.data(playlist_.index(0, static_cast(static_cast(Playlist::Column::Artist))))); + EXPECT_EQ(u"Album"_s, playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Album)))); EXPECT_EQ(123, playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Length)))); } TEST_F(PlaylistTest, Indexes) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); // Start "playing" track 1 playlist_.set_current_row(0); EXPECT_EQ(0, playlist_.current_row()); - EXPECT_EQ(QStringLiteral("One"), playlist_.current_item()->Metadata().title()); + EXPECT_EQ(u"One"_s, playlist_.current_item()->Metadata().title()); EXPECT_EQ(-1, playlist_.previous_row()); EXPECT_EQ(1, playlist_.next_row()); @@ -113,14 +115,14 @@ TEST_F(PlaylistTest, Indexes) { // Play track 2 playlist_.set_current_row(1); EXPECT_EQ(1, playlist_.current_row()); - EXPECT_EQ(QStringLiteral("Two"), playlist_.current_item()->Metadata().title()); + EXPECT_EQ(u"Two"_s, playlist_.current_item()->Metadata().title()); EXPECT_EQ(0, playlist_.previous_row()); EXPECT_EQ(2, playlist_.next_row()); // Play track 3 playlist_.set_current_row(2); EXPECT_EQ(2, playlist_.current_row()); - EXPECT_EQ(QStringLiteral("Three"), playlist_.current_item()->Metadata().title()); + EXPECT_EQ(u"Three"_s, playlist_.current_item()->Metadata().title()); EXPECT_EQ(1, playlist_.previous_row()); EXPECT_EQ(-1, playlist_.next_row()); @@ -128,7 +130,7 @@ TEST_F(PlaylistTest, Indexes) { TEST_F(PlaylistTest, RepeatPlaylist) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.sequence()->SetRepeatMode(PlaylistSequence::RepeatMode::Playlist); @@ -146,7 +148,7 @@ TEST_F(PlaylistTest, RepeatPlaylist) { TEST_F(PlaylistTest, RepeatTrack) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.sequence()->SetRepeatMode(PlaylistSequence::RepeatMode::Track); @@ -159,9 +161,9 @@ TEST_F(PlaylistTest, RepeatTrack) { TEST_F(PlaylistTest, RepeatAlbum) { playlist_.InsertItems(PlaylistItemPtrList() - << MakeMockItemP(QStringLiteral("One"), QStringLiteral("Album one")) - << MakeMockItemP(QStringLiteral("Two"), QStringLiteral("Album two")) - << MakeMockItemP(QStringLiteral("Three"), QStringLiteral("Album one"))); + << MakeMockItemP(u"One"_s, u"Album one"_s) + << MakeMockItemP(u"Two"_s, u"Album two"_s) + << MakeMockItemP(u"Three"_s, u"Album one"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.sequence()->SetRepeatMode(PlaylistSequence::RepeatMode::Album); @@ -177,7 +179,7 @@ TEST_F(PlaylistTest, RepeatAlbum) { TEST_F(PlaylistTest, RemoveBeforeCurrent) { playlist_.InsertItems(PlaylistItemPtrList() - << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); // Remove a row before the currently playing track @@ -194,7 +196,7 @@ TEST_F(PlaylistTest, RemoveBeforeCurrent) { TEST_F(PlaylistTest, RemoveAfterCurrent) { playlist_.InsertItems(PlaylistItemPtrList() - << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); // Remove a row after the currently playing track @@ -213,7 +215,7 @@ TEST_F(PlaylistTest, RemoveAfterCurrent) { TEST_F(PlaylistTest, RemoveCurrent) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); // Remove the currently playing track's row @@ -229,12 +231,12 @@ TEST_F(PlaylistTest, RemoveCurrent) { TEST_F(PlaylistTest, InsertBeforeCurrent) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.set_current_row(1); EXPECT_EQ(1, playlist_.current_row()); - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Four")), 0); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Four"_s), 0); ASSERT_EQ(4, playlist_.rowCount(QModelIndex())); EXPECT_EQ(2, playlist_.current_row()); @@ -242,19 +244,19 @@ TEST_F(PlaylistTest, InsertBeforeCurrent) { EXPECT_EQ(1, playlist_.previous_row()); EXPECT_EQ(3, playlist_.next_row()); - EXPECT_EQ(QStringLiteral("Four"), playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); - EXPECT_EQ(QStringLiteral("One"), playlist_.data(playlist_.index(1, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Four"_s, playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"One"_s, playlist_.data(playlist_.index(1, static_cast(Playlist::Column::Title)))); } TEST_F(PlaylistTest, InsertAfterCurrent) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.set_current_row(1); EXPECT_EQ(1, playlist_.current_row()); - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Four")), 2); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Four"_s), 2); ASSERT_EQ(4, playlist_.rowCount(QModelIndex())); EXPECT_EQ(1, playlist_.current_row()); @@ -262,15 +264,15 @@ TEST_F(PlaylistTest, InsertAfterCurrent) { EXPECT_EQ(0, playlist_.previous_row()); EXPECT_EQ(2, playlist_.next_row()); - EXPECT_EQ(QStringLiteral("Two"), playlist_.data(playlist_.index(1, static_cast(Playlist::Column::Title)))); - EXPECT_EQ(QStringLiteral("Four"), playlist_.data(playlist_.index(2, static_cast(Playlist::Column::Title)))); - EXPECT_EQ(QStringLiteral("Three"), playlist_.data(playlist_.index(3, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Two"_s, playlist_.data(playlist_.index(1, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Four"_s, playlist_.data(playlist_.index(2, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Three"_s, playlist_.data(playlist_.index(3, static_cast(Playlist::Column::Title)))); } TEST_F(PlaylistTest, Clear) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.set_current_row(1); @@ -290,7 +292,7 @@ TEST_F(PlaylistTest, UndoAdd) { EXPECT_FALSE(playlist_.undo_stack()->canUndo()); EXPECT_FALSE(playlist_.undo_stack()->canRedo()); - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Title"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Title"_s)); EXPECT_EQ(1, playlist_.rowCount(QModelIndex())); EXPECT_FALSE(playlist_.undo_stack()->canRedo()); ASSERT_TRUE(playlist_.undo_stack()->canUndo()); @@ -305,26 +307,26 @@ TEST_F(PlaylistTest, UndoAdd) { EXPECT_FALSE(playlist_.undo_stack()->canRedo()); EXPECT_TRUE(playlist_.undo_stack()->canUndo()); - EXPECT_EQ(QStringLiteral("Title"), playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Title"_s, playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); } TEST_F(PlaylistTest, UndoMultiAdd) { // Add 1 item - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s)); // Add 2 items - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); // Undo adding 2 items ASSERT_TRUE(playlist_.undo_stack()->canUndo()); - EXPECT_EQ(QStringLiteral("add 2 songs"), playlist_.undo_stack()->undoText()); + EXPECT_EQ(u"add 2 songs"_s, playlist_.undo_stack()->undoText()); playlist_.undo_stack()->undo(); // Undo adding 1 item ASSERT_TRUE(playlist_.undo_stack()->canUndo()); - EXPECT_EQ(QStringLiteral("add 1 songs"), playlist_.undo_stack()->undoText()); + EXPECT_EQ(u"add 1 songs"_s, playlist_.undo_stack()->undoText()); playlist_.undo_stack()->undo(); EXPECT_FALSE(playlist_.undo_stack()->canUndo()); @@ -336,7 +338,7 @@ TEST_F(PlaylistTest, UndoRemove) { EXPECT_FALSE(playlist_.undo_stack()->canUndo()); EXPECT_FALSE(playlist_.undo_stack()->canRedo()); - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Title"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Title"_s)); EXPECT_TRUE(playlist_.undo_stack()->canUndo()); EXPECT_FALSE(playlist_.undo_stack()->canRedo()); @@ -351,7 +353,7 @@ TEST_F(PlaylistTest, UndoRemove) { EXPECT_EQ(1, playlist_.rowCount(QModelIndex())); ASSERT_TRUE(playlist_.undo_stack()->canRedo()); - EXPECT_EQ(QStringLiteral("Title"), playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Title"_s, playlist_.data(playlist_.index(0, static_cast(Playlist::Column::Title)))); playlist_.undo_stack()->redo(); EXPECT_EQ(0, playlist_.rowCount(QModelIndex())); @@ -363,7 +365,7 @@ TEST_F(PlaylistTest, UndoRemove) { TEST_F(PlaylistTest, UndoMultiRemove) { // Add 3 items - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); // Remove 1 item @@ -376,7 +378,7 @@ TEST_F(PlaylistTest, UndoMultiRemove) { // Undo removing all 3 items ASSERT_TRUE(playlist_.undo_stack()->canUndo()); - EXPECT_EQ(QStringLiteral("remove 3 songs"), playlist_.undo_stack()->undoText()); + EXPECT_EQ(u"remove 3 songs"_s, playlist_.undo_stack()->undoText()); playlist_.undo_stack()->undo(); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); @@ -385,13 +387,13 @@ TEST_F(PlaylistTest, UndoMultiRemove) { TEST_F(PlaylistTest, UndoClear) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("One")) << MakeMockItemP(QStringLiteral("Two")) << MakeMockItemP(QStringLiteral("Three"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"One"_s) << MakeMockItemP(u"Two"_s) << MakeMockItemP(u"Three"_s)); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); playlist_.Clear(); ASSERT_EQ(0, playlist_.rowCount(QModelIndex())); ASSERT_TRUE(playlist_.undo_stack()->canUndo()); - EXPECT_EQ(QStringLiteral("remove 3 songs"), playlist_.undo_stack()->undoText()); + EXPECT_EQ(u"remove 3 songs"_s, playlist_.undo_stack()->undoText()); playlist_.undo_stack()->undo(); ASSERT_EQ(3, playlist_.rowCount(QModelIndex())); @@ -400,7 +402,7 @@ TEST_F(PlaylistTest, UndoClear) { TEST_F(PlaylistTest, UndoRemoveCurrent) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Title"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Title"_s)); playlist_.set_current_row(0); EXPECT_EQ(0, playlist_.current_row()); EXPECT_EQ(0, playlist_.last_played_row()); @@ -417,7 +419,7 @@ TEST_F(PlaylistTest, UndoRemoveCurrent) { TEST_F(PlaylistTest, UndoRemoveOldCurrent) { - playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(QStringLiteral("Title"))); + playlist_.InsertItems(PlaylistItemPtrList() << MakeMockItemP(u"Title"_s)); playlist_.set_current_row(0); EXPECT_EQ(0, playlist_.current_row()); EXPECT_EQ(0, playlist_.last_played_row()); @@ -440,7 +442,7 @@ TEST_F(PlaylistTest, ShuffleThenNext) { PlaylistItemPtrList items; items.reserve(100); for (int i=0 ; i<100 ; ++i) - items << MakeMockItemP(QStringLiteral("Item ") + QString::number(i)); + items << MakeMockItemP(u"Item "_s + QString::number(i)); playlist_.InsertItems(items); playlist_.set_current_row(0); @@ -453,8 +455,8 @@ TEST_F(PlaylistTest, ShuffleThenNext) { } int index = playlist_.current_row(); - EXPECT_EQ(QStringLiteral("Item 0"), playlist_.current_item()->Metadata().title()); - EXPECT_EQ(QStringLiteral("Item 0"), playlist_.data(playlist_.index(index, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Item 0"_s, playlist_.current_item()->Metadata().title()); + EXPECT_EQ(u"Item 0"_s, playlist_.data(playlist_.index(index, static_cast(Playlist::Column::Title)))); EXPECT_EQ(index, playlist_.last_played_row()); //EXPECT_EQ(index + 1, playlist_.next_row()); @@ -466,8 +468,8 @@ TEST_F(PlaylistTest, ShuffleThenNext) { //} index = playlist_.current_row(); - EXPECT_EQ(QStringLiteral("Item 0"), playlist_.current_item()->Metadata().title()); - EXPECT_EQ(QStringLiteral("Item 0"), playlist_.data(playlist_.index(index, static_cast(Playlist::Column::Title)))); + EXPECT_EQ(u"Item 0"_s, playlist_.current_item()->Metadata().title()); + EXPECT_EQ(u"Item 0"_s, playlist_.data(playlist_.index(index, static_cast(Playlist::Column::Title)))); EXPECT_EQ(index, playlist_.last_played_row()); //EXPECT_EQ(-1, playlist_.next_row()); //EXPECT_EQ(index-1, playlist_.previous_row()); @@ -477,7 +479,7 @@ TEST_F(PlaylistTest, ShuffleThenNext) { TEST_F(PlaylistTest, CollectionIdMapSingle) { Song song; - song.Init(QStringLiteral("title"), QStringLiteral("artist"), QStringLiteral("album"), 123); + song.Init(u"title"_s, u"artist"_s, u"album"_s, 123); song.set_id(1); PlaylistItemPtr item(std::make_shared(song)); @@ -498,7 +500,7 @@ TEST_F(PlaylistTest, CollectionIdMapSingle) { TEST_F(PlaylistTest, CollectionIdMapInvalid) { Song invalid; - invalid.Init(QStringLiteral("title"), QStringLiteral("artist"), QStringLiteral("album"), 123); + invalid.Init(u"title"_s, u"artist"_s, u"album"_s, 123); ASSERT_EQ(-1, invalid.id()); PlaylistItemPtr item(std::make_shared(invalid)); @@ -514,11 +516,11 @@ TEST_F(PlaylistTest, CollectionIdMapInvalid) { TEST_F(PlaylistTest, CollectionIdMapMulti) { Song one; - one.Init(QStringLiteral("title"), QStringLiteral("artist"), QStringLiteral("album"), 123); + one.Init(u"title"_s, u"artist"_s, u"album"_s, 123); one.set_id(1); Song two; - two.Init(QStringLiteral("title 2"), QStringLiteral("artist 2"), QStringLiteral("album 2"), 123); + two.Init(u"title 2"_s, u"artist 2"_s, u"album 2"_s, 123); two.set_id(2); PlaylistItemPtr item_one(std::make_shared(one)); diff --git a/tests/src/songplaylistitem_test.cpp b/tests/src/songplaylistitem_test.cpp index e26a1bc04..7acba672b 100644 --- a/tests/src/songplaylistitem_test.cpp +++ b/tests/src/songplaylistitem_test.cpp @@ -35,6 +35,8 @@ using std::make_unique; +using namespace Qt::Literals::StringLiterals; + // clazy:excludeall=non-pod-global-static namespace { @@ -49,7 +51,7 @@ class SongPlaylistItemTest : public ::testing::TestWithParam { absolute_file_name_ = QFileInfo(temp_file_.fileName()).absoluteFilePath(); - song_.Init(QStringLiteral("Title"), QStringLiteral("Artist"), QStringLiteral("Album"), 123); + song_.Init(u"Title"_s, u"Artist"_s, u"Album"_s, 123); song_.set_url(QUrl::fromLocalFile(absolute_file_name_)); item_ = make_unique(song_); @@ -73,7 +75,7 @@ INSTANTIATE_TEST_SUITE_P(RealFiles, SongPlaylistItemTest, testing::Values( // c TEST_P(SongPlaylistItemTest, Url) { QUrl expected; - expected.setScheme(QStringLiteral("file")); + expected.setScheme(u"file"_s); expected.setPath(absolute_file_name_); EXPECT_EQ(expected, item_->Url()); diff --git a/tests/src/test_utils.cpp b/tests/src/test_utils.cpp index 72f9f2b5b..3e90310f3 100644 --- a/tests/src/test_utils.cpp +++ b/tests/src/test_utils.cpp @@ -28,6 +28,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + std::ostream &operator<<(std::ostream &stream, const QString &str) { stream << str.toStdString(); return stream; @@ -62,7 +64,7 @@ void PrintTo(const ::QUrl &url, std::ostream &os) { TemporaryResource::TemporaryResource(const QString &filename, QObject *parent) : QTemporaryFile(parent) { - setFileTemplate(QDir::tempPath() + QStringLiteral("/strawberry_test-XXXXXX.") + filename.section(u'.', -1, -1)); + setFileTemplate(QDir::tempPath() + u"/strawberry_test-XXXXXX."_s + filename.section(u'.', -1, -1)); open(); QFile resource(filename); diff --git a/tests/src/utilities_test.cpp b/tests/src/utilities_test.cpp index 17803d09b..cfaf7e945 100644 --- a/tests/src/utilities_test.cpp +++ b/tests/src/utilities_test.cpp @@ -42,21 +42,21 @@ using namespace Qt::Literals::StringLiterals; TEST(UtilitiesTest, PrettyTimeDelta) { - ASSERT_EQ(Utilities::PrettyTimeDelta(60), QStringLiteral("+1:00")); + ASSERT_EQ(Utilities::PrettyTimeDelta(60), u"+1:00"_s); - ASSERT_EQ(Utilities::PrettyTimeDelta(3600), QStringLiteral("+1:00:00")); + ASSERT_EQ(Utilities::PrettyTimeDelta(3600), u"+1:00:00"_s); - ASSERT_EQ(Utilities::PrettyTimeDelta(9600), QStringLiteral("+2:40:00")); + ASSERT_EQ(Utilities::PrettyTimeDelta(9600), u"+2:40:00"_s); } TEST(UtilitiesTest, PrettyTime) { - ASSERT_EQ(Utilities::PrettyTime(60), QStringLiteral("1:00")); + ASSERT_EQ(Utilities::PrettyTime(60), u"1:00"_s); - ASSERT_EQ(Utilities::PrettyTime(3600), QStringLiteral("1:00:00")); + ASSERT_EQ(Utilities::PrettyTime(3600), u"1:00:00"_s); - ASSERT_EQ(Utilities::PrettyTime(9600), QStringLiteral("2:40:00")); + ASSERT_EQ(Utilities::PrettyTime(9600), u"2:40:00"_s); } @@ -64,7 +64,7 @@ TEST(UtilitiesTest, PrettyTimeNanosec) {} TEST(UtilitiesTest, WordyTime) { - ASSERT_EQ(Utilities::WordyTime(787200), QStringLiteral("9 days 2:40:00")); + ASSERT_EQ(Utilities::WordyTime(787200), u"9 days 2:40:00"_s); } @@ -72,7 +72,7 @@ TEST(UtilitiesTest, WordyTimeNanosec) {} TEST(UtilitiesTest, Ago) { - ASSERT_EQ(Utilities::Ago(QDateTime::currentSecsSinceEpoch() - 604800, QLocale()), QStringLiteral("7 days ago")); + ASSERT_EQ(Utilities::Ago(QDateTime::currentSecsSinceEpoch() - 604800, QLocale()), u"7 days ago"_s); } @@ -80,83 +80,83 @@ TEST(UtilitiesTest, PrettyFutureDate) {} TEST(UtilitiesTest, PrettySize) { - ASSERT_EQ(Utilities::PrettySize(787200), QStringLiteral("787.2 KB")); + ASSERT_EQ(Utilities::PrettySize(787200), u"787.2 KB"_s); } TEST(UtilitiesTest, ColorToRgba) { - ASSERT_EQ(Utilities::ColorToRgba(QColor(33, 22, 128)), QStringLiteral("rgba(33, 22, 128, 255)")); + ASSERT_EQ(Utilities::ColorToRgba(QColor(33, 22, 128)), u"rgba(33, 22, 128, 255)"_s); } TEST(UtilitiesTest, HmacFunctions) { - QString key(QStringLiteral("key")); - QString data(QStringLiteral("The quick brown fox jumps over the lazy dog")); + QString key(u"key"_s); + QString data(u"The quick brown fox jumps over the lazy dog"_s); // Test Hmac MD5 QString result_hash_md5 = QString::fromLatin1(Utilities::HmacMd5(key.toLocal8Bit(), data.toLocal8Bit()).toHex()); - bool result_md5 = result_hash_md5 == QStringLiteral("80070713463e7749b90c2dc24911e275"); + bool result_md5 = result_hash_md5 == u"80070713463e7749b90c2dc24911e275"_s; EXPECT_TRUE(result_md5); // Test Hmac SHA256 QString result_hash_sha256 = QString::fromLatin1(Utilities::HmacSha256(key.toLocal8Bit(), data.toLocal8Bit()).toHex()); - bool result_sha256 = result_hash_sha256 == QStringLiteral("f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8"); + bool result_sha256 = result_hash_sha256 == u"f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8"_s; EXPECT_TRUE(result_sha256); } TEST(UtilitiesTest, PrettySize2) { - ASSERT_EQ(Utilities::PrettySize(QSize(22, 32)), QStringLiteral("22x32")); + ASSERT_EQ(Utilities::PrettySize(QSize(22, 32)), u"22x32"_s); } TEST(UtilitiesTest, ParseRFC822DateTime) { - QDateTime result_DateTime = Utilities::ParseRFC822DateTime(QStringLiteral("22 Feb 2008 00:16:17 GMT")); + QDateTime result_DateTime = Utilities::ParseRFC822DateTime(u"22 Feb 2008 00:16:17 GMT"_s); EXPECT_TRUE(result_DateTime.isValid()); - result_DateTime = Utilities::ParseRFC822DateTime(QStringLiteral("Thu, 13 Dec 2012 13:27:52 +0000")); + result_DateTime = Utilities::ParseRFC822DateTime(u"Thu, 13 Dec 2012 13:27:52 +0000"_s); EXPECT_TRUE(result_DateTime.isValid()); - result_DateTime = Utilities::ParseRFC822DateTime(QStringLiteral("Mon, 12 March 2012 20:00:00 +0100")); + result_DateTime = Utilities::ParseRFC822DateTime(u"Mon, 12 March 2012 20:00:00 +0100"_s); EXPECT_TRUE(result_DateTime.isValid()); } TEST(UtilitiesTest, DecodeHtmlEntities) { - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral("&")), QStringLiteral("&")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral("&")), QStringLiteral("&")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral(""")), QStringLiteral("\"")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral(""")), QStringLiteral("\"")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral("'")), QStringLiteral("'")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral("'")), QStringLiteral("'")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral("<")), QStringLiteral("<")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral("<")), QStringLiteral("<")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral(">")), QStringLiteral(">")); - ASSERT_EQ(Utilities::DecodeHtmlEntities(QStringLiteral(">")), QStringLiteral(">")); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"&"_s), u"&"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"&"_s), u"&"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"""_s), u"\""_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"""_s), u"\""_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"'"_s), u"'"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"'"_s), u"'"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"<"_s), u"<"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u"<"_s), u"<"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u">"_s), u">"_s); + ASSERT_EQ(Utilities::DecodeHtmlEntities(u">"_s), u">"_s); } TEST(UtilitiesTest, PathWithoutFilenameExtension) { - ASSERT_EQ(Utilities::PathWithoutFilenameExtension(QStringLiteral("/home/jonas/test/filename.txt")), QStringLiteral("/home/jonas/test/filename")); + ASSERT_EQ(Utilities::PathWithoutFilenameExtension(u"/home/jonas/test/filename.txt"_s), u"/home/jonas/test/filename"_s); } TEST(UtilitiesTest, FiddleFileExtension) { - ASSERT_EQ(Utilities::FiddleFileExtension(QStringLiteral("/home/jonas/test/filename.txt"), QStringLiteral("db")), QStringLiteral("/home/jonas/test/filename.db")); + ASSERT_EQ(Utilities::FiddleFileExtension(u"/home/jonas/test/filename.txt"_s, u"db"_s), u"/home/jonas/test/filename.db"_s); } TEST(UtilitiesTest, SetEnvGetEnv) { - QString var = QStringLiteral("STRAWBERRY_UNIT_TEST_") + Utilities::GetRandomStringWithCharsAndNumbers(20); - QString value = QStringLiteral("STRAWBERRY_UNIT_TEST_") + Utilities::GetRandomStringWithCharsAndNumbers(20); + QString var = u"STRAWBERRY_UNIT_TEST_"_s + Utilities::GetRandomStringWithCharsAndNumbers(20); + QString value = u"STRAWBERRY_UNIT_TEST_"_s + Utilities::GetRandomStringWithCharsAndNumbers(20); Utilities::SetEnv(var.toUtf8().constData(), value); ASSERT_EQ(Utilities::GetEnv(var), value); @@ -172,13 +172,13 @@ TEST(UtilitiesTest, Random) { EXPECT_FALSE(Utilities::CryptographicRandomString(20) == Utilities::CryptographicRandomString(20)); - EXPECT_FALSE(Utilities::GetRandomString(20, QStringLiteral("&%XVBGQ")) == Utilities::GetRandomString(20, QStringLiteral("&%XVBGQ"))); + EXPECT_FALSE(Utilities::GetRandomString(20, u"&%XVBGQ"_s) == Utilities::GetRandomString(20, u"&%XVBGQ"_s)); } TEST(UtilitiesTest, Transliterate) { - ASSERT_EQ(Utilities::Transliterate(QStringLiteral("ÆØÅ")), QStringLiteral("AEOA")); + ASSERT_EQ(Utilities::Transliterate(u"ÆØÅ"_s), u"AEOA"_s); } @@ -198,29 +198,29 @@ TEST(UtilitiesTest, ReplaceVariable) { song.set_performer(Utilities::GetRandomStringWithChars(8)); song.set_grouping(Utilities::GetRandomStringWithChars(8)); song.set_length_nanosec(900000000000); - song.set_url(QUrl(QStringLiteral("file:///home/jonas/Music/test_song.flac"))); + song.set_url(QUrl(u"file:///home/jonas/Music/test_song.flac"_s)); song.set_skipcount(20); song.set_playcount(90); song.set_rating(1.0); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%title%"), song, ""_L1), song.title()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%album%"), song, ""_L1), song.album()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%artist%"), song, ""_L1), song.artist()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%albumartist%"), song, ""_L1), song.effective_albumartist()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%track%"), song, ""_L1), QString::number(song.track())); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%disc%"), song, ""_L1), QString::number(song.disc())); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%year%"), song, ""_L1), QString::number(song.year())); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%originalyear%"), song, ""_L1), QString::number(song.originalyear())); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%genre%"), song, ""_L1), song.genre()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%composer%"), song, ""_L1), song.composer()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%performer%"), song, ""_L1), song.performer()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%grouping%"), song, ""_L1), song.grouping()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%length%"), song, ""_L1), song.PrettyLength()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%filename%"), song, ""_L1), song.basefilename()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%url%"), song, ""_L1), song.url().toString()); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%playcount%"), song, ""_L1), QString::number(song.playcount())); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%skipcount%"), song, ""_L1), QString::number(song.skipcount())); - ASSERT_EQ(Utilities::ReplaceVariable(QStringLiteral("%rating%"), song, ""_L1), song.PrettyRating()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%title%"_s, song, ""_L1), song.title()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%album%"_s, song, ""_L1), song.album()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%artist%"_s, song, ""_L1), song.artist()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%albumartist%"_s, song, ""_L1), song.effective_albumartist()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%track%"_s, song, ""_L1), QString::number(song.track())); + ASSERT_EQ(Utilities::ReplaceVariable(u"%disc%"_s, song, ""_L1), QString::number(song.disc())); + ASSERT_EQ(Utilities::ReplaceVariable(u"%year%"_s, song, ""_L1), QString::number(song.year())); + ASSERT_EQ(Utilities::ReplaceVariable(u"%originalyear%"_s, song, ""_L1), QString::number(song.originalyear())); + ASSERT_EQ(Utilities::ReplaceVariable(u"%genre%"_s, song, ""_L1), song.genre()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%composer%"_s, song, ""_L1), song.composer()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%performer%"_s, song, ""_L1), song.performer()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%grouping%"_s, song, ""_L1), song.grouping()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%length%"_s, song, ""_L1), song.PrettyLength()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%filename%"_s, song, ""_L1), song.basefilename()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%url%"_s, song, ""_L1), song.url().toString()); + ASSERT_EQ(Utilities::ReplaceVariable(u"%playcount%"_s, song, ""_L1), QString::number(song.playcount())); + ASSERT_EQ(Utilities::ReplaceVariable(u"%skipcount%"_s, song, ""_L1), QString::number(song.skipcount())); + ASSERT_EQ(Utilities::ReplaceVariable(u"%rating%"_s, song, ""_L1), song.PrettyRating()); } @@ -240,18 +240,18 @@ TEST(UtilitiesTest, ReplaceMessage) { song.set_performer(Utilities::GetRandomStringWithChars(8)); song.set_grouping(Utilities::GetRandomStringWithChars(8)); song.set_length_nanosec(900000000000); - song.set_url(QUrl(QStringLiteral("file:///home/jonas/Music/test_song.flac"))); + song.set_url(QUrl(u"file:///home/jonas/Music/test_song.flac"_s)); song.set_skipcount(20); song.set_playcount(90); song.set_rating(1.0); - ASSERT_EQ(Utilities::ReplaceMessage(QStringLiteral("%title% - %artist%"), song, ""_L1), song.title() + QStringLiteral(" - ") + song.artist()); + ASSERT_EQ(Utilities::ReplaceMessage(u"%title% - %artist%"_s, song, ""_L1), song.title() + u" - "_s + song.artist()); } TEST(UtilitiesTest, TemporaryFile) { - QString filename_pattern = QStringLiteral("/tmp/test-XXXX.jpg"); + QString filename_pattern = u"/tmp/test-XXXX.jpg"_s; TemporaryFile temp_file(filename_pattern); @@ -259,7 +259,7 @@ TEST(UtilitiesTest, TemporaryFile) { EXPECT_FALSE(temp_file.filename() == filename_pattern); - static const QRegularExpression regex_temp_filename(QStringLiteral("^\\/tmp\\/test-....\\.jpg$")); + static const QRegularExpression regex_temp_filename(u"^\\/tmp\\/test-....\\.jpg$"_s); EXPECT_TRUE(regex_temp_filename.match(temp_file.filename()).hasMatch());