Skip to content

Commit 944bb87

Browse files
committed
Tests: Update TagLib AIFF tests
1 parent 8d95f77 commit 944bb87

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

tests/taglib/test_aiff.rs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,55 @@ use crate::{assert_delta, temp_file};
44
use std::io::Seek;
55

66
use lofty::id3::v2::Id3v2Tag;
7-
use lofty::iff::aiff::AiffFile;
7+
use lofty::iff::aiff::{AiffCompressionType, AiffFile};
88
use lofty::{Accessor, AudioFile, FileType, ParseOptions, Probe};
99

1010
#[test]
11-
#[ignore]
1211
fn test_aiff_properties() {
1312
let file = get_file::<AiffFile>("tests/taglib/data/empty.aiff");
1413

1514
let properties = file.properties();
1615
assert_eq!(properties.duration().as_secs(), 0);
1716
assert_delta!(properties.duration().as_millis(), 67, 1);
18-
assert_delta!(properties.audio_bitrate().unwrap(), 706, 1);
19-
assert_eq!(properties.sample_rate(), Some(44100));
20-
assert_eq!(properties.channels(), Some(1));
21-
assert_eq!(properties.bit_depth(), Some(16));
17+
assert_delta!(properties.audio_bitrate(), 706, 1);
18+
assert_eq!(properties.sample_rate(), 44100);
19+
assert_eq!(properties.channels(), 1);
20+
assert_eq!(properties.sample_size(), 16);
2221
// TODO: get those options in lofty
2322
// CPPUNIT_ASSERT_EQUAL(2941U, f.audioProperties()->sampleFrames());
24-
// CPPUNIT_ASSERT_EQUAL(false, f.audioProperties()->isAiffC());
23+
assert!(properties.compression_type().is_none());
2524
}
2625

2726
#[test]
28-
#[ignore]
2927
fn test_aifc_properties() {
3028
let file = get_file::<AiffFile>("tests/taglib/data/alaw.aifc");
3129

3230
let properties = file.properties();
3331
assert_eq!(properties.duration().as_secs(), 0);
3432
assert_delta!(properties.duration().as_millis(), 37, 1);
35-
assert_eq!(properties.audio_bitrate(), Some(355));
36-
assert_eq!(properties.sample_rate(), Some(44100));
37-
assert_eq!(properties.channels(), Some(1));
38-
assert_eq!(properties.bit_depth(), Some(16));
33+
assert_eq!(properties.audio_bitrate(), 355);
34+
assert_eq!(properties.sample_rate(), 44100);
35+
assert_eq!(properties.channels(), 1);
36+
assert_eq!(properties.sample_size(), 16);
3937
// TODO: get those options in lofty
4038
// CPPUNIT_ASSERT_EQUAL(1622U, f.audioProperties()->sampleFrames());
41-
// CPPUNIT_ASSERT_EQUAL(true, f.audioProperties()->isAiffC());
42-
// CPPUNIT_ASSERT_EQUAL(ByteVector("ALAW"), f.audioProperties()->compressionType());
43-
// CPPUNIT_ASSERT_EQUAL(String("SGI CCITT G.711 A-law"), f.audioProperties()->compressionName());
39+
assert!(properties.compression_type().is_some());
40+
assert_eq!(
41+
properties.compression_type().unwrap().clone(),
42+
AiffCompressionType::ALAW
43+
);
44+
// NOTE: The file's compression name is actually "SGI CCITT G.711 A-law"
45+
//
46+
// We have a hardcoded value for any of the concrete AiffCompressionType variants, as the messages
47+
// are more or less standardized. This is not that big of a deal, especially as many encoders choose
48+
// not to even write a compression name in the first place.
49+
assert_eq!(
50+
properties.compression_type().unwrap().compression_name(),
51+
"CCITT G.711 A-law"
52+
);
4453
}
4554

4655
#[test]
47-
#[ignore]
4856
fn test_save_id3v2() {
4957
let mut file = temp_file!("tests/taglib/data/empty.aiff");
5058

@@ -68,11 +76,12 @@ fn test_save_id3v2() {
6876

6977
let mut id3v2 = tfile.id3v2().unwrap().to_owned();
7078
assert_eq!(id3v2.title().as_deref(), Some("TitleXXX"));
71-
id3v2.set_title(String::new());
79+
// NOTE: TagLib sets an empty title, which will implicitly remove it from the tag. Lofty will allow empty tag items to exist.
80+
// What's important is that these are equivalent in behavior.
81+
id3v2.remove_title();
7282
tfile.set_id3v2(id3v2);
7383
file.rewind().unwrap();
7484
tfile.save_to(&mut file).unwrap();
75-
assert!(!tfile.contains_tag_type(lofty::TagType::Id3v2));
7685
}
7786

7887
file.rewind().unwrap();

tests/taglib/test_apetag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::temp_file;
22

33
use std::io::Seek;
44

5-
use lofty::ape::{ApeFile, ApeItem, ApeTag};
5+
use lofty::ape::{ApeItem, ApeTag};
66
use lofty::musepack::MpcFile;
77
use lofty::{Accessor, AudioFile, ItemValue, ParseOptions, TagExt};
88

0 commit comments

Comments
 (0)