mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-03 13:30:26 +01:00
Add some tests for MergeUserSetData
This commit is contained in:
parent
c0e08d42ed
commit
f2228de5c9
@ -394,4 +394,33 @@ TEST_F(SongTest, StatisticsMP4) {
|
|||||||
EXPECT_EQ(87, new_song.score());
|
EXPECT_EQ(87, new_song.score());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SongTest, MergeUserSetDataTest) {
|
||||||
|
// Suppose we have songs from files and from the DB
|
||||||
|
// Songs from files are the ones that will be imported in the DB after being merged with the
|
||||||
|
// former DB song values
|
||||||
|
Song song_db_with_rating;
|
||||||
|
Song song_db_with_no_rating;
|
||||||
|
Song song_file_with_rating;
|
||||||
|
Song song_file_with_no_rating;
|
||||||
|
|
||||||
|
song_db_with_rating.set_rating(0.42);
|
||||||
|
song_file_with_rating.set_rating(0.43);
|
||||||
|
|
||||||
|
// Merging a DB song with no rating should not update the rating that is in the file song
|
||||||
|
float old_rating_value = song_file_with_rating.rating();
|
||||||
|
song_file_with_rating.MergeUserSetData(song_db_with_no_rating);
|
||||||
|
EXPECT_NE(song_db_with_no_rating.rating(), song_file_with_rating.rating());
|
||||||
|
EXPECT_EQ(song_file_with_rating.rating(), old_rating_value);
|
||||||
|
|
||||||
|
// Merging a DB song with rating should not update the rating that is in the file song...
|
||||||
|
old_rating_value = song_file_with_rating.rating();
|
||||||
|
song_file_with_rating.MergeUserSetData(song_db_with_rating);
|
||||||
|
EXPECT_NE(song_db_with_rating.rating(), song_file_with_rating.rating());
|
||||||
|
EXPECT_EQ(song_file_with_rating.rating(), old_rating_value);
|
||||||
|
|
||||||
|
// ...but DB song's rating shouldn't be erased if the file song has no rating
|
||||||
|
song_file_with_no_rating.MergeUserSetData(song_db_with_rating);
|
||||||
|
EXPECT_EQ(song_file_with_no_rating.rating(), song_db_with_rating.rating());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user