mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-01-06 01:08:46 +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 lofty::{Picture, PictureInformation, PictureType, TextEncoding};
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -28,9 +28,9 @@ fn create_original_picture() -> Picture {
|
||||||
fn id3v24_apic() {
|
fn id3v24_apic() {
|
||||||
let buf = get_buf("tests/picture/assets/png_640x628.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]
|
#[test]
|
||||||
|
@ -38,10 +38,12 @@ fn as_apic_bytes() {
|
||||||
let buf = get_buf("tests/picture/assets/png_640x628.apic");
|
let buf = get_buf("tests/picture/assets/png_640x628.apic");
|
||||||
|
|
||||||
let original_picture = create_original_picture();
|
let original_picture = create_original_picture();
|
||||||
|
let apic = AttachedPictureFrame {
|
||||||
|
encoding: TextEncoding::Latin1,
|
||||||
|
picture: original_picture,
|
||||||
|
};
|
||||||
|
|
||||||
let original_as_apic = original_picture
|
let original_as_apic = apic.as_bytes(ID3v2Version::V4).unwrap();
|
||||||
.as_apic_bytes(ID3v2Version::V4, TextEncoding::Latin1)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(buf, original_as_apic);
|
assert_eq!(buf, original_as_apic);
|
||||||
}
|
}
|
||||||
|
@ -50,9 +52,9 @@ fn as_apic_bytes() {
|
||||||
fn id3v22_pic() {
|
fn id3v22_pic() {
|
||||||
let buf = get_buf("tests/picture/assets/png_640x628.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]
|
#[test]
|
||||||
|
@ -60,10 +62,12 @@ fn as_apic_bytes_v2() {
|
||||||
let buf = get_buf("tests/picture/assets/png_640x628.pic");
|
let buf = get_buf("tests/picture/assets/png_640x628.pic");
|
||||||
|
|
||||||
let original_picture = create_original_picture();
|
let original_picture = create_original_picture();
|
||||||
|
let pic = AttachedPictureFrame {
|
||||||
|
encoding: TextEncoding::Latin1,
|
||||||
|
picture: original_picture,
|
||||||
|
};
|
||||||
|
|
||||||
let original_as_pic = original_picture
|
let original_as_pic = pic.as_bytes(ID3v2Version::V2).unwrap();
|
||||||
.as_apic_bytes(ID3v2Version::V2, TextEncoding::Latin1)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(buf, original_as_pic);
|
assert_eq!(buf, original_as_pic);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Tests for special case conversions
|
// 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};
|
use lofty::{ItemKey, Tag, TagType, TextEncoding};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -15,12 +15,12 @@ fn tag_to_id3v2_lang_frame() {
|
||||||
id3.get("USLT"),
|
id3.get("USLT"),
|
||||||
Frame::new(
|
Frame::new(
|
||||||
"USLT",
|
"USLT",
|
||||||
FrameValue::UnSyncText(LanguageFrame {
|
UnsynchronizedTextFrame {
|
||||||
encoding: TextEncoding::UTF8,
|
encoding: TextEncoding::UTF8,
|
||||||
language: *b"eng",
|
language: *b"eng",
|
||||||
description: String::new(),
|
description: String::new(),
|
||||||
content: String::from("Test lyrics")
|
content: String::from("Test lyrics")
|
||||||
}),
|
},
|
||||||
FrameFlags::default()
|
FrameFlags::default()
|
||||||
)
|
)
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -31,12 +31,12 @@ fn tag_to_id3v2_lang_frame() {
|
||||||
id3.get("COMM"),
|
id3.get("COMM"),
|
||||||
Frame::new(
|
Frame::new(
|
||||||
"COMM",
|
"COMM",
|
||||||
FrameValue::Comment(LanguageFrame {
|
CommentFrame {
|
||||||
encoding: TextEncoding::UTF8,
|
encoding: TextEncoding::UTF8,
|
||||||
language: *b"eng",
|
language: *b"eng",
|
||||||
description: String::new(),
|
description: String::new(),
|
||||||
content: String::from("Test comment")
|
content: String::from("Test comment")
|
||||||
}),
|
},
|
||||||
FrameFlags::default()
|
FrameFlags::default()
|
||||||
)
|
)
|
||||||
.ok()
|
.ok()
|
||||||
|
|
Loading…
Reference in a new issue