@@ -5,7 +5,7 @@ use std::io::Seek;
5
5
6
6
use lofty:: config:: { ParseOptions , WriteOptions } ;
7
7
use lofty:: file:: { AudioFile , FileType } ;
8
- use lofty:: id3:: v2:: Id3v2Tag ;
8
+ use lofty:: id3:: v2:: { Id3v2Tag , Id3v2Version } ;
9
9
use lofty:: iff:: aiff:: { AiffCompressionType , AiffFile } ;
10
10
use lofty:: probe:: Probe ;
11
11
use lofty:: tag:: { Accessor , TagType } ;
@@ -96,9 +96,33 @@ fn test_save_id3v2() {
96
96
}
97
97
98
98
#[ test_log:: test]
99
- #[ ignore]
100
99
fn test_save_id3v23 ( ) {
101
- todo ! ( "Support writing ID3v2.3 tags" )
100
+ let mut file = temp_file ! ( "tests/taglib/data/empty.aiff" ) ;
101
+
102
+ let xxx = "X" . repeat ( 254 ) ;
103
+ {
104
+ let mut tfile = AiffFile :: read_from ( & mut file, ParseOptions :: new ( ) ) . unwrap ( ) ;
105
+
106
+ assert ! ( tfile. id3v2( ) . is_none( ) ) ;
107
+
108
+ let mut id3v2 = Id3v2Tag :: new ( ) ;
109
+ id3v2. set_title ( xxx. clone ( ) ) ;
110
+ id3v2. set_artist ( String :: from ( "Artist A" ) ) ;
111
+ tfile. set_id3v2 ( id3v2) ;
112
+ file. rewind ( ) . unwrap ( ) ;
113
+ tfile
114
+ . save_to ( & mut file, WriteOptions :: default ( ) . use_id3v23 ( true ) )
115
+ . unwrap ( ) ;
116
+ assert ! ( tfile. contains_tag_type( TagType :: Id3v2 ) ) ;
117
+ }
118
+ file. rewind ( ) . unwrap ( ) ;
119
+ {
120
+ let tfile = AiffFile :: read_from ( & mut file, ParseOptions :: new ( ) ) . unwrap ( ) ;
121
+ let id3v2 = tfile. id3v2 ( ) . unwrap ( ) . to_owned ( ) ;
122
+ assert_eq ! ( id3v2. original_version( ) , Id3v2Version :: V3 ) ;
123
+ assert_eq ! ( id3v2. artist( ) . as_deref( ) , Some ( "Artist A" ) ) ;
124
+ assert_eq ! ( id3v2. title( ) . as_deref( ) , Some ( & * xxx) ) ;
125
+ }
102
126
}
103
127
104
128
#[ test_log:: test]
0 commit comments