1
- use lofty:: { Accessor , AudioFile , FileType , ParseOptions , TaggedFileExt } ;
1
+ use lofty:: { Accessor , AudioFile , FileType , ParseOptions , Probe } ;
2
2
3
+ use lofty:: id3:: v2:: Id3v2Tag ;
3
4
use lofty:: iff:: aiff:: AiffFile ;
4
- use std:: io:: { Read , Seek } ;
5
+ use std:: io:: Seek ;
5
6
6
- use crate :: util:: get_filetype ;
7
+ use crate :: util:: get_file ;
7
8
use crate :: { assert_delta, temp_file} ;
8
9
9
10
#[ test]
10
11
#[ ignore]
11
12
fn test_aiff_properties ( ) {
12
- let file = lofty:: read_from_path ( "tests/taglib/data/empty.aiff" ) . unwrap ( ) ;
13
-
14
- assert_eq ! ( file. file_type( ) , FileType :: Aiff ) ;
13
+ let file = get_file :: < AiffFile > ( "tests/taglib/data/empty.aiff" ) ;
15
14
16
15
let properties = file. properties ( ) ;
17
16
assert_eq ! ( properties. duration( ) . as_secs( ) , 0 ) ;
@@ -28,9 +27,7 @@ fn test_aiff_properties() {
28
27
#[ test]
29
28
#[ ignore]
30
29
fn test_aifc_properties ( ) {
31
- let file = lofty:: read_from_path ( "tests/taglib/data/alaw.aifc" ) . unwrap ( ) ;
32
-
33
- assert_eq ! ( file. file_type( ) , FileType :: Aiff ) ;
30
+ let file = get_file :: < AiffFile > ( "tests/taglib/data/alaw.aifc" ) ;
34
31
35
32
let properties = file. properties ( ) ;
36
33
assert_eq ! ( properties. duration( ) . as_secs( ) , 0 ) ;
@@ -52,15 +49,13 @@ fn test_save_id3v2() {
52
49
let mut file = temp_file ! ( "tests/taglib/data/empty.aiff" ) ;
53
50
54
51
{
55
- let mut tfile = lofty :: read_from ( & mut file) . unwrap ( ) ;
52
+ let mut tfile = AiffFile :: read_from ( & mut file, ParseOptions :: new ( ) ) . unwrap ( ) ;
56
53
57
- assert_eq ! ( tfile. file_type ( ) , FileType :: Aiff ) ;
54
+ assert ! ( tfile. id3v2 ( ) . is_none ( ) ) ;
58
55
59
- assert ! ( tfile. tag( lofty:: TagType :: Id3v2 ) . is_none( ) ) ;
60
-
61
- let mut tag = lofty:: Tag :: new ( lofty:: TagType :: Id3v2 ) ;
62
- tag. set_title ( "TitleXXX" . to_string ( ) ) ;
63
- tfile. insert_tag ( tag) ;
56
+ let mut id3v2 = Id3v2Tag :: new ( ) ;
57
+ id3v2. set_title ( "TitleXXX" . to_string ( ) ) ;
58
+ tfile. set_id3v2 ( id3v2) ;
64
59
file. rewind ( ) . unwrap ( ) ;
65
60
tfile. save_to ( & mut file) . unwrap ( ) ;
66
61
assert ! ( tfile. contains_tag_type( lofty:: TagType :: Id3v2 ) ) ;
@@ -69,14 +64,12 @@ fn test_save_id3v2() {
69
64
file. rewind ( ) . unwrap ( ) ;
70
65
71
66
{
72
- let mut tfile = lofty:: read_from ( & mut file) . unwrap ( ) ;
73
-
74
- assert_eq ! ( tfile. file_type( ) , FileType :: Aiff ) ;
67
+ let mut tfile = AiffFile :: read_from ( & mut file, ParseOptions :: new ( ) ) . unwrap ( ) ;
75
68
76
- let mut tag = tfile. tag ( lofty :: TagType :: Id3v2 ) . unwrap ( ) . to_owned ( ) ;
77
- assert_eq ! ( tag . title( ) . as_deref( ) , Some ( "TitleXXX" ) ) ;
78
- tag . set_title ( String :: new ( ) ) ;
79
- tfile. insert_tag ( tag ) ;
69
+ let mut id3v2 = tfile. id3v2 ( ) . unwrap ( ) . to_owned ( ) ;
70
+ assert_eq ! ( id3v2 . title( ) . as_deref( ) , Some ( "TitleXXX" ) ) ;
71
+ id3v2 . set_title ( String :: new ( ) ) ;
72
+ tfile. set_id3v2 ( id3v2 ) ;
80
73
file. rewind ( ) . unwrap ( ) ;
81
74
tfile. save_to ( & mut file) . unwrap ( ) ;
82
75
assert ! ( !tfile. contains_tag_type( lofty:: TagType :: Id3v2 ) ) ;
@@ -85,10 +78,7 @@ fn test_save_id3v2() {
85
78
file. rewind ( ) . unwrap ( ) ;
86
79
87
80
{
88
- let tfile = lofty:: read_from ( & mut file) . unwrap ( ) ;
89
-
90
- assert_eq ! ( tfile. file_type( ) , FileType :: Aiff ) ;
91
-
81
+ let tfile = AiffFile :: read_from ( & mut file, ParseOptions :: new ( ) ) . unwrap ( ) ;
92
82
assert ! ( !tfile. contains_tag_type( lofty:: TagType :: Id3v2 ) ) ;
93
83
}
94
84
}
@@ -104,11 +94,14 @@ fn test_duplicate_id3v2() {
104
94
}
105
95
106
96
#[ test]
107
- #[ ignore]
108
97
fn test_fuzzed_file1 ( ) {
109
98
assert_eq ! (
110
- get_filetype( "tests/taglib/data/segfault.aif" ) ,
111
- FileType :: Aiff
99
+ Probe :: open( "tests/taglib/data/segfault.aif" )
100
+ . unwrap( )
101
+ . guess_file_type( )
102
+ . unwrap( )
103
+ . file_type( ) ,
104
+ Some ( FileType :: Aiff )
112
105
) ;
113
106
}
114
107
0 commit comments