From 2006431fa8c0c8bfe0eef24e055d67718ae85f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sun, 28 Oct 2018 18:41:26 -0400 Subject: [PATCH] t: trivial manipulations --- t/tags.t | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/t/tags.t b/t/tags.t index 97872ad..98249d9 100644 --- a/t/tags.t +++ b/t/tags.t @@ -1,6 +1,6 @@ # Test the main features of opustags on an Ogg Opus sample file. -use Test::More tests => 2; +use Test::More tests => 14; use Digest::MD5; @@ -16,3 +16,35 @@ is(md5('t/gobble.opus'), '111a483596ac32352fbce4d14d16abd2', 'the sample is the is(`./opustags t/gobble.opus`, <<'EOF', 'read the initial tags'); encoder=Lavc58.18.100 libopus EOF + +unlink('t/out.opus'); +is(`./opustags t/gobble.opus -o t/out.opus 2>&1`, '', 'copy the file without changes'); +is(md5('t/out.opus'), '111a483596ac32352fbce4d14d16abd2', 'the copy is faithful'); +is($?, 0, 'check the error code'); + +# empty out.opus +open(my $fh, '> t/out.opus') or die; +close($fh); +is(`./opustags t/gobble.opus -o t/out.opus 2>&1 >/dev/null`, <<'EOF', 'refuse to override'); +'t/out.opus' already exists (use -y to overwrite) +EOF +is(md5('t/out.opus'), 'd41d8cd98f00b204e9800998ecf8427e', 'the output wasn\'t written'); +is($?, 256, 'check the error code'); + +is(`./opustags t/out.opus -o t/out.opus 2>&1 >/dev/null`, <<'EOF', 'output and input can\'t be the same'); +error: the input and output files are the same +EOF +is($?, 256, 'check the error code'); + +is(`./opustags t/gobble.opus -a A=B`, <<'EOF', 'dry add'); +encoder=Lavc58.18.100 libopus +A=B +EOF + +is(`./opustags t/gobble.opus --add A=B --output t/out.opus -y 2>&1`, '', 'add a tag'); +is(md5('t/out.opus'), '7a0bb7f46edf7d5bb735c32635f145fd', 'check the footprint of the result'); + +is(`./opustags t/out.opus`, <<'EOF', 'the added tag is read'); +encoder=Lavc58.18.100 libopus +A=B +EOF