80 lines
1.4 KiB
C++
80 lines
1.4 KiB
C++
#include "gtest/gtest.h"
|
|
|
|
#include "RawFileStream.h"
|
|
|
|
template <class T>
|
|
T Add(T a, T b)
|
|
{
|
|
return a + b;
|
|
}
|
|
|
|
TEST(FuntionTest, addFunction)
|
|
{
|
|
EXPECT_EQ(Add(2, 3), 5);
|
|
EXPECT_EQ(Add(2.5, 3.0), 5.5);
|
|
EXPECT_EQ(Add(3, 3), 6);
|
|
}
|
|
|
|
|
|
class RawFileStreamTest : public testing::Test
|
|
{
|
|
protected:
|
|
void SetUp()override
|
|
{
|
|
std::string path = "E:/workspace/1280_1024_X16_10.raw";
|
|
RawFileTools::GFrameFormat format;
|
|
format.nImageWidth = 1280;
|
|
format.nImageHeight = 1024;
|
|
format.nParamLineCount = 0;
|
|
format.nParamStartLine = 0;
|
|
format.nFrameRate = 25;
|
|
format.dBytesOfPixel = 2;
|
|
format.ePT = RawFileTools::ePixelType::ePT_Y16;
|
|
Stream = new RawFileTools::GuideRawFileStream(path, format);
|
|
};
|
|
|
|
void TearDown()override
|
|
{
|
|
delete Stream;
|
|
}
|
|
|
|
RawFileTools::GuideRawFileStream* Stream;
|
|
};
|
|
|
|
TEST_F(RawFileStreamTest, getTotalFrameCount)
|
|
{
|
|
if(Stream->isReadReady())
|
|
{
|
|
EXPECT_FALSE(Stream->isReadReady())<<"第二次调用";
|
|
auto it =Stream->begin();
|
|
EXPECT_GE(Stream->getTotalFrameCount(),0);
|
|
ASSERT_EQ(Stream->getErrorCode(),0);
|
|
ASSERT_EQ(it.getCurrentFrameCount(), 0);
|
|
static int index=0;
|
|
for (; it != Stream->end(); ++it)
|
|
{
|
|
index++;
|
|
it.getImageData();
|
|
}
|
|
|
|
//EXPECT_GE(it->getCurrentFrameCount(), it->getTotalFrameCount()-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
#include<Windows.h>
|
|
#endif // _WIN32
|
|
|
|
int main(int argc,char** argv)
|
|
{
|
|
testing::InitGoogleTest(&argc, argv);
|
|
#ifdef _WIN32
|
|
SetConsoleOutputCP(CP_UTF8);
|
|
#endif // _WIN32
|
|
return RUN_ALL_TESTS();
|
|
} |