Skip to content
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

Tests: Add tests from TagLib #106

Draft
wants to merge 69 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a2973a8
Tests: Add AIFF tests from TagLib
sagudev May 15, 2022
fdc86a0
Tests: Add TagLib APE tests
Serial-ATA Jan 7, 2023
22fc001
Tests: Add TagLib APETag tests
Serial-ATA Jan 7, 2023
f523e86
Tests: Add TagLib FileRef tests
Serial-ATA Jan 8, 2023
84ddeb6
Tests: Add TagLib FLAC tests
Serial-ATA Jan 8, 2023
b8e61b7
Tests: Add TagLib FLAC Picture tests
Serial-ATA Jan 13, 2023
396e957
Tests: Add TagLib ID3v1 tests
Serial-ATA Jan 13, 2023
5e2a9ac
Tests: Add TagLib RIFF INFO tests
Serial-ATA Jan 15, 2023
3673ef7
Tests: Add TagLib Speex tests
Serial-ATA Jan 15, 2023
c950c68
Tests: Add TagLib MPEG tests
Serial-ATA Jan 21, 2023
6ea024c
Tests: Update TagLib MPEG tests for new behavior
Serial-ATA Mar 1, 2023
e160815
Tests: Add TagLib MP4 tests
Serial-ATA Mar 10, 2023
462204c
Tests: Add TagLib WavPack tests
Serial-ATA Mar 15, 2023
a3d095e
Tests: Add TagLib Vorbis Comments tests
Serial-ATA Mar 17, 2023
d77e481
Tests: Update VorbisComments usages to use `push`
Serial-ATA Mar 18, 2023
1b55a8b
Tests: Add TagLib WAV tests
Serial-ATA Mar 18, 2023
1f4188d
Tests: Update TagLib MP4 tests for recent changes
Serial-ATA Mar 20, 2023
22f49b9
Tests: Add ignored TagLib OGA FLAC tests
Serial-ATA Mar 20, 2023
9c830c4
Tests: Fix track number check in TagLib XiphComment test
Serial-ATA Mar 20, 2023
9ca5eb3
Tests: Add TagLib Opus tests
Serial-ATA Mar 24, 2023
1d8726d
Tests: Add TagLib OGG tests
Serial-ATA Apr 10, 2023
be58822
Tests: Fix TagLib TestFLAC::testSaveMultipleValues
Serial-ATA Apr 10, 2023
a1d0ecb
Tests: Add TagLib ID3v2 tests
Serial-ATA Apr 10, 2023
6bf1a22
Tests: Update Taglib tests for new type names
Serial-ATA Apr 22, 2023
9a8adf1
Tests: Update TagLib FLAC tests for recent VorbisComments changes
Serial-ATA Apr 23, 2023
14cc4b7
Tests: Finish TagLib AIFF tests
Serial-ATA Apr 23, 2023
e5035be
Tests: Update TagLib tests for recent ID3v2 changes
Serial-ATA Jul 5, 2023
d58c97c
Tests: Add TagLib Musepack fileref test
Serial-ATA Jul 5, 2023
97aec83
Tests: Add TagLib Musepack tests
Serial-ATA Jul 6, 2023
bc25e73
Tests: Add TagLib SynchData tests
Serial-ATA Jul 9, 2023
3d1a5ad
Tests: Fix paths in TagLib tests
Serial-ATA Jul 9, 2023
da6b417
Tests: Cleanup Taglib APE and AIFF tests
Serial-ATA Jul 9, 2023
1546e7a
Tests: Stop creating temp files for immutable tests
Serial-ATA Jul 9, 2023
7f8faab
Tests: Switch ID3v1 collision test asset to MusePack
Serial-ATA Jul 10, 2023
5c5f35f
Tests: Remove stray `todo!()`s in resolver test
Serial-ATA Jul 10, 2023
b5551d4
Tests: Remove TagLib ID3v1 `test_strip_whitespace` test
Serial-ATA Jul 10, 2023
b502a15
Tests: Update TagLib AIFF tests
Serial-ATA Jul 10, 2023
a115cac
Tests: Update TagLib ID3v2 tests for new frames
Serial-ATA Jul 24, 2023
f8cd018
Tests: Fix TagLib W000 ID3v2 test
Serial-ATA Jul 24, 2023
534c9f1
Tests: Fix TagLib TestMPEG::testFuzzedFile
Serial-ATA Jul 24, 2023
044eb60
Tests: Ignore TagLib TestOGG::testPageChecksum for now
Serial-ATA Jul 24, 2023
a6891bf
Tests: Ignore testFLAC::testMultipleCommentBlocks
Serial-ATA Jul 27, 2023
aa887a2
Tests: Unignore TagLib tests, replacing with todo!() panics
Serial-ATA Jul 27, 2023
63d9fe3
Tests: Ignore testWavPack::testMultiChannelProperties
Serial-ATA Jul 27, 2023
0ef9797
Tests: Update TagLib tests for latest changes
Serial-ATA Oct 17, 2023
4301417
Tests: Ignore TagLib ID3v2.3 conversion tests for now
Serial-ATA Oct 26, 2023
1ed8132
Tests: Simply ignore tests with unimplemented/uncertain behavior
Serial-ATA Dec 3, 2023
a614157
Tests: Implement TagLib ID3v2 UTF16 delimiter tests
Serial-ATA Dec 3, 2023
2068217
Tests: Implement TagLib TestID3v2::testUpdateGenre24
Serial-ATA Dec 3, 2023
991f364
Tests: Ignore more TagLib tests with unimplemented features
Serial-ATA Dec 3, 2023
55ab57b
Tests: Use `Mp4Properties::is_drm_properties()` in TagLib tests
Serial-ATA Dec 3, 2023
093bb57
Tests: Comment out TagLib TestID3v2::testBrokenFrame1
Serial-ATA Dec 14, 2023
77878f6
Tests: Update for `MimeType` changes
Serial-ATA Dec 31, 2023
1230020
Tests: Fixup some TagLib tests where TagLib is incorrect
Serial-ATA Dec 31, 2023
66ebf9f
Tests: Fix bitrate in `TestOGG::testAudioProperties()`
Serial-ATA Dec 31, 2023
c1b49ac
Tests: Ignore TagLib `TestMP4::testUpdateStco()` for now
Serial-ATA Jan 3, 2024
a9b1c5c
Tests: Update TagLib tests for latest changes
Serial-ATA Apr 5, 2024
5843800
Tests: Update TagLib tests for new module structure
Serial-ATA Apr 14, 2024
0a5b9c3
Tests: Update TagLib tests for recent changes
Serial-ATA Apr 24, 2024
5d59215
Tests: Update TagLib tests for recent ID3v2 changes
Serial-ATA May 4, 2024
351abf6
Tests: Run Clippy on TagLib tests
Serial-ATA May 4, 2024
7d20a37
Tests/TagLib: Do not check bit depth for lossy formats
Serial-ATA May 6, 2024
38a5e0b
Tests: Update TagLib Musepack tests
Serial-ATA May 9, 2024
33a2888
Tests: Uncomment TagLib WAV test
Serial-ATA Jun 6, 2024
50741f5
Tests: Update TagLib ID3v2 tests for recent changes
Serial-ATA Jul 4, 2024
8bdbdd7
Tests: Impl TagLib `TestWAV::testSaveID3v23`
Serial-ATA Jul 15, 2024
57eac7f
Tests: Add ID3v2.3 tests from TagLib
Serial-ATA Jul 16, 2024
e8b89db
Tests: Update TagLib MP4 test
Serial-ATA Jul 22, 2024
930a774
Tests: Update TagLib tests for latest changes
Serial-ATA Sep 14, 2024
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 @@ -33,6 +33,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.10.1"
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.
22 changes: 22 additions & 0 deletions lofty/tests/taglib/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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]
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]
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]
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]
#[ignore]
fn test_save_id3v23() {
todo!("Support writing ID3v2.3 tags")
}

#[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]
fn test_fuzzed_file1() {
assert_eq!(
Probe::open("tests/taglib/data/segfault.aif")
.unwrap()
.guess_file_type()
.unwrap()
.file_type(),
Some(FileType::Aiff)
);
}

#[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
Loading