mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-12 13:42:34 +00:00
Tests: Fix old Id3v2Tag tests
This commit is contained in:
parent
9554295e51
commit
aa50837ecc
3 changed files with 12 additions and 8 deletions
|
@ -159,8 +159,6 @@ impl Id3v2Tag {
|
|||
|
||||
impl Id3v2Tag {
|
||||
/// Gets a [`Frame`] from an id
|
||||
///
|
||||
/// NOTE: This is *not* case-sensitive
|
||||
pub fn get(&self, id: &FrameId<'_>) -> Option<&Frame<'static>> {
|
||||
self.frames.iter().find(|f| &f.id == id)
|
||||
}
|
||||
|
@ -208,7 +206,7 @@ impl Id3v2Tag {
|
|||
///
|
||||
/// tag.set_title(String::from("Foo\0Bar"));
|
||||
///
|
||||
/// let mut titles = tag.get_texts(&TITLE_ID);
|
||||
/// let mut titles = tag.get_texts(&TITLE_ID).expect("Should exist");
|
||||
///
|
||||
/// assert_eq!(titles.next(), Some("Foo"));
|
||||
/// assert_eq!(titles.next(), Some("Bar"));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::{set_artist, temp_file, verify_artist};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use lofty::id3::v2::{Frame, FrameFlags, FrameValue, Id3v2Tag, KeyValueFrame};
|
||||
use lofty::id3::v2::{Frame, FrameFlags, FrameId, FrameValue, Id3v2Tag, KeyValueFrame};
|
||||
use lofty::mpeg::MpegFile;
|
||||
use lofty::{
|
||||
Accessor, AudioFile, FileType, ItemKey, ItemValue, ParseOptions, Probe, Tag, TagExt, TagItem,
|
||||
|
@ -344,7 +345,11 @@ fn read_and_write_tpil_frame() {
|
|||
|
||||
let tag: &Id3v2Tag = mpeg_file.id3v2().unwrap();
|
||||
|
||||
let content = match tag.get("TIPL").unwrap().content() {
|
||||
let content = match tag
|
||||
.get(&FrameId::Valid(Cow::Borrowed("TIPL")))
|
||||
.unwrap()
|
||||
.content()
|
||||
{
|
||||
FrameValue::KeyValue(content) => content,
|
||||
_ => panic!("Wrong Frame Value Type for TIPL"),
|
||||
};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// Tests for special case conversions
|
||||
|
||||
use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, Id3v2Tag, UnsynchronizedTextFrame};
|
||||
use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, FrameId, Id3v2Tag, UnsynchronizedTextFrame};
|
||||
use lofty::{ItemKey, Tag, TagType, TextEncoding};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[test]
|
||||
fn tag_to_id3v2_lang_frame() {
|
||||
|
@ -12,7 +13,7 @@ fn tag_to_id3v2_lang_frame() {
|
|||
let id3: Id3v2Tag = tag.into();
|
||||
|
||||
assert_eq!(
|
||||
id3.get("USLT"),
|
||||
id3.get(&FrameId::Valid(Cow::Borrowed("USLT"))),
|
||||
Frame::new(
|
||||
"USLT",
|
||||
UnsynchronizedTextFrame {
|
||||
|
@ -28,7 +29,7 @@ fn tag_to_id3v2_lang_frame() {
|
|||
);
|
||||
|
||||
assert_eq!(
|
||||
id3.get("COMM"),
|
||||
id3.get(&FrameId::Valid(Cow::Borrowed("COMM"))),
|
||||
Frame::new(
|
||||
"COMM",
|
||||
CommentFrame {
|
||||
|
|
Loading…
Reference in a new issue