mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-12 13:42:34 +00:00
Tests: Fix tests for new APIs
This commit is contained in:
parent
91470739da
commit
e441a36c4f
2 changed files with 20 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
use lofty::id3::v2::ID3v2Version;
|
||||
use lofty::id3::v2::{AttachedPictureFrame, ID3v2Version};
|
||||
use lofty::{Picture, PictureInformation, PictureType, TextEncoding};
|
||||
|
||||
use std::fs::File;
|
||||
|
@ -28,9 +28,9 @@ fn create_original_picture() -> Picture {
|
|||
fn id3v24_apic() {
|
||||
let buf = get_buf("tests/picture/assets/png_640x628.apic");
|
||||
|
||||
let (pic, _) = Picture::from_apic_bytes(&buf, ID3v2Version::V4).unwrap();
|
||||
let apic = AttachedPictureFrame::parse(&buf, ID3v2Version::V4).unwrap();
|
||||
|
||||
assert_eq!(create_original_picture(), pic);
|
||||
assert_eq!(create_original_picture(), apic.picture);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -38,10 +38,12 @@ fn as_apic_bytes() {
|
|||
let buf = get_buf("tests/picture/assets/png_640x628.apic");
|
||||
|
||||
let original_picture = create_original_picture();
|
||||
let apic = AttachedPictureFrame {
|
||||
encoding: TextEncoding::Latin1,
|
||||
picture: original_picture,
|
||||
};
|
||||
|
||||
let original_as_apic = original_picture
|
||||
.as_apic_bytes(ID3v2Version::V4, TextEncoding::Latin1)
|
||||
.unwrap();
|
||||
let original_as_apic = apic.as_bytes(ID3v2Version::V4).unwrap();
|
||||
|
||||
assert_eq!(buf, original_as_apic);
|
||||
}
|
||||
|
@ -50,9 +52,9 @@ fn as_apic_bytes() {
|
|||
fn id3v22_pic() {
|
||||
let buf = get_buf("tests/picture/assets/png_640x628.pic");
|
||||
|
||||
let (pic, _) = Picture::from_apic_bytes(&buf, ID3v2Version::V2).unwrap();
|
||||
let pic = AttachedPictureFrame::parse(&buf, ID3v2Version::V2).unwrap();
|
||||
|
||||
assert_eq!(create_original_picture(), pic);
|
||||
assert_eq!(create_original_picture(), pic.picture);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -60,10 +62,12 @@ fn as_apic_bytes_v2() {
|
|||
let buf = get_buf("tests/picture/assets/png_640x628.pic");
|
||||
|
||||
let original_picture = create_original_picture();
|
||||
let pic = AttachedPictureFrame {
|
||||
encoding: TextEncoding::Latin1,
|
||||
picture: original_picture,
|
||||
};
|
||||
|
||||
let original_as_pic = original_picture
|
||||
.as_apic_bytes(ID3v2Version::V2, TextEncoding::Latin1)
|
||||
.unwrap();
|
||||
let original_as_pic = pic.as_bytes(ID3v2Version::V2).unwrap();
|
||||
|
||||
assert_eq!(buf, original_as_pic);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Tests for special case conversions
|
||||
|
||||
use lofty::id3::v2::{Frame, FrameFlags, FrameValue, ID3v2Tag, LanguageFrame};
|
||||
use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, ID3v2Tag, UnsynchronizedTextFrame};
|
||||
use lofty::{ItemKey, Tag, TagType, TextEncoding};
|
||||
|
||||
#[test]
|
||||
|
@ -15,12 +15,12 @@ fn tag_to_id3v2_lang_frame() {
|
|||
id3.get("USLT"),
|
||||
Frame::new(
|
||||
"USLT",
|
||||
FrameValue::UnSyncText(LanguageFrame {
|
||||
UnsynchronizedTextFrame {
|
||||
encoding: TextEncoding::UTF8,
|
||||
language: *b"eng",
|
||||
description: String::new(),
|
||||
content: String::from("Test lyrics")
|
||||
}),
|
||||
},
|
||||
FrameFlags::default()
|
||||
)
|
||||
.ok()
|
||||
|
@ -31,12 +31,12 @@ fn tag_to_id3v2_lang_frame() {
|
|||
id3.get("COMM"),
|
||||
Frame::new(
|
||||
"COMM",
|
||||
FrameValue::Comment(LanguageFrame {
|
||||
CommentFrame {
|
||||
encoding: TextEncoding::UTF8,
|
||||
language: *b"eng",
|
||||
description: String::new(),
|
||||
content: String::from("Test comment")
|
||||
}),
|
||||
},
|
||||
FrameFlags::default()
|
||||
)
|
||||
.ok()
|
||||
|
|
Loading…
Reference in a new issue