Skip to content

Commit 2db1ab3

Browse files
committed
Added test cases
1 parent d564ee7 commit 2db1ab3

7 files changed

+103
-1
lines changed

test/OptionHandlerTest.cpp

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//------------------------------------------------------------------------------
22
//
3-
// Copyright 2014-2022 BBC Research and Development
3+
// Copyright 2014-2023 BBC Research and Development
44
//
55
// Author: Chris Needham
66
//
@@ -425,6 +425,7 @@ TEST_F(OptionHandlerTest, shouldNotConvertWavToMp3Audio)
425425
TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromWavAudio)
426426
{
427427
std::vector<const char*> args{ "-b", "8", "-z", "64" };
428+
428429
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Dat, &args, true, "test_file_stereo_8bit_64spp_wav.dat");
429430
}
430431

@@ -433,6 +434,7 @@ TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromWavAudio)
433434
TEST_F(OptionHandlerTest, shouldGenerate2ChannelBinaryWaveformDataFromWavAudio)
434435
{
435436
std::vector<const char*> args{ "-b", "8", "-z", "64", "--split-channels" };
437+
436438
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Dat, &args, true, "test_file_2channel_8bit_64spp_wav.dat");
437439
}
438440

@@ -441,6 +443,7 @@ TEST_F(OptionHandlerTest, shouldGenerate2ChannelBinaryWaveformDataFromWavAudio)
441443
TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromFloatingPointWavAudio)
442444
{
443445
std::vector<const char*> args{ "-b", "8", "-z", "64" };
446+
444447
runTests("test_file_mono_float32.wav", FileFormat::Wav, FileFormat::Dat, &args, true, "test_file_mono_float32_8bit_64spp.dat");
445448
}
446449

@@ -449,6 +452,7 @@ TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromFloatingPointWavAu
449452
TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromMp3Audio)
450453
{
451454
std::vector<const char*> args{ "-b", "8", "-z", "64" };
455+
452456
runTests("test_file_stereo.mp3", FileFormat::Mp3, FileFormat::Dat, &args, true, "test_file_stereo_8bit_64spp_mp3.dat");
453457
}
454458

@@ -457,6 +461,7 @@ TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromMp3Audio)
457461
TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromFlacAudio)
458462
{
459463
std::vector<const char*> args{ "-b", "8", "-z", "64" };
464+
460465
runTests("test_file_stereo.flac", FileFormat::Flac, FileFormat::Dat, &args, true, "test_file_stereo_8bit_64spp_flac.dat");
461466
}
462467

@@ -465,6 +470,7 @@ TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromFlacAudio)
465470
TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromOggVorbisAudio)
466471
{
467472
std::vector<const char*> args{ "-b", "8", "-z", "64" };
473+
468474
runTests("test_file_stereo.oga", FileFormat::Ogg, FileFormat::Dat, &args, true, "test_file_stereo_8bit_64spp_oga.dat");
469475
}
470476

@@ -474,6 +480,7 @@ TEST_F(OptionHandlerTest, shouldGenerateBinaryWaveformDataFromOpusAudioIfSupport
474480
{
475481
if (FileFormat::isSupported(FileFormat::Opus)) {
476482
std::vector<const char*> args{ "-b", "8", "-z", "64" };
483+
477484
runTests("test_file_stereo.opus", FileFormat::Opus, FileFormat::Dat, &args, true, "test_file_stereo_8bit_64spp_opus.dat");
478485
}
479486
}
@@ -484,6 +491,7 @@ TEST_F(OptionHandlerTest, shouldNotGenerateBinaryWaveformDataFromOpusAudioIfNotS
484491
{
485492
if (!FileFormat::isSupported(FileFormat::Opus)) {
486493
std::vector<const char*> args{ "-b", "8", "-z", "64" };
494+
487495
runTests("test_file_stereo.opus", FileFormat::Opus, FileFormat::Dat, &args, false);
488496
}
489497
}
@@ -493,6 +501,7 @@ TEST_F(OptionHandlerTest, shouldNotGenerateBinaryWaveformDataFromOpusAudioIfNotS
493501
TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromWavAudio)
494502
{
495503
std::vector<const char*> args{ "-b", "8", "-z", "64" };
504+
496505
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Json, &args, true, "test_file_stereo_8bit_64spp_wav.json");
497506
}
498507

@@ -501,6 +510,7 @@ TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromWavAudio)
501510
TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromMp3Audio)
502511
{
503512
std::vector<const char*> args{ "-b", "8", "-z", "64" };
513+
504514
runTests("test_file_stereo.mp3", FileFormat::Mp3, FileFormat::Json, &args, true, "test_file_stereo_8bit_64spp_mp3.json");
505515
}
506516

@@ -509,6 +519,7 @@ TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromMp3Audio)
509519
TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromFlacAudio)
510520
{
511521
std::vector<const char*> args{ "-b", "8", "-z", "64" };
522+
512523
runTests("test_file_stereo.flac", FileFormat::Flac, FileFormat::Json, &args, true, "test_file_stereo_8bit_64spp_flac.json");
513524
}
514525

@@ -517,6 +528,7 @@ TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromFlacAudio)
517528
TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromOggVorbisAudio)
518529
{
519530
std::vector<const char*> args{ "-b", "8", "-z", "64" };
531+
520532
runTests("test_file_stereo.oga", FileFormat::Ogg, FileFormat::Json, &args, true, "test_file_stereo_8bit_64spp_oga.json");
521533
}
522534

@@ -526,6 +538,7 @@ TEST_F(OptionHandlerTest, shouldGenerateJsonWaveformDataFromOpusAudioIfSupported
526538
{
527539
if (FileFormat::isSupported(FileFormat::Opus)) {
528540
std::vector<const char*> args{ "-b", "8", "-z", "64" };
541+
529542
runTests("test_file_stereo.opus", FileFormat::Opus, FileFormat::Json, &args, true, "test_file_stereo_8bit_64spp_opus.json");
530543
}
531544
}
@@ -536,6 +549,7 @@ TEST_F(OptionHandlerTest, shouldNotGenerateJsonWaveformDataFromOpusAudioIfNotSup
536549
{
537550
if (!FileFormat::isSupported(FileFormat::Opus)) {
538551
std::vector<const char*> args{ "-b", "8", "-z", "64" };
552+
539553
runTests("test_file_stereo.opus", FileFormat::Opus, FileFormat::Json, &args, false);
540554
}
541555
}
@@ -627,6 +641,7 @@ TEST_F(OptionHandlerTest, shouldNotConvertTextWaveformDataToJson)
627641
TEST_F(OptionHandlerTest, shouldRenderSingleChannelWaveformImageWithCorrectAmplitudeScale)
628642
{
629643
std::vector<const char*> args{ "-z", "64" };
644+
630645
runTests("test_file_image_amplitude_scale_1channel.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_image_amplitude_scale_1channel.png");
631646
}
632647

@@ -635,6 +650,7 @@ TEST_F(OptionHandlerTest, shouldRenderSingleChannelWaveformImageWithCorrectAmpli
635650
TEST_F(OptionHandlerTest, shouldRenderTwoChannelWaveformImageWithCorrectAmplitudeScale)
636651
{
637652
std::vector<const char*> args{ "-z", "64" };
653+
638654
runTests("test_file_image_amplitude_scale_2channel.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_image_amplitude_scale_2channel.png");
639655
}
640656

@@ -643,6 +659,7 @@ TEST_F(OptionHandlerTest, shouldRenderTwoChannelWaveformImageWithCorrectAmplitud
643659
TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromBinaryWaveformData)
644660
{
645661
std::vector<const char*> args{ "-z", "128" };
662+
646663
runTests("test_file_stereo_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_stereo_dat_128spp.png");
647664
}
648665

@@ -651,6 +668,7 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromBinaryWaveformData)
651668
TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromFloatingPointWavAudio)
652669
{
653670
std::vector<const char*> args{ "-z", "128" };
671+
654672
runTests("test_file_mono_float32.wav", FileFormat::Wav, FileFormat::Png, &args, true, "test_file_mono_float32_128spp.png");
655673
}
656674

@@ -659,6 +677,7 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromFloatingPointWavAudio)
659677
TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromWavAudio)
660678
{
661679
std::vector<const char*> args{ "-z", "128" };
680+
662681
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Png, &args, true, "test_file_stereo_wav_128spp.png");
663682
}
664683

@@ -667,6 +686,7 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromWavAudio)
667686
TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromMp3Audio)
668687
{
669688
std::vector<const char*> args{ "-z", "128" };
689+
670690
runTests("test_file_stereo.mp3", FileFormat::Mp3, FileFormat::Png, &args, true, "test_file_stereo_mp3_128spp.png");
671691
}
672692

@@ -675,6 +695,7 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromMp3Audio)
675695
TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromFlacAudio)
676696
{
677697
std::vector<const char*> args{ "-z", "128" };
698+
678699
runTests("test_file_stereo.flac", FileFormat::Flac, FileFormat::Png, &args, true, "test_file_stereo_flac_128spp.png");
679700
}
680701

@@ -683,6 +704,7 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromFlacAudio)
683704
TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromOggVorbisAudio)
684705
{
685706
std::vector<const char*> args{ "-z", "128" };
707+
686708
runTests("test_file_stereo.oga", FileFormat::Ogg, FileFormat::Png, &args, true, "test_file_stereo_oga_128spp.png");
687709
}
688710

@@ -692,6 +714,7 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformImageFromOpusAudioIfSupported)
692714
{
693715
if (FileFormat::isSupported(FileFormat::Opus)) {
694716
std::vector<const char*> args{ "-z", "128" };
717+
695718
runTests("test_file_stereo.opus", FileFormat::Opus, FileFormat::Png, &args, true, "test_file_stereo_opus_128spp.png");
696719
}
697720
}
@@ -702,6 +725,7 @@ TEST_F(OptionHandlerTest, shouldNotRenderWaveformImageFromOpusAudioIfNotSupporte
702725
{
703726
if (!FileFormat::isSupported(FileFormat::Opus)) {
704727
std::vector<const char*> args{ "-z", "128" };
728+
705729
runTests("test_file_stereo.opus", FileFormat::Opus, FileFormat::Png, &args, false);
706730
}
707731
}
@@ -777,6 +801,60 @@ TEST_F(OptionHandlerTest, shouldRenderWaveformFitToImageWidthFromWav)
777801

778802
//------------------------------------------------------------------------------
779803

804+
TEST_F(OptionHandlerTest, shouldRenderWaveformWithSplitChannels)
805+
{
806+
std::vector<const char*> args{ "-z", "128", "--split-channels" };
807+
808+
runTests("test_file_2channel_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_2channel_8bit_64spp_wav.png");
809+
}
810+
811+
//------------------------------------------------------------------------------
812+
813+
TEST_F(OptionHandlerTest, shouldRenderWaveformWithStartTimeOffset)
814+
{
815+
std::vector<const char*> args{ "-z", "128", "--start", "0.5" };
816+
817+
runTests("test_file_stereo_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_stereo_dat_128spp_offset.png");
818+
}
819+
820+
//------------------------------------------------------------------------------
821+
822+
TEST_F(OptionHandlerTest, shouldRenderWaveformWithSquareBars)
823+
{
824+
std::vector<const char*> args{ "-z", "128", "--waveform-style", "bars" };
825+
826+
runTests("test_file_stereo_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_stereo_dat_128spp_square_bars.png");
827+
}
828+
829+
//------------------------------------------------------------------------------
830+
831+
TEST_F(OptionHandlerTest, shouldRenderWaveformWithRoundedBars)
832+
{
833+
std::vector<const char*> args{ "-z", "128", "--waveform-style", "bars", "--bar-style", "rounded" };
834+
835+
runTests("test_file_stereo_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_stereo_dat_128spp_rounded_bars.png");
836+
}
837+
838+
//------------------------------------------------------------------------------
839+
840+
TEST_F(OptionHandlerTest, shouldRenderWaveformBarsWithStartTimeOffset)
841+
{
842+
std::vector<const char*> args{ "-z", "128", "--waveform-style", "bars", "--start", "0.5" };
843+
844+
runTests("test_file_stereo_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_stereo_dat_128spp_square_bars_offset.png");
845+
}
846+
847+
//------------------------------------------------------------------------------
848+
849+
TEST_F(OptionHandlerTest, shouldRenderWaveformBarsWithSplitChannels)
850+
{
851+
std::vector<const char*> args{ "-z", "128", "--waveform-style", "bars", "--split-channels" };
852+
853+
runTests("test_file_2channel_8bit_64spp_wav.dat", FileFormat::Dat, FileFormat::Png, &args, true, "test_file_2channel_8bit_64spp_wav_bars.png");
854+
}
855+
856+
//------------------------------------------------------------------------------
857+
780858
TEST_F(OptionHandlerTest, shouldNotRenderWaveformImageFromJsonWaveformData)
781859
{
782860
runTests("test_file_stereo_8bit_64spp_wav.json", FileFormat::Json, FileFormat::Png, nullptr, false);
@@ -822,3 +900,27 @@ TEST_F(OptionHandlerTest, shouldFailIfPixelsPerSecondIsNegative)
822900
}
823901

824902
//------------------------------------------------------------------------------
903+
904+
TEST_F(OptionHandlerTest, shouldFailIfUnknownColorScheme)
905+
{
906+
std::vector<const char*> args{ "--colors", "test" };
907+
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Png, &args, false, nullptr, "Unknown color scheme: test\n");
908+
}
909+
910+
//------------------------------------------------------------------------------
911+
912+
TEST_F(OptionHandlerTest, shouldFailIfUnknownWaveformStyle)
913+
{
914+
std::vector<const char*> args{ "--waveform-style", "test" };
915+
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Png, &args, false, nullptr, "Unknown waveform style: test\n");
916+
}
917+
918+
//------------------------------------------------------------------------------
919+
920+
TEST_F(OptionHandlerTest, shouldFailIfUnknownWaveformBarStyle)
921+
{
922+
std::vector<const char*> args{ "--waveform-style", "bars", "--bar-style", "test" };
923+
runTests("test_file_stereo.wav", FileFormat::Wav, FileFormat::Png, &args, false, nullptr, "Unknown waveform bar style: test\n");
924+
}
925+
926+
//------------------------------------------------------------------------------
6.99 KB
Loading
2.45 KB
Loading
4.87 KB
Loading
2.95 KB
Loading
2.05 KB
Loading
2.06 KB
Loading

0 commit comments

Comments
 (0)