Tests: add test function to write to file stream

This commit is contained in:
wmayer
2024-03-10 08:49:15 +01:00
committed by wwmayer
parent 7b7a806bdf
commit d3e790cf21

View File

@@ -3,6 +3,7 @@
#include "InitApplication.h"
#include <App/ProjectFile.h>
#include <App/InventorObject.h>
#include <Base/Stream.h>
#include <Base/Type.h>
// NOLINTBEGIN
@@ -23,6 +24,10 @@ protected:
resDir.append("/tests/ProjectTest.FCStd");
return resDir;
}
std::string imageFileName() const
{
return {"thumbnails/Thumbnail.png"};
}
std::list<std::string> getInventorObjects() const
{
return {"Body"};
@@ -103,4 +108,25 @@ TEST_F(ProjectFileTest, getTypeId)
Base::Type id = proj.getTypeId("Body");
EXPECT_EQ(id, getInventorId());
}
TEST_F(ProjectFileTest, getThumbnailBuffer)
{
App::ProjectFile proj(fileName());
std::stringstream str;
proj.readInputFileDirect(imageFileName(), str);
std::string buffer = str.str();
EXPECT_EQ(buffer.size(), 2857);
}
TEST_F(ProjectFileTest, getThumbnailFile)
{
App::ProjectFile proj(fileName());
Base::FileInfo fi(Base::FileInfo::getTempFileName());
Base::ofstream file(fi, std::ios::out | std::ios::binary);
proj.readInputFileDirect(imageFileName(), file);
file.flush();
file.close();
EXPECT_EQ(fi.size(), 2857);
fi.deleteFile();
}
// NOLINTEND