Skip to content

Tests: Add tests from TagLib #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
aa7aa22
Tests: Add AIFF tests from TagLib
sagudev May 15, 2022
8b9a237
Tests: Add TagLib APE tests
Serial-ATA Jan 7, 2023
44373e1
Tests: Add TagLib APETag tests
Serial-ATA Jan 7, 2023
7363590
Tests: Add TagLib FileRef tests
Serial-ATA Jan 8, 2023
61f4ab4
Tests: Add TagLib FLAC tests
Serial-ATA Jan 8, 2023
9c5f1b2
Tests: Add TagLib FLAC Picture tests
Serial-ATA Jan 13, 2023
0daf315
Tests: Add TagLib ID3v1 tests
Serial-ATA Jan 13, 2023
f0f5a04
Tests: Add TagLib RIFF INFO tests
Serial-ATA Jan 15, 2023
5299ac8
Tests: Add TagLib Speex tests
Serial-ATA Jan 15, 2023
20df290
Tests: Add TagLib MPEG tests
Serial-ATA Jan 21, 2023
5822a3d
Tests: Update TagLib MPEG tests for new behavior
Serial-ATA Mar 1, 2023
1e44f90
Tests: Add TagLib MP4 tests
Serial-ATA Mar 10, 2023
5b66f8c
Tests: Add TagLib WavPack tests
Serial-ATA Mar 15, 2023
9e263f9
Tests: Add TagLib Vorbis Comments tests
Serial-ATA Mar 17, 2023
c8cf494
Tests: Update VorbisComments usages to use `push`
Serial-ATA Mar 18, 2023
052731d
Tests: Add TagLib WAV tests
Serial-ATA Mar 18, 2023
66bba14
Tests: Update TagLib MP4 tests for recent changes
Serial-ATA Mar 20, 2023
61f3622
Tests: Add ignored TagLib OGA FLAC tests
Serial-ATA Mar 20, 2023
4fcecd0
Tests: Fix track number check in TagLib XiphComment test
Serial-ATA Mar 20, 2023
f9ff268
Tests: Add TagLib Opus tests
Serial-ATA Mar 24, 2023
735a8d1
Tests: Add TagLib OGG tests
Serial-ATA Apr 10, 2023
21d88d1
Tests: Fix TagLib TestFLAC::testSaveMultipleValues
Serial-ATA Apr 10, 2023
15ad04c
Tests: Add TagLib ID3v2 tests
Serial-ATA Apr 10, 2023
226592e
Tests: Update Taglib tests for new type names
Serial-ATA Apr 22, 2023
e9f1fdd
Tests: Update TagLib FLAC tests for recent VorbisComments changes
Serial-ATA Apr 23, 2023
6137bad
Tests: Finish TagLib AIFF tests
Serial-ATA Apr 23, 2023
b7a49b4
Tests: Update TagLib tests for recent ID3v2 changes
Serial-ATA Jul 5, 2023
6f751fb
Tests: Add TagLib Musepack fileref test
Serial-ATA Jul 5, 2023
648efe3
Tests: Add TagLib Musepack tests
Serial-ATA Jul 6, 2023
f3f3941
Tests: Add TagLib SynchData tests
Serial-ATA Jul 9, 2023
14dfefb
Tests: Fix paths in TagLib tests
Serial-ATA Jul 9, 2023
16fc95c
Tests: Cleanup Taglib APE and AIFF tests
Serial-ATA Jul 9, 2023
295d493
Tests: Stop creating temp files for immutable tests
Serial-ATA Jul 9, 2023
1f7fa08
Tests: Switch ID3v1 collision test asset to MusePack
Serial-ATA Jul 10, 2023
7eb968c
Tests: Remove stray `todo!()`s in resolver test
Serial-ATA Jul 10, 2023
c266b60
Tests: Remove TagLib ID3v1 `test_strip_whitespace` test
Serial-ATA Jul 10, 2023
e9d8130
Tests: Update TagLib AIFF tests
Serial-ATA Jul 10, 2023
884a72e
Tests: Update TagLib ID3v2 tests for new frames
Serial-ATA Jul 24, 2023
60f6c28
Tests: Fix TagLib W000 ID3v2 test
Serial-ATA Jul 24, 2023
ebd6200
Tests: Fix TagLib TestMPEG::testFuzzedFile
Serial-ATA Jul 24, 2023
0eddd88
Tests: Ignore TagLib TestOGG::testPageChecksum for now
Serial-ATA Jul 24, 2023
2a5ee43
Tests: Ignore testFLAC::testMultipleCommentBlocks
Serial-ATA Jul 27, 2023
75f3108
Tests: Unignore TagLib tests, replacing with todo!() panics
Serial-ATA Jul 27, 2023
9ed604f
Tests: Ignore testWavPack::testMultiChannelProperties
Serial-ATA Jul 27, 2023
9b0fcf0
Tests: Update TagLib tests for latest changes
Serial-ATA Oct 17, 2023
ac92656
Tests: Ignore TagLib ID3v2.3 conversion tests for now
Serial-ATA Oct 26, 2023
b680531
Tests: Simply ignore tests with unimplemented/uncertain behavior
Serial-ATA Dec 3, 2023
6a5e54a
Tests: Implement TagLib ID3v2 UTF16 delimiter tests
Serial-ATA Dec 3, 2023
d213550
Tests: Implement TagLib TestID3v2::testUpdateGenre24
Serial-ATA Dec 3, 2023
35f02ab
Tests: Ignore more TagLib tests with unimplemented features
Serial-ATA Dec 3, 2023
896d9e8
Tests: Use `Mp4Properties::is_drm_properties()` in TagLib tests
Serial-ATA Dec 3, 2023
c0e0cf0
Tests: Comment out TagLib TestID3v2::testBrokenFrame1
Serial-ATA Dec 14, 2023
64fefd2
Tests: Update for `MimeType` changes
Serial-ATA Dec 31, 2023
255916a
Tests: Fixup some TagLib tests where TagLib is incorrect
Serial-ATA Dec 31, 2023
b23bc2a
Tests: Fix bitrate in `TestOGG::testAudioProperties()`
Serial-ATA Dec 31, 2023
770f6d2
Tests: Ignore TagLib `TestMP4::testUpdateStco()` for now
Serial-ATA Jan 3, 2024
455ee07
Tests: Update TagLib tests for latest changes
Serial-ATA Apr 5, 2024
9051604
Tests: Update TagLib tests for new module structure
Serial-ATA Apr 14, 2024
b054fb8
Tests: Update TagLib tests for recent changes
Serial-ATA Apr 24, 2024
fbdff5a
Tests: Update TagLib tests for recent ID3v2 changes
Serial-ATA May 4, 2024
018db06
Tests: Run Clippy on TagLib tests
Serial-ATA May 4, 2024
4e328b4
Tests/TagLib: Do not check bit depth for lossy formats
Serial-ATA May 6, 2024
84e3fec
Tests: Update TagLib Musepack tests
Serial-ATA May 9, 2024
c61869e
Tests: Uncomment TagLib WAV test
Serial-ATA Jun 6, 2024
7391088
Tests: Update TagLib ID3v2 tests for recent changes
Serial-ATA Jul 4, 2024
40ff8f4
Tests: Impl TagLib `TestWAV::testSaveID3v23`
Serial-ATA Jul 15, 2024
5cb6098
Tests: Add ID3v2.3 tests from TagLib
Serial-ATA Jul 16, 2024
b074dfc
Tests: Update TagLib MP4 test
Serial-ATA Jul 22, 2024
7f63640
Tests: Update TagLib tests for latest changes
Serial-ATA Sep 14, 2024
29d310f
Tests: Allow missing docs
Serial-ATA Nov 20, 2024
18c4d2e
Tests: Ignore TagLib `TestWAV::test_duplicate_tags`
Serial-ATA Apr 24, 2025
27934d1
Tests: Fix TagLib `TestMPEG::test_ignore_garbage`
Serial-ATA Apr 24, 2025
ddaa5a4
Tests: Use `test-log` in TagLib tests
Serial-ATA Apr 24, 2025
5ef97b9
Tests: Ignore a few TagLib tests for now
Serial-ATA Apr 25, 2025
e1acb9e
Tests: Fix TagLib TestMP4::testRemoveMetadata
Serial-ATA Apr 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lofty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ id3v2_compression_support = ["dep:flate2"]
[dev-dependencies]
# WAV properties validity tests
hound = { git = "https://github.com/ruuda/hound.git", rev = "02e66effb33683dd6acb92df792683ee46ad6a59" }
rusty-fork = "0.3.0"
# tag_writer example
structopt = { version = "0.3.26", default-features = false }
tempfile = "3.15.0"
Expand Down
Binary file added lofty/tests/taglib/data/005411.id3
Binary file not shown.
Binary file added lofty/tests/taglib/data/alaw.aifc
Binary file not shown.
Binary file added lofty/tests/taglib/data/alaw.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/bladeenc.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/blank_video.m4v
Binary file not shown.
Binary file added lofty/tests/taglib/data/broken-tenc.id3
Binary file not shown.
Binary file added lofty/tests/taglib/data/click.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/click.wv
Binary file not shown.
Binary file added lofty/tests/taglib/data/compressed_id3_frame.mp3
Binary file not shown.
Binary file not shown.
Binary file added lofty/tests/taglib/data/covr-junk.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/dsd_stereo.wv
Binary file not shown.
Binary file added lofty/tests/taglib/data/duplicate_id3v2.aiff
Binary file not shown.
Binary file added lofty/tests/taglib/data/duplicate_id3v2.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/duplicate_tags.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty-seektable.flac
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty.aiff
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty.ogg
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty.spx
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty_alac.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty_flac.oga
Binary file not shown.
Binary file added lofty/tests/taglib/data/empty_vorbis.oga
Binary file not shown.
Binary file added lofty/tests/taglib/data/excessive_alloc.aif
Binary file not shown.
Binary file added lofty/tests/taglib/data/excessive_alloc.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/float64.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/garbage.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/gnre.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/has-tags.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/id3v22-tda.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/ilst-is-last.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/infloop.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/infloop.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/infloop.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/infloop.wv
Binary file not shown.
Binary file added lofty/tests/taglib/data/invalid-frames1.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/invalid-frames2.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/invalid-frames3.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/lame_cbr.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/lame_vbr.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/longloop.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/lowercase-fields.ogg
Binary file not shown.
Binary file added lofty/tests/taglib/data/mac-390-hdr.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/mac-396.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/mac-399-id3v2.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/mac-399-tagged.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/mac-399.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/mpeg2.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/multiple-vc.flac
Binary file not shown.
Binary file added lofty/tests/taglib/data/no-extension
Binary file not shown.
Binary file added lofty/tests/taglib/data/no-tags.3g2
Binary file not shown.
Binary file added lofty/tests/taglib/data/no-tags.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/no-tags.flac
Binary file not shown.
Binary file added lofty/tests/taglib/data/no-tags.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/no-tags.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/no_length.wv
Binary file not shown.
Binary file added lofty/tests/taglib/data/non-full-meta.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/non_standard_rate.wv
Binary file not shown.
Binary file added lofty/tests/taglib/data/pcm_with_fact_chunk.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/rare_frames.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/segfault.aif
Binary file not shown.
Binary file added lofty/tests/taglib/data/segfault.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/segfault.oga
Binary file not shown.
Binary file added lofty/tests/taglib/data/segfault.wav
Binary file not shown.
1 change: 1 addition & 0 deletions lofty/tests/taglib/data/segfault2.mpc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MPCKSH
Binary file added lofty/tests/taglib/data/silence-1.wma
Binary file not shown.
Binary file added lofty/tests/taglib/data/silence-44-s.flac
Binary file not shown.
Binary file added lofty/tests/taglib/data/sinewave.flac
Binary file not shown.
Binary file added lofty/tests/taglib/data/sv4_header.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/sv5_header.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/sv8_header.mpc
Binary file not shown.
Binary file added lofty/tests/taglib/data/tagged.wv
Binary file not shown.
Binary file added lofty/tests/taglib/data/uint8we.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/unsupported-extension.xx
Binary file not shown.
Binary file added lofty/tests/taglib/data/unsynch.id3
Binary file not shown.
Binary file added lofty/tests/taglib/data/w000.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/xing.mp3
Binary file not shown.
Binary file added lofty/tests/taglib/data/zero-length-mdat.m4a
Binary file not shown.
Binary file added lofty/tests/taglib/data/zero-size-chunk.wav
Binary file not shown.
Binary file added lofty/tests/taglib/data/zero-sized-padding.flac
Binary file not shown.
Binary file added lofty/tests/taglib/data/zerodiv.ape
Binary file not shown.
Binary file added lofty/tests/taglib/data/zerodiv.mpc
Binary file not shown.
24 changes: 24 additions & 0 deletions lofty/tests/taglib/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![allow(missing_docs)]

pub(crate) mod util;

mod test_aiff;
mod test_ape;
mod test_apetag;
mod test_fileref;
mod test_flac;
mod test_flacpicture;
mod test_id3v1;
mod test_id3v2;
mod test_info;
mod test_mp4;
mod test_mpc;
mod test_mpeg;
mod test_ogaflac;
mod test_ogg;
mod test_opus;
mod test_speex;
mod test_synchdata;
mod test_wav;
mod test_wavpack;
mod test_xiphcomment;
126 changes: 126 additions & 0 deletions lofty/tests/taglib/test_aiff.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
use crate::util::get_file;
use crate::{assert_delta, temp_file};

use std::io::Seek;

use lofty::config::{ParseOptions, WriteOptions};
use lofty::file::{AudioFile, FileType};
use lofty::id3::v2::Id3v2Tag;
use lofty::iff::aiff::{AiffCompressionType, AiffFile};
use lofty::probe::Probe;
use lofty::tag::{Accessor, TagType};

#[test_log::test]
fn test_aiff_properties() {
let file = get_file::<AiffFile>("tests/taglib/data/empty.aiff");

let properties = file.properties();
assert_eq!(properties.duration().as_secs(), 0);
assert_delta!(properties.duration().as_millis(), 67, 1);
assert_delta!(properties.audio_bitrate(), 706, 1);
assert_eq!(properties.sample_rate(), 44100);
assert_eq!(properties.channels(), 1);
assert_eq!(properties.sample_size(), 16);
// TODO: get those options in lofty
// CPPUNIT_ASSERT_EQUAL(2941U, f.audioProperties()->sampleFrames());
assert!(properties.compression_type().is_none());
}

#[test_log::test]
fn test_aifc_properties() {
let file = get_file::<AiffFile>("tests/taglib/data/alaw.aifc");

let properties = file.properties();
assert_eq!(properties.duration().as_secs(), 0);
assert_delta!(properties.duration().as_millis(), 37, 1);
assert_eq!(properties.audio_bitrate(), 355);
assert_eq!(properties.sample_rate(), 44100);
assert_eq!(properties.channels(), 1);
assert_eq!(properties.sample_size(), 16);
// TODO: get those options in lofty
// CPPUNIT_ASSERT_EQUAL(1622U, f.audioProperties()->sampleFrames());
assert!(properties.compression_type().is_some());
assert_eq!(
properties.compression_type().unwrap().clone(),
AiffCompressionType::ALAW
);
// NOTE: The file's compression name is actually "SGI CCITT G.711 A-law"
//
// We have a hardcoded value for any of the concrete AiffCompressionType variants, as the messages
// are more or less standardized. This is not that big of a deal, especially as many encoders choose
// not to even write a compression name in the first place.
assert_eq!(
properties.compression_type().unwrap().compression_name(),
"CCITT G.711 A-law"
);
}

#[test_log::test]
fn test_save_id3v2() {
let mut file = temp_file!("tests/taglib/data/empty.aiff");

{
let mut tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();

assert!(tfile.id3v2().is_none());

let mut id3v2 = Id3v2Tag::new();
id3v2.set_title("TitleXXX".to_string());
tfile.set_id3v2(id3v2);
file.rewind().unwrap();
tfile.save_to(&mut file, WriteOptions::default()).unwrap();
assert!(tfile.contains_tag_type(TagType::Id3v2));
}

file.rewind().unwrap();

{
let mut tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();

let mut id3v2 = tfile.id3v2().unwrap().to_owned();
assert_eq!(id3v2.title().as_deref(), Some("TitleXXX"));
// NOTE: TagLib sets an empty title, which will implicitly remove it from the tag. Lofty will allow empty tag items to exist.
// What's important is that these are equivalent in behavior.
id3v2.remove_title();
tfile.set_id3v2(id3v2);
file.rewind().unwrap();
tfile.save_to(&mut file, WriteOptions::default()).unwrap();
}

file.rewind().unwrap();

{
let tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();
assert!(!tfile.contains_tag_type(TagType::Id3v2));
}
}

#[test_log::test]
#[ignore]
fn test_save_id3v23() {
todo!("Support writing ID3v2.3 tags")
}

#[test_log::test]
#[ignore]
fn test_duplicate_id3v2() {
// Marker test, Lofty will overwrite values in the original tag with any new values it finds in the next tag.
}

#[test_log::test]
fn test_fuzzed_file1() {
assert_eq!(
Probe::open("tests/taglib/data/segfault.aif")
.unwrap()
.guess_file_type()
.unwrap()
.file_type(),
Some(FileType::Aiff)
);
}

#[test_log::test]
#[ignore]
fn test_fuzzed_file2() {
// Marker test, this file doesn't even have a valid signature. No idea how TagLib manages to read it.
}
Loading