2021-06-19 01:34:47 +00:00
|
|
|
#include "DataCarrierDetect.h"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
class DataCarrierDetectTest : public ::testing::Test {
|
|
|
|
protected:
|
|
|
|
void SetUp() override {}
|
|
|
|
|
|
|
|
// void TearDown() override {}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(DataCarrierDetectTest, construct)
|
|
|
|
{
|
2021-06-19 15:24:14 +00:00
|
|
|
auto dcd = mobilinkd::DataCarrierDetect<float, 48000, 1000>(2000, 4000, 1.0, 5.0);
|
2021-06-19 01:34:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DataCarrierDetectTest, dcd)
|
|
|
|
{
|
|
|
|
constexpr std::array<float, 24> input = {1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
|
|
|
|
|
2021-06-19 15:24:14 +00:00
|
|
|
auto dcd = mobilinkd::DataCarrierDetect<float, 48000, 1000>(2000,3000,1.0,5.0);
|
2021-06-19 01:34:47 +00:00
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
|
|
|
|
dcd.update();
|
|
|
|
|
|
|
|
EXPECT_TRUE(dcd.dcd());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DataCarrierDetectTest, dcd_off)
|
|
|
|
{
|
|
|
|
constexpr std::array<float, 16> input = {1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1};
|
|
|
|
|
2021-06-19 15:24:14 +00:00
|
|
|
auto dcd = mobilinkd::DataCarrierDetect<float, 48000, 1000>(2000,3000, 0.1, 1.0);
|
2021-06-19 01:34:47 +00:00
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
std::for_each(input.begin(), input.end(), [&dcd](float x){dcd(x);});
|
|
|
|
|
|
|
|
dcd.update();
|
|
|
|
|
|
|
|
EXPECT_FALSE(dcd.dcd());
|
|
|
|
}
|