Part 2 of the migration to gtest

pull/495/head
Vincent 2 years ago
parent c6f93e6dbb
commit 68e2a887c6
  1. 22
      src/test/Makefile
  2. 4
      src/test/desktop.ini
  3. 44
      src/test/test_fixture.cpp
  4. 32
      src/test/test_fixture.h
  5. 37
      src/test/test_fx_helper.cpp
  6. 28
      src/test/test_fx_helper.h

@ -4,20 +4,20 @@ EXECUTABLE := all_test.bin
CXX := g++
# CXXFLAGS := -O2
CXXFLAGS := -g -std=c++20
DEFINES := -DCPU=x86 -DDEBUG=1 -DOUTPUT_FOLDER=$(OUTPUT_FOLDER)
INCLUDES := -I../../CMSIS_5/CMSIS/DSP/Include/ \
CXXFLAGS = -g -std=c++20
DEFINES = -DCPU=x86 -DDEBUG -DOUTPUT_FOLDER=$(OUTPUT_FOLDER)
INCLUDES = -I../../CMSIS_5/CMSIS/DSP/Include/ \
-I../../CMSIS_5/CMSIS/Core/Include/ \
-I../../Synth_Dexed/src
-I../../Synth_Dexed/src/
# -I../../circle-stdlib/libs/circle/include \
# -I../../circle-stdlib/libs/circle/addon \
GCC := $(CXX) $(INCLUDES) $(CXXFLAGS)
LD := g++
LIBS := -lm -lstdc++ -lgtest -lpthread
SRCS = $(filter-out waveplay.cpp, $(wildcard *.cpp))
SRCS := $(filter-out waveplay.cpp, $(wildcard *.cpp))
SRCS += ../fx.cpp
SRCS += ../fx_components.cpp
SRCS += ../fx_svf.cpp
SRCS += ../fx_tube.cpp
SRCS += ../fx_chorus.cpp
@ -30,8 +30,8 @@ SRCS += ../fx_shimmer_reverb.cpp
SRCS += ../fx_dry.cpp
SRCS += ../fx_rack.cpp
OBJS = $(SRCS:.cpp=.o)
# OBJS = $(addprefix $(OBJDIR)/,$(OBJ))
OBJ = $(SRCS:.cpp=.o)
OBJS = $(addprefix $(OBJDIR)/,$(OBJ))
all: $(EXECUTABLE)
@ -45,16 +45,12 @@ $(OBJDIR):
mkdir -p $(OBJDIR)
$(OBJDIR)/%.o: %.cpp $(OBJDIR)
$(CXX) $(DEFINES) $(INCLUDES) $(CXXFLAGS) -c $< -o $@
# mv -f $@ $(OBJDIR)
$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@
test_mixing_console.cpp: ../mixing_console.h ../mixing_console.cpp
touch $@
$(EXECUTABLE): $(OBJS)
echo "***************************"
echo $(OBJS)
echo "***************************"
$(LD) $(OBJS) -o $@ $(LIBS)
$(OUTPUT_FOLDER):

@ -1,4 +0,0 @@
[ViewState]
Mode=
Vid=
FolderType=Generic

@ -1,44 +0,0 @@
#include "test_fixture.h"
#include <iomanip>
#include <iostream>
#include <sstream>
#include <locale>
#include <random>
#include <string>
void setupOuputStreamFocCSV(std::ostream& out)
{
struct comma_separator : numpunct<char>
{
virtual char do_decimal_point() const override { return ','; }
};
out.imbue(locale(out.getloc(), new comma_separator));
out << fixed << showpoint;
}
FxComponentFixture::FxComponentFixture() :
testing::Test(),
gen_(rd_()),
dist_(-1.0f, 1.0f)
{
}
void FxComponentFixture::SetUp()
{
}
void FxComponentFixture::TearDown()
{
}
string FxComponentFixture::getResultFile(const std::string& filename)
{
return std::string(STR(OUTPUT_FOLDER)) + "/" + filename;
}
float32_t FxComponentFixture::getRandomValue()
{
return this->dist_(this->gen_);
}

@ -1,32 +0,0 @@
#pragma once
#include <gtest/gtest.h>
#include <iomanip>
#include <iostream>
#include <locale>
#include <random>
#include <string>
#include "../fx.h"
#define STR(x) #x
void setupOuputStreamFocCSV(std::ostream& out);
class FxComponentFixture : public testing::Test
{
public:
FxComponentFixture();
virtual void SetUp() override;
virtual void TearDown() override;
std::string getResultFile(const string& filename);
float32_t getRandomValue();
random_device rd_;
mt19937 gen_;
uniform_real_distribution<float32_t> dist_;
};

@ -83,3 +83,40 @@ string getScenarioName(int scenario)
return ss.str();
}
void setupOuputStreamFocCSV(std::ostream& out)
{
struct comma_separator : numpunct<char>
{
virtual char do_decimal_point() const override { return ','; }
};
out.imbue(locale(out.getloc(), new comma_separator));
out << fixed << showpoint;
}
FxComponentFixture::FxComponentFixture() :
testing::Test(),
gen_(rd_()),
dist_(-1.0f, 1.0f)
{
}
void FxComponentFixture::SetUp()
{
}
void FxComponentFixture::TearDown()
{
}
string FxComponentFixture::getResultFile(const std::string& filename)
{
return std::string(STR(OUTPUT_FOLDER)) + "/" + filename;
}
float32_t FxComponentFixture::getRandomValue()
{
return this->dist_(this->gen_);
}

@ -1,16 +1,21 @@
#pragma once
#include "test_fixture.h"
#include <random>
#include <string>
#include <gtest/gtest.h>
#include "../fx.h"
#include "../mixing_console_constants.h"
#define AUDIO_SOURCE_FILE "test.wav"
#define SAMPLING_FREQUENCY 44100.0f
#define STR(x) #x
#define Active(scenarioKey, FxID) ((scenarioKey & (1 << FxID)) == (1 << FxID))
string getScenarioName(int scenario);
std::string getScenarioName(int scenario);
enum FXSwitch
{
@ -27,3 +32,22 @@ enum FXSwitch
class FXScenarioTest : public testing::TestWithParam<int>
{
};
void setupOuputStreamFocCSV(std::ostream& out);
class FxComponentFixture : public testing::Test
{
public:
FxComponentFixture();
virtual void SetUp() override;
virtual void TearDown() override;
std::string getResultFile(const string& filename);
float32_t getRandomValue();
random_device rd_;
mt19937 gen_;
uniform_real_distribution<float32_t> dist_;
};

Loading…
Cancel
Save