|
| 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