@@ -5,7 +5,7 @@ use std::io::Seek;
55
66use lofty:: config:: { ParseOptions , WriteOptions } ;
77use lofty:: file:: { AudioFile , FileType } ;
8- use lofty:: id3:: v2:: Id3v2Tag ;
8+ use lofty:: id3:: v2:: { Id3v2Tag , Id3v2Version } ;
99use lofty:: iff:: aiff:: { AiffCompressionType , AiffFile } ;
1010use lofty:: probe:: Probe ;
1111use lofty:: tag:: { Accessor , TagType } ;
@@ -96,9 +96,33 @@ fn test_save_id3v2() {
9696}
9797
9898#[ test_log:: test]
99- #[ ignore]
10099fn 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+ }
102126}
103127
104128#[ test_log:: test]
0 commit comments