From a2c5b1f28475365c8a880819df428dc83ddc2585 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Tue, 8 Oct 2024 12:37:55 +0300 Subject: [PATCH] tests file for Range.hpp --- tests/Math/Range.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/Math/Range.cpp diff --git a/tests/Math/Range.cpp b/tests/Math/Range.cpp new file mode 100644 index 0000000..799022b --- /dev/null +++ b/tests/Math/Range.cpp @@ -0,0 +1,57 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#include + +#include "Math/Range.hpp" + +using namespace OpenVulkano::Math; +using RangeType = Range; + +// The class does not have a default constructor... So rely on warnings about unitialized members + +TEST_CASE("Parameterized constructor", "[Range]") +{ + int min = 10; + int max = 20; + RangeType range(min, max); + REQUIRE(range.GetMin() == min); + REQUIRE(range.GetMax() == max); +} + +TEST_CASE("GetMin and GetMax", "[Range]") +{ + int min = 10; + int max = 20; + RangeType range(min, max); + + // Test const-qualified access + const RangeType& constRange = range; + REQUIRE(constRange.GetMin() == min); + REQUIRE(constRange.GetMax() == max); + + // Test non-const access + range.GetMin() = 30; + range.GetMax() = 40; + REQUIRE(range.GetMin() == 30); + REQUIRE(range.GetMax() == 40); +} + +TEST_CASE("GetSize", "[Range]") +{ + int min = 10; + int max = 20; + RangeType range(min, max); + REQUIRE(range.GetSize() == 10); +} + +TEST_CASE("GetSize with negative", "[Range]") +{ + int min = -10; + int max = 10; + RangeType range(min, max); + REQUIRE(range.GetSize() == 20); +} \ No newline at end of file