From 1f06f03e9cf619e9feb36a16e22f9110aceb67f4 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Wed, 10 Dec 2025 18:38:07 -0600 Subject: [PATCH] Adding unit tests for image magic durations --- tests/ImageReader.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/ImageReader.cpp diff --git a/tests/ImageReader.cpp b/tests/ImageReader.cpp new file mode 100644 index 00000000..9183e7cf --- /dev/null +++ b/tests/ImageReader.cpp @@ -0,0 +1,36 @@ +/** + * @file + * @brief Unit tests for openshot::ImageReader + * @author Jonathan Thomas + * + * @ref License + */ + +// Copyright (c) 2008-2025 OpenShot Studios, LLC +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#include "openshot_catch.h" + +#include "ImageReader.h" +#include "Exceptions.h" +#include "Frame.h" + +using namespace openshot; + +TEST_CASE( "Duration_And_Length_ImageReader", "[libopenshot][imagereader]" ) +{ + // Create a reader + std::stringstream path; + path << TEST_MEDIA_PATH << "front.png"; + ImageReader r(path.str()); + r.Open(); + + // Duration and frame count should be aligned to fps (1 hour at 30 fps) + CHECK(r.info.fps.num == 30); + CHECK(r.info.fps.den == 1); + CHECK(r.info.video_length == 108000); + CHECK(r.info.duration == Approx(3600.0f).margin(0.001f)); + + r.Close(); +}