Skip to content
Snippets Groups Projects
Commit 2265e4e1 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix file tests

parent 0b8bb895
No related branches found
No related tags found
No related merge requests found
Pipeline #29167 failed
#include "catch.hpp" #include "catch.hpp"
#include <ftl/calibration/parameters.hpp> #include <ftl/calibration/parameters.hpp>
#include <ftl/calibration/structures.hpp> #include <ftl/calibration/structures.hpp>
#include <ftl/file.hpp>
using cv::Size; using cv::Size;
using cv::Mat; using cv::Mat;
...@@ -55,15 +56,15 @@ TEST_CASE("Test reading/writing file") { ...@@ -55,15 +56,15 @@ TEST_CASE("Test reading/writing file") {
calib.intrinsic.cy = 0.5; calib.intrinsic.cy = 0.5;
data.get(Channel::Left) = calib; data.get(Channel::Left) = calib;
data.writeFile("/tmp/calib.yml"); data.writeFile((std::filesystem::temp_directory_path() / "calib.yml").string());
calib_read = CalibrationData::readFile("/tmp/calib.yml"); calib_read = CalibrationData::readFile((std::filesystem::temp_directory_path() / "calib.yml").string());
REQUIRE(calib_read.hasCalibration(Channel::Left)); REQUIRE(calib_read.hasCalibration(Channel::Left));
data.writeFile("/tmp/calib.json"); data.writeFile((std::filesystem::temp_directory_path() / "calib.json").string());
calib_read = CalibrationData::readFile("/tmp/calib.json"); calib_read = CalibrationData::readFile((std::filesystem::temp_directory_path() / "calib.json").string());
REQUIRE(calib_read.hasCalibration(Channel::Left)); REQUIRE(calib_read.hasCalibration(Channel::Left));
data.writeFile("/tmp/calib.xml"); data.writeFile((std::filesystem::temp_directory_path() / "calib.xml").string());
calib_read = CalibrationData::readFile("/tmp/calib.xml"); calib_read = CalibrationData::readFile((std::filesystem::temp_directory_path() / "calib.xml").string());
REQUIRE(calib_read.hasCalibration(Channel::Left)); REQUIRE(calib_read.hasCalibration(Channel::Left));
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <ftl/streams/filestream.hpp> #include <ftl/streams/filestream.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <ftl/timer.hpp> #include <ftl/timer.hpp>
#include <ftl/file.hpp>
using ftl::stream::File; using ftl::stream::File;
using ftl::stream::Stream; using ftl::stream::Stream;
...@@ -25,7 +26,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { ...@@ -25,7 +26,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") {
REQUIRE(writer); REQUIRE(writer);
SECTION("write read single packet") { SECTION("write read single packet") {
writer->set("filename", "/tmp/ftl_file_stream_test.ftl"); writer->set("filename", (std::filesystem::temp_directory_path() / "ftl_file_stream_test.ftl").string());
writer->setMode(File::Mode::Write); writer->setMode(File::Mode::Write);
REQUIRE( writer->begin() ); REQUIRE( writer->begin() );
...@@ -34,7 +35,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { ...@@ -34,7 +35,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") {
writer->end(); writer->end();
reader->set("filename", "/tmp/ftl_file_stream_test.ftl"); reader->set("filename", (std::filesystem::temp_directory_path() / "ftl_file_stream_test.ftl").string());
ftl::codecs::StreamPacket tspkt = {4,0,0,1,ftl::codecs::Channel::Colour}; ftl::codecs::StreamPacket tspkt = {4,0,0,1,ftl::codecs::Channel::Colour};
auto h = reader->onPacket([&tspkt](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { auto h = reader->onPacket([&tspkt](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
...@@ -52,7 +53,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { ...@@ -52,7 +53,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") {
} }
SECTION("write read multiple packets at same timestamp") { SECTION("write read multiple packets at same timestamp") {
writer->set("filename", "/tmp/ftl_file_stream_test.ftl"); writer->set("filename", (std::filesystem::temp_directory_path() / "ftl_file_stream_test.ftl").string());
writer->setMode(File::Mode::Write); writer->setMode(File::Mode::Write);
REQUIRE( writer->begin() ); REQUIRE( writer->begin() );
...@@ -63,7 +64,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { ...@@ -63,7 +64,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") {
writer->end(); writer->end();
reader->set("filename", "/tmp/ftl_file_stream_test.ftl"); reader->set("filename", (std::filesystem::temp_directory_path() / "ftl_file_stream_test.ftl").string());
ftl::codecs::StreamPacket tspkt = {4,0,0,1,ftl::codecs::Channel::Colour}; ftl::codecs::StreamPacket tspkt = {4,0,0,1,ftl::codecs::Channel::Colour};
int count = 0; int count = 0;
...@@ -84,7 +85,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { ...@@ -84,7 +85,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") {
} }
SECTION("write read multiple packets at different timestamps") { SECTION("write read multiple packets at different timestamps") {
writer->set("filename", "/tmp/ftl_file_stream_test.ftl"); writer->set("filename", (std::filesystem::temp_directory_path() / "ftl_file_stream_test.ftl").string());
writer->setMode(File::Mode::Write); writer->setMode(File::Mode::Write);
REQUIRE( writer->begin() ); REQUIRE( writer->begin() );
...@@ -96,7 +97,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { ...@@ -96,7 +97,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") {
writer->end(); writer->end();
reader->set("filename", "/tmp/ftl_file_stream_test.ftl"); reader->set("filename", (std::filesystem::temp_directory_path() / "ftl_file_stream_test.ftl").string());
ftl::codecs::StreamPacket tspkt = {4,0,0,1,ftl::codecs::Channel::Colour}; ftl::codecs::StreamPacket tspkt = {4,0,0,1,ftl::codecs::Channel::Colour};
int count = 0; int count = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment