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 70 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
fe34f88
Tests: Add AIFF tests from TagLib
sagudev May 15, 2022
8578611
Tests: Add TagLib APE tests
Serial-ATA Jan 7, 2023
94287c3
Tests: Add TagLib APETag tests
Serial-ATA Jan 7, 2023
1fb328d
Tests: Add TagLib FileRef tests
Serial-ATA Jan 8, 2023
13cfc42
Tests: Add TagLib FLAC tests
Serial-ATA Jan 8, 2023
f6e4b51
Tests: Add TagLib FLAC Picture tests
Serial-ATA Jan 13, 2023
c3f05b3
Tests: Add TagLib ID3v1 tests
Serial-ATA Jan 13, 2023
f8be964
Tests: Add TagLib RIFF INFO tests
Serial-ATA Jan 15, 2023
f8a7e70
Tests: Add TagLib Speex tests
Serial-ATA Jan 15, 2023
7cd40c3
Tests: Add TagLib MPEG tests
Serial-ATA Jan 21, 2023
e5c9bb8
Tests: Update TagLib MPEG tests for new behavior
Serial-ATA Mar 1, 2023
05ff118
Tests: Add TagLib MP4 tests
Serial-ATA Mar 10, 2023
24225ae
Tests: Add TagLib WavPack tests
Serial-ATA Mar 15, 2023
2114bcd
Tests: Add TagLib Vorbis Comments tests
Serial-ATA Mar 17, 2023
ee779b9
Tests: Update VorbisComments usages to use `push`
Serial-ATA Mar 18, 2023
e37298c
Tests: Add TagLib WAV tests
Serial-ATA Mar 18, 2023
688fa0f
Tests: Update TagLib MP4 tests for recent changes
Serial-ATA Mar 20, 2023
964df34
Tests: Add ignored TagLib OGA FLAC tests
Serial-ATA Mar 20, 2023
f50ddcd
Tests: Fix track number check in TagLib XiphComment test
Serial-ATA Mar 20, 2023
56734d8
Tests: Add TagLib Opus tests
Serial-ATA Mar 24, 2023
a4c046d
Tests: Add TagLib OGG tests
Serial-ATA Apr 10, 2023
76b913f
Tests: Fix TagLib TestFLAC::testSaveMultipleValues
Serial-ATA Apr 10, 2023
2f732f3
Tests: Add TagLib ID3v2 tests
Serial-ATA Apr 10, 2023
d60c02e
Tests: Update Taglib tests for new type names
Serial-ATA Apr 22, 2023
98655a0
Tests: Update TagLib FLAC tests for recent VorbisComments changes
Serial-ATA Apr 23, 2023
bbdf8a2
Tests: Finish TagLib AIFF tests
Serial-ATA Apr 23, 2023
d552574
Tests: Update TagLib tests for recent ID3v2 changes
Serial-ATA Jul 5, 2023
7c850bc
Tests: Add TagLib Musepack fileref test
Serial-ATA Jul 5, 2023
a12db2b
Tests: Add TagLib Musepack tests
Serial-ATA Jul 6, 2023
43d0599
Tests: Add TagLib SynchData tests
Serial-ATA Jul 9, 2023
facfe37
Tests: Fix paths in TagLib tests
Serial-ATA Jul 9, 2023
a7d8b4d
Tests: Cleanup Taglib APE and AIFF tests
Serial-ATA Jul 9, 2023
cc02aa2
Tests: Stop creating temp files for immutable tests
Serial-ATA Jul 9, 2023
9c1b91a
Tests: Switch ID3v1 collision test asset to MusePack
Serial-ATA Jul 10, 2023
8d01415
Tests: Remove stray `todo!()`s in resolver test
Serial-ATA Jul 10, 2023
fda3a9f
Tests: Remove TagLib ID3v1 `test_strip_whitespace` test
Serial-ATA Jul 10, 2023
76c4759
Tests: Update TagLib AIFF tests
Serial-ATA Jul 10, 2023
c343f7c
Tests: Update TagLib ID3v2 tests for new frames
Serial-ATA Jul 24, 2023
b9c7eec
Tests: Fix TagLib W000 ID3v2 test
Serial-ATA Jul 24, 2023
5166296
Tests: Fix TagLib TestMPEG::testFuzzedFile
Serial-ATA Jul 24, 2023
6facaab
Tests: Ignore TagLib TestOGG::testPageChecksum for now
Serial-ATA Jul 24, 2023
6867b72
Tests: Ignore testFLAC::testMultipleCommentBlocks
Serial-ATA Jul 27, 2023
4c1d3b4
Tests: Unignore TagLib tests, replacing with todo!() panics
Serial-ATA Jul 27, 2023
e9f0d65
Tests: Ignore testWavPack::testMultiChannelProperties
Serial-ATA Jul 27, 2023
eacd7a6
Tests: Update TagLib tests for latest changes
Serial-ATA Oct 17, 2023
a1d31bd
Tests: Ignore TagLib ID3v2.3 conversion tests for now
Serial-ATA Oct 26, 2023
52a7ef5
Tests: Simply ignore tests with unimplemented/uncertain behavior
Serial-ATA Dec 3, 2023
7c6ddd3
Tests: Implement TagLib ID3v2 UTF16 delimiter tests
Serial-ATA Dec 3, 2023
a0e8dc5
Tests: Implement TagLib TestID3v2::testUpdateGenre24
Serial-ATA Dec 3, 2023
c83d5ee
Tests: Ignore more TagLib tests with unimplemented features
Serial-ATA Dec 3, 2023
22d022c
Tests: Use `Mp4Properties::is_drm_properties()` in TagLib tests
Serial-ATA Dec 3, 2023
c5d30bf
Tests: Comment out TagLib TestID3v2::testBrokenFrame1
Serial-ATA Dec 14, 2023
48414b9
Tests: Update for `MimeType` changes
Serial-ATA Dec 31, 2023
d66b8ad
Tests: Fixup some TagLib tests where TagLib is incorrect
Serial-ATA Dec 31, 2023
f523865
Tests: Fix bitrate in `TestOGG::testAudioProperties()`
Serial-ATA Dec 31, 2023
eb2168e
Tests: Ignore TagLib `TestMP4::testUpdateStco()` for now
Serial-ATA Jan 3, 2024
945d28b
Tests: Update TagLib tests for latest changes
Serial-ATA Apr 5, 2024
7a857d6
Tests: Update TagLib tests for new module structure
Serial-ATA Apr 14, 2024
8d22d7a
Tests: Update TagLib tests for recent changes
Serial-ATA Apr 24, 2024
5f9da13
Tests: Update TagLib tests for recent ID3v2 changes
Serial-ATA May 4, 2024
dce0f0a
Tests: Run Clippy on TagLib tests
Serial-ATA May 4, 2024
8a625eb
Tests/TagLib: Do not check bit depth for lossy formats
Serial-ATA May 6, 2024
d1be0cd
Tests: Update TagLib Musepack tests
Serial-ATA May 9, 2024
6666058
Tests: Uncomment TagLib WAV test
Serial-ATA Jun 6, 2024
38470ea
Tests: Update TagLib ID3v2 tests for recent changes
Serial-ATA Jul 4, 2024
47fdc79
Tests: Impl TagLib `TestWAV::testSaveID3v23`
Serial-ATA Jul 15, 2024
103239a
Tests: Add ID3v2.3 tests from TagLib
Serial-ATA Jul 16, 2024
90ba51b
Tests: Update TagLib MP4 test
Serial-ATA Jul 22, 2024
1f2a46f
Tests: Update TagLib tests for latest changes
Serial-ATA Sep 14, 2024
a6b99a9
Tests: Allow missing docs
Serial-ATA Nov 20, 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.
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]
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