58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "common/ceMatchedFilterHandling.h"
|
|
#include "common/convertfp16tofloat.h"
|
|
#include "MatlabReader.h"
|
|
|
|
inline double fourDecimalRound(double src){
|
|
return round(src*10000.0)/10000.0;
|
|
}
|
|
|
|
#define EXPECT_DOUBLE_AE(valueA,valueB)\
|
|
EXPECT_DOUBLE_EQ(fourDecimalRound(valueA),fourDecimalRound(valueB))
|
|
|
|
class Common_Test : public ::testing::Test {
|
|
protected:
|
|
static void SetUpCommonTester() {
|
|
|
|
}
|
|
|
|
static void TearDownTestCase() {
|
|
}
|
|
|
|
void SetUp() {
|
|
}
|
|
|
|
void TearDown() {
|
|
}
|
|
};
|
|
|
|
TEST_F(Common_Test, adaptFrequency) {
|
|
// MatlabReader m("/home/krad/TestData/adaptFrequency.mat");
|
|
MatlabReader m("/home/sun/Aurora/build/a.mat");
|
|
|
|
auto mCe = m.read("input");
|
|
mCe = Recon::adaptFrequency(mCe,40000000.0,10000000.0);
|
|
EXPECT_EQ(4096,mCe.getDataSize());
|
|
auto output = m.read("output");
|
|
for (size_t i = 0; i < 4096; i++)
|
|
{
|
|
EXPECT_DOUBLE_AE(mCe.getData()[i],output.getData()[i])<<", index:"<<i;
|
|
}
|
|
|
|
}
|
|
|
|
TEST_F(Common_Test, convertfp16tofloat) {
|
|
MatlabReader m("/home/krad/TestData/convertReal.mat");
|
|
|
|
size_t count = 0;
|
|
auto input = m.readint16("input",count);
|
|
auto ma = Aurora::Matrix::copyFromRawData((double*)input.get(),count/4);
|
|
auto resultM = Recon::convertfp16tofloat(ma);
|
|
auto result = resultM.getData();
|
|
auto output = m.read("output");
|
|
for (size_t i = 0; i<count; i++) {
|
|
EXPECT_EQ(result[i], output.getData()[i])<<"index:"<<i<<",input:"<< ((short*)ma.getData())[i]<<",input2:"<<input.get()[i];
|
|
}
|
|
|
|
} |