Skip to content

Commit fc23525

Browse files
committed
EBML: Add basic matroska integration tests (not yet working)
1 parent 2ba5e20 commit fc23525

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

lofty/tests/files/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod aac;
22
mod aiff;
33
mod ape;
44
mod flac;
5+
mod matroska;
56
mod mp4;
67
mod mpc;
78
mod mpeg;

lofty/tests/files/matroska.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
use crate::{set_artist, temp_file, verify_artist};
2+
use lofty::config::ParseOptions;
3+
use lofty::file::FileType;
4+
use lofty::prelude::*;
5+
use lofty::probe::Probe;
6+
use lofty::tag::TagType;
7+
8+
use std::io::Seek;
9+
10+
#[test]
11+
fn read() {
12+
// This file contains a tags element
13+
let file = Probe::open("tests/files/assets/minimal/full_test.mka")
14+
.unwrap()
15+
.options(ParseOptions::new().read_properties(false))
16+
.read()
17+
.unwrap();
18+
19+
assert_eq!(file.file_type(), FileType::Ebml);
20+
21+
// Verify the tag
22+
crate::verify_artist!(file, primary_tag, "Foo artist", 1);
23+
}
24+
25+
#[test]
26+
fn write() {
27+
let mut file = temp_file!("tests/files/assets/minimal/full_test.mka");
28+
29+
let mut tagged_file = Probe::new(&mut file)
30+
.options(ParseOptions::new().read_properties(false))
31+
.guess_file_type()
32+
.unwrap()
33+
.read()
34+
.unwrap();
35+
36+
assert_eq!(tagged_file.file_type(), FileType::Ebml);
37+
38+
// Tags
39+
crate::set_artist!(tagged_file, tag_mut, TagType::Ebml, "Foo artist", 1 => file, "Bar artist");
40+
41+
// Now reread the file
42+
file.rewind().unwrap();
43+
44+
let mut tagged_file = Probe::new(&mut file)
45+
.options(ParseOptions::new().read_properties(false))
46+
.guess_file_type()
47+
.unwrap()
48+
.read()
49+
.unwrap();
50+
51+
crate::set_artist!(tagged_file, tag_mut, TagType::Ebml, "Bar artist", 1 => file, "Foo artist");
52+
}
53+
54+
#[test]
55+
fn remove() {
56+
crate::remove_tag!("tests/files/assets/minimal/full_test.mka", TagType::Ebml);
57+
}
58+
59+
#[test]
60+
fn read_no_properties() {
61+
crate::no_properties_test!("tests/files/assets/minimal/full_test.mka");
62+
}
63+
64+
#[test]
65+
fn read_no_tags() {
66+
crate::no_tag_test!("tests/files/assets/minimal/full_test.mka");
67+
}

0 commit comments

Comments
 (0)