From 8aa37f20ef73cfa056c2caa2a4b8a6a138dda6b2 Mon Sep 17 00:00:00 2001 From: abscisys Date: Thu, 26 Jan 2023 23:37:35 +0100 Subject: [PATCH] Small updates on the unit tests --- src/fx_engine.hpp | 2 +- src/fx_unit.hpp | 3 - src/fx_unit2.hpp | 3 - src/mixing_console_constants.h | 26 +++++---- src/test/test_fx_rack.cpp | 2 +- src/test/test_mixing_console.cpp | 98 +++----------------------------- 6 files changed, 23 insertions(+), 111 deletions(-) diff --git a/src/fx_engine.hpp b/src/fx_engine.hpp index 132fa61..662ca01 100644 --- a/src/fx_engine.hpp +++ b/src/fx_engine.hpp @@ -199,7 +199,7 @@ public: buffer_(nullptr), write_ptr_(0) { - memset(this->lfo_value_, 0, LFOIndex::kLFOCount * sizeof(T)); + memset(this->lfo_value_, 0, LFOIndex::kLFOCount * sizeof(float32_t)); } ~Context() diff --git a/src/fx_unit.hpp b/src/fx_unit.hpp index f986c83..0f7abd9 100644 --- a/src/fx_unit.hpp +++ b/src/fx_unit.hpp @@ -20,9 +20,6 @@ #include "fx_components.h" -#include -using namespace std; - class FXUnitModule { DISALLOW_COPY_AND_ASSIGN(FXUnitModule); diff --git a/src/fx_unit2.hpp b/src/fx_unit2.hpp index dbebd55..9bda222 100644 --- a/src/fx_unit2.hpp +++ b/src/fx_unit2.hpp @@ -20,9 +20,6 @@ #include "fx_components.h" -#include -using namespace std; - class FXUnitModule2 { DISALLOW_COPY_AND_ASSIGN(FXUnitModule2); diff --git a/src/mixing_console_constants.h b/src/mixing_console_constants.h index 270382c..0ee414b 100644 --- a/src/mixing_console_constants.h +++ b/src/mixing_console_constants.h @@ -38,26 +38,28 @@ inline std::string toString(MixerOutput enum_val) "Orbitone", "Phaser", "Delay", - "Plate Reverb", - "Shimmer Reverb", - "Main Output" + "PlateReverb", + "ShimmerReverb", + "MainOutput" }; static_assert(names.size() == MixerOutput::kFXCount, "Enum MixerOutput and string array size mismatch"); return std::string(names[static_cast(enum_val)]); } +#define TO_INDEX_CHECK(str, fx) if(std::strcmp(str, toString(fx).c_str()) == 0) return fx; + inline MixerOutput toIndex(const char* str) { - if(strcmp(str, "Tube") == 0) return MixerOutput::FX_Tube; - if(strcmp(str, "Chorus") == 0) return MixerOutput::FX_Chorus; - if(strcmp(str, "Flanger") == 0) return MixerOutput::FX_Flanger; - if(strcmp(str, "Orbitone") == 0) return MixerOutput::FX_Orbitone; - if(strcmp(str, "Phaser") == 0) return MixerOutput::FX_Phaser; - if(strcmp(str, "Delay") == 0) return MixerOutput::FX_Delay; - if(strcmp(str, "PlateReverb") == 0) return MixerOutput::FX_PlateReverb; - if(strcmp(str, "ShimmerReverb") == 0) return MixerOutput::FX_ShimmerReverb; - if(strcmp(str, "MainOutput") == 0) return MixerOutput::MainOutput; + TO_INDEX_CHECK(str, MixerOutput::FX_Tube); + TO_INDEX_CHECK(str, MixerOutput::FX_Chorus); + TO_INDEX_CHECK(str, MixerOutput::FX_Flanger); + TO_INDEX_CHECK(str, MixerOutput::FX_Orbitone); + TO_INDEX_CHECK(str, MixerOutput::FX_Phaser); + TO_INDEX_CHECK(str, MixerOutput::FX_Delay); + TO_INDEX_CHECK(str, MixerOutput::FX_PlateReverb); + TO_INDEX_CHECK(str, MixerOutput::FX_ShimmerReverb); + TO_INDEX_CHECK(str, MixerOutput::MainOutput); throw std::invalid_argument("Invalid MixerOutput string"); } diff --git a/src/test/test_fx_rack.cpp b/src/test/test_fx_rack.cpp index 71b0099..fcc6628 100644 --- a/src/test/test_fx_rack.cpp +++ b/src/test/test_fx_rack.cpp @@ -92,7 +92,7 @@ TEST_P(FXScenarioTest, ScenarioProcessing) setupRack(rack); rack->reset(); - int fxSwitch = GetParam(); + int fxSwitch = this->GetParam(); activateRackFXUnitScenario(rack, fxSwitch); diff --git a/src/test/test_mixing_console.cpp b/src/test/test_mixing_console.cpp index 8526d94..2ba22bb 100644 --- a/src/test/test_mixing_console.cpp +++ b/src/test/test_mixing_console.cpp @@ -18,101 +18,17 @@ void normalizedValueInspector(const std::string& el, size_t idx, const float32_t } } -TEST(MixerOutputTest, toStringForTube) -{ - auto v = toString(MixerOutput::FX_Tube); - EXPECT_EQ(v, "Tube"); -} - -TEST(MixerOutputTest, toStringForChorus) -{ - auto v = toString(MixerOutput::FX_Chorus); - EXPECT_EQ(v, "Chorus"); -} - -TEST(MixerOutputTest, toStringForFlanger) -{ - auto v = toString(MixerOutput::FX_Flanger); - EXPECT_EQ(v, "Flanger"); -} - -TEST(MixerOutputTest, toStringForOrbitone) -{ - auto v = toString(MixerOutput::FX_Orbitone); - EXPECT_EQ(v, "Orbitone"); -} +class MixingConsoleScenarioTest : public testing::TestWithParam {}; -TEST(MixerOutputTest, toStringForPhaser) +TEST_P(MixingConsoleScenarioTest, MixerOutputTest) { - auto v = toString(MixerOutput::FX_Phaser); - EXPECT_EQ(v, "Phaser"); + MixerOutput v = this->GetParam(); + std::string str = toString(v); + MixerOutput mo = toIndex(str.c_str()); + EXPECT_EQ(v, mo); } -TEST(MixerOutputTest, toStringForDelay) -{ - auto v = toString(MixerOutput::FX_Delay); - EXPECT_EQ(v, "Delay"); -} - -TEST(MixerOutputTest, toStringForPlateReverb) -{ - auto v = toString(MixerOutput::FX_PlateReverb); - EXPECT_EQ(v, "Plate Reverb"); -} - -TEST(MixerOutputTest, toStringForShimmerReverb) -{ - auto v = toString(MixerOutput::FX_ShimmerReverb); - EXPECT_EQ(v, "Shimmer Reverb"); -} - -TEST(MixerOutputTest, toIndexTube) -{ - MixerOutput v = toIndex("Tube"); - EXPECT_EQ(v, MixerOutput::FX_Tube); -} - -TEST(MixerOutputTest, toIndexChorus) -{ - MixerOutput v = toIndex("Chorus"); - EXPECT_EQ(v, MixerOutput::FX_Chorus); -} - -TEST(MixerOutputTest, toIndexFlanger) -{ - MixerOutput v = toIndex("Flanger"); - EXPECT_EQ(v, MixerOutput::FX_Flanger); -} - -TEST(MixerOutputTest, toIndexOrbitone) -{ - MixerOutput v = toIndex("Orbitone"); - EXPECT_EQ(v, MixerOutput::FX_Orbitone); -} - -TEST(MixerOutputTest, toIndexPhaser) -{ - MixerOutput v = toIndex("Phaser"); - EXPECT_EQ(v, MixerOutput::FX_Phaser); -} - -TEST(MixerOutputTest, toIndexDelay) -{ - MixerOutput v = toIndex("Delay"); - EXPECT_EQ(v, MixerOutput::FX_Delay); -} - -TEST(MixerOutputTest, toIndexPlateReverb) -{ - MixerOutput v = toIndex("PlateReverb"); - EXPECT_EQ(v, MixerOutput::FX_PlateReverb); -} - -TEST(MixerOutputTest, toIndexShimmerReverb) -{ - MixerOutput v = toIndex("ShimmerReverb"); - EXPECT_EQ(v, MixerOutput::FX_ShimmerReverb); -} +INSTANTIATE_TEST_SUITE_P(MixerOutputTest, MixingConsoleScenarioTest, testing::Range(MixerOutput::OutputStart, MixerOutput::kFXCount)); typedef MixingConsole<8> Mixer;