@@ -4,47 +4,55 @@ use crate::{assert_delta, temp_file};
4
4
use std:: io:: Seek ;
5
5
6
6
use lofty:: id3:: v2:: Id3v2Tag ;
7
- use lofty:: iff:: aiff:: AiffFile ;
7
+ use lofty:: iff:: aiff:: { AiffCompressionType , AiffFile } ;
8
8
use lofty:: { Accessor , AudioFile , FileType , ParseOptions , Probe } ;
9
9
10
10
#[ test]
11
- #[ ignore]
12
11
fn test_aiff_properties ( ) {
13
12
let file = get_file :: < AiffFile > ( "tests/taglib/data/empty.aiff" ) ;
14
13
15
14
let properties = file. properties ( ) ;
16
15
assert_eq ! ( properties. duration( ) . as_secs( ) , 0 ) ;
17
16
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 ) ;
22
21
// TODO: get those options in lofty
23
22
// CPPUNIT_ASSERT_EQUAL(2941U, f.audioProperties()->sampleFrames());
24
- // CPPUNIT_ASSERT_EQUAL(false, f.audioProperties()->isAiffC ());
23
+ assert ! ( properties . compression_type ( ) . is_none ( ) ) ;
25
24
}
26
25
27
26
#[ test]
28
- #[ ignore]
29
27
fn test_aifc_properties ( ) {
30
28
let file = get_file :: < AiffFile > ( "tests/taglib/data/alaw.aifc" ) ;
31
29
32
30
let properties = file. properties ( ) ;
33
31
assert_eq ! ( properties. duration( ) . as_secs( ) , 0 ) ;
34
32
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 ) ;
39
37
// TODO: get those options in lofty
40
38
// 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
+ ) ;
44
53
}
45
54
46
55
#[ test]
47
- #[ ignore]
48
56
fn test_save_id3v2 ( ) {
49
57
let mut file = temp_file ! ( "tests/taglib/data/empty.aiff" ) ;
50
58
@@ -68,11 +76,12 @@ fn test_save_id3v2() {
68
76
69
77
let mut id3v2 = tfile. id3v2 ( ) . unwrap ( ) . to_owned ( ) ;
70
78
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 ( ) ;
72
82
tfile. set_id3v2 ( id3v2) ;
73
83
file. rewind ( ) . unwrap ( ) ;
74
84
tfile. save_to ( & mut file) . unwrap ( ) ;
75
- assert ! ( !tfile. contains_tag_type( lofty:: TagType :: Id3v2 ) ) ;
76
85
}
77
86
78
87
file. rewind ( ) . unwrap ( ) ;
0 commit comments