Skip to content

Commit 33d0483

Browse files
committed
Tests: Update VorbisComments usages to use push
1 parent e667f73 commit 33d0483

File tree

2 files changed

+56
-89
lines changed

2 files changed

+56
-89
lines changed

tests/taglib/test_flac.rs

Lines changed: 42 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,12 @@ fn test_save_multiple_values() {
264264
let mut f = FlacFile::read_from(&mut file, ParseOptions::new()).unwrap();
265265
file.rewind().unwrap();
266266

267-
f.vorbis_comments_mut().unwrap().insert(
268-
String::from("ARTIST"),
269-
String::from("artist 1"),
270-
false,
271-
);
272-
f.vorbis_comments_mut().unwrap().insert(
273-
String::from("ARTIST"),
274-
String::from("artist 2"),
275-
false,
276-
);
267+
f.vorbis_comments_mut()
268+
.unwrap()
269+
.push(String::from("ARTIST"), String::from("artist 1"));
270+
f.vorbis_comments_mut()
271+
.unwrap()
272+
.push(String::from("ARTIST"), String::from("artist 2"));
277273
f.save_to(&mut file).unwrap();
278274
}
279275
file.rewind().unwrap();
@@ -295,99 +291,72 @@ fn test_dict() {
295291
#[test]
296292
fn test_properties() {
297293
let mut tag = VorbisComments::default();
298-
tag.insert(String::from("ALBUM"), String::from("Album"), false);
299-
tag.insert(
300-
String::from("ALBUMARTIST"),
301-
String::from("Album Artist"),
302-
false,
303-
);
304-
tag.insert(
294+
tag.push(String::from("ALBUM"), String::from("Album"));
295+
tag.push(String::from("ALBUMARTIST"), String::from("Album Artist"));
296+
tag.push(
305297
String::from("ALBUMARTISTSORT"),
306298
String::from("Album Artist Sort"),
307-
false,
308-
);
309-
tag.insert(String::from("ALBUMSORT"), String::from("Album Sort"), false);
310-
tag.insert(String::from("ARTIST"), String::from("Artist"), false);
311-
tag.insert(String::from("ARTISTS"), String::from("Artists"), false);
312-
tag.insert(
313-
String::from("ARTISTSORT"),
314-
String::from("Artist Sort"),
315-
false,
316299
);
317-
tag.insert(String::from("ASIN"), String::from("ASIN"), false);
318-
tag.insert(String::from("BARCODE"), String::from("Barcode"), false);
319-
tag.insert(
300+
tag.push(String::from("ALBUMSORT"), String::from("Album Sort"));
301+
tag.push(String::from("ARTIST"), String::from("Artist"));
302+
tag.push(String::from("ARTISTS"), String::from("Artists"));
303+
tag.push(String::from("ARTISTSORT"), String::from("Artist Sort"));
304+
tag.push(String::from("ASIN"), String::from("ASIN"));
305+
tag.push(String::from("BARCODE"), String::from("Barcode"));
306+
tag.push(
320307
String::from("CATALOGNUMBER"),
321308
String::from("Catalog Number 1"),
322-
false,
323309
);
324-
tag.insert(
310+
tag.push(
325311
String::from("CATALOGNUMBER"),
326312
String::from("Catalog Number 2"),
327-
false,
328313
);
329-
tag.insert(String::from("COMMENT"), String::from("Comment"), false);
330-
tag.insert(String::from("DATE"), String::from("2021-01-10"), false);
331-
tag.insert(String::from("DISCNUMBER"), String::from("3/5"), false);
332-
tag.insert(String::from("GENRE"), String::from("Genre"), false);
333-
tag.insert(String::from("ISRC"), String::from("UKAAA0500001"), false);
334-
tag.insert(String::from("LABEL"), String::from("Label 1"), false);
335-
tag.insert(String::from("LABEL"), String::from("Label 2"), false);
336-
tag.insert(String::from("MEDIA"), String::from("Media"), false);
337-
tag.insert(
314+
tag.push(String::from("COMMENT"), String::from("Comment"));
315+
tag.push(String::from("DATE"), String::from("2021-01-10"));
316+
tag.push(String::from("DISCNUMBER"), String::from("3/5"));
317+
tag.push(String::from("GENRE"), String::from("Genre"));
318+
tag.push(String::from("ISRC"), String::from("UKAAA0500001"));
319+
tag.push(String::from("LABEL"), String::from("Label 1"));
320+
tag.push(String::from("LABEL"), String::from("Label 2"));
321+
tag.push(String::from("MEDIA"), String::from("Media"));
322+
tag.push(
338323
String::from("MUSICBRAINZ_ALBUMARTISTID"),
339324
String::from("MusicBrainz_AlbumartistID"),
340-
false,
341325
);
342-
tag.insert(
326+
tag.push(
343327
String::from("MUSICBRAINZ_ALBUMID"),
344328
String::from("MusicBrainz_AlbumID"),
345-
false,
346329
);
347-
tag.insert(
330+
tag.push(
348331
String::from("MUSICBRAINZ_ARTISTID"),
349332
String::from("MusicBrainz_ArtistID"),
350-
false,
351333
);
352-
tag.insert(
334+
tag.push(
353335
String::from("MUSICBRAINZ_RELEASEGROUPID"),
354336
String::from("MusicBrainz_ReleasegroupID"),
355-
false,
356337
);
357-
tag.insert(
338+
tag.push(
358339
String::from("MUSICBRAINZ_RELEASETRACKID"),
359340
String::from("MusicBrainz_ReleasetrackID"),
360-
false,
361341
);
362-
tag.insert(
342+
tag.push(
363343
String::from("MUSICBRAINZ_TRACKID"),
364344
String::from("MusicBrainz_TrackID"),
365-
false,
366-
);
367-
tag.insert(
368-
String::from("ORIGINALDATE"),
369-
String::from("2021-01-09"),
370-
false,
371345
);
372-
tag.insert(
346+
tag.push(String::from("ORIGINALDATE"), String::from("2021-01-09"));
347+
tag.push(
373348
String::from("RELEASECOUNTRY"),
374349
String::from("Release Country"),
375-
false,
376350
);
377-
tag.insert(
351+
tag.push(
378352
String::from("RELEASESTATUS"),
379353
String::from("Release Status"),
380-
false,
381354
);
382-
tag.insert(
383-
String::from("RELEASETYPE"),
384-
String::from("Release Type"),
385-
false,
386-
);
387-
tag.insert(String::from("SCRIPT"), String::from("Script"), false);
388-
tag.insert(String::from("TITLE"), String::from("Title"), false);
389-
tag.insert(String::from("TRACKNUMBER"), String::from("2"), false);
390-
tag.insert(String::from("TRACKTOTAL"), String::from("4"), false);
355+
tag.push(String::from("RELEASETYPE"), String::from("Release Type"));
356+
tag.push(String::from("SCRIPT"), String::from("Script"));
357+
tag.push(String::from("TITLE"), String::from("Title"));
358+
tag.push(String::from("TRACKNUMBER"), String::from("2"));
359+
tag.push(String::from("TRACKTOTAL"), String::from("4"));
391360

392361
let mut file = temp_file!("tests/taglib/data/no-tags.flac");
393362
{
@@ -412,11 +381,9 @@ fn test_invalid() {
412381
let mut file = temp_file!("tests/taglib/data/silence-44-s.flac");
413382
let mut f = FlacFile::read_from(&mut file, ParseOptions::new()).unwrap();
414383

415-
f.vorbis_comments_mut().unwrap().insert(
416-
String::from("H\x00c4\x00d6"),
417-
String::from("bla"),
418-
false,
419-
);
384+
f.vorbis_comments_mut()
385+
.unwrap()
386+
.push(String::from("H\x00c4\x00d6"), String::from("bla"));
420387
}
421388

422389
#[test]

tests/taglib/test_xiphcomment.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ use std::io::Seek;
99
fn test_year() {
1010
let mut cmt = VorbisComments::default();
1111
assert_eq!(cmt.year(), None);
12-
cmt.insert(String::from("YEAR"), String::from("2009"), false);
12+
cmt.push(String::from("YEAR"), String::from("2009"));
1313
assert_eq!(cmt.year(), Some(2009));
1414

1515
// NOTE: Lofty will *always* prioritize "YEAR" over "DATE". TagLib doesn't have the same ideas,
1616
// so we have to remove "YEAR".
1717
let _ = cmt.remove("YEAR");
1818

19-
cmt.insert(String::from("DATE"), String::from("2008"), false);
19+
cmt.push(String::from("DATE"), String::from("2008"));
2020
assert_eq!(cmt.year(), Some(2008));
2121
}
2222

2323
#[test]
2424
fn test_set_year() {
2525
let mut cmt = VorbisComments::default();
26-
cmt.insert(String::from("YEAR"), String::from("2009"), false);
27-
cmt.insert(String::from("DATE"), String::from("2008"), false);
26+
cmt.push(String::from("YEAR"), String::from("2009"));
27+
cmt.push(String::from("DATE"), String::from("2008"));
2828
cmt.set_year(1995);
2929
assert!(cmt.get("YEAR").is_none());
3030
assert_eq!(cmt.get("DATE"), Some("1995"));
@@ -34,17 +34,17 @@ fn test_set_year() {
3434
fn test_track() {
3535
let mut cmt = VorbisComments::default();
3636
assert_eq!(cmt.track(), None);
37-
cmt.insert(String::from("TRACKNUM"), String::from("7"), false);
37+
cmt.push(String::from("TRACKNUM"), String::from("7"));
3838
assert_eq!(cmt.track(), Some(7));
39-
cmt.insert(String::from("TRACKNUMBER"), String::from("8"), false);
39+
cmt.push(String::from("TRACKNUMBER"), String::from("8"));
4040
assert_eq!(cmt.year(), Some(8));
4141
}
4242

4343
#[test]
4444
fn test_set_track() {
4545
let mut cmt = VorbisComments::default();
46-
cmt.insert(String::from("TRACKNUM"), String::from("7"), false);
47-
cmt.insert(String::from("TRACKNUMBER"), String::from("8"), false);
46+
cmt.push(String::from("TRACKNUM"), String::from("7"));
47+
cmt.push(String::from("TRACKNUMBER"), String::from("8"));
4848
cmt.set_track(3);
4949
assert!(cmt.get("TRACKNUM").is_none());
5050
assert_eq!(cmt.get("TRACKNUMBER"), Some("3"));
@@ -59,11 +59,11 @@ fn test_invalid_keys1() {
5959
#[test]
6060
fn test_invalid_keys2() {
6161
let mut cmt = VorbisComments::default();
62-
cmt.insert(String::new(), String::new(), false);
63-
cmt.insert(String::from("A=B"), String::new(), false);
64-
cmt.insert(String::from("A~B"), String::new(), false);
65-
cmt.insert(String::from("A\x7F"), String::new(), false);
66-
cmt.insert(String::from("A\u{3456}"), String::new(), false);
62+
cmt.push(String::new(), String::new());
63+
cmt.push(String::from("A=B"), String::new());
64+
cmt.push(String::from("A~B"), String::new());
65+
cmt.push(String::from("A\x7F"), String::new());
66+
cmt.push(String::from("A\u{3456}"), String::new());
6767

6868
assert!(cmt.is_empty());
6969
}
@@ -77,7 +77,7 @@ fn test_clear_comment() {
7777
file.rewind().unwrap();
7878

7979
f.vorbis_comments_mut()
80-
.insert(String::from("COMMENT"), String::from("Comment1"), false);
80+
.push(String::from("COMMENT"), String::from("Comment1"));
8181
f.save_to(&mut file).unwrap();
8282
}
8383
file.rewind().unwrap();

0 commit comments

Comments
 (0)