Skip to content

Commit

Permalink
ID3v2: Ensure ordered comparison in retention test
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed May 1, 2024
1 parent dc018f3 commit 15ce1e1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lofty/src/id3/v2/tag/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ fn special_items_roundtrip() {
assert_eq!(tag.len(), 1);
assert_eq!(tag.artist().as_deref(), Some("Foo Artist"));

let tag: Id3v2Tag = tag.into();
let mut tag: Id3v2Tag = tag.into();

assert_eq!(tag.frames.len(), 2);
assert_eq!(tag.artist().as_deref(), Some("Foo Artist"));
Expand All @@ -1286,7 +1286,13 @@ fn special_items_roundtrip() {
tag.dump_to(&mut tag_bytes, WriteOptions::default())
.unwrap();

let tag_re_read = read_tag_raw(&tag_bytes[..]);
let mut tag_re_read = read_tag_raw(&tag_bytes[..]);

// Ensure ordered comparison
tag.frames.sort_by_key(|frame| frame.id().to_string());
tag_re_read
.frames
.sort_by_key(|frame| frame.id().to_string());
assert_eq!(tag, tag_re_read);

// Now write from `Tag`
Expand All @@ -1296,6 +1302,10 @@ fn special_items_roundtrip() {
tag.dump_to(&mut tag_bytes, WriteOptions::default())
.unwrap();

let generic_tag_re_read = read_tag_raw(&tag_bytes[..]);
let mut generic_tag_re_read = read_tag_raw(&tag_bytes[..]);

generic_tag_re_read
.frames
.sort_by_key(|frame| frame.id().to_string());
assert_eq!(tag_re_read, generic_tag_re_read);
}

0 comments on commit 15ce1e1

Please sign in to comment.