From fe40eae74cf2490582d844159e7736492536ca20 Mon Sep 17 00:00:00 2001 From: ChernyukVS Date: Tue, 16 Sep 2025 17:57:51 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D0=BB(=D0=B0)=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unittest.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 unittest.cpp diff --git a/unittest.cpp b/unittest.cpp new file mode 100644 index 0000000..6111101 --- /dev/null +++ b/unittest.cpp @@ -0,0 +1,54 @@ +#include "histogram_internal.h" +#include +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + + +TEST_CASE("distinct positive numbers") { + double min = 0; + double max = 0; + find_minmax({1, 2}, min, max); + CHECK(min == 1); + CHECK(max == 2); +} + +TEST_CASE("distinct negative numbers") +{ + double min = 0; + double max = 0; + find_minmax({-1, -2}, min, max); + CHECK(min == -2); + CHECK(max == -1); +} +TEST_CASE("vector 1 element") +{ + double min = 0; + double max = 0; + find_minmax({1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} +TEST_CASE("distinct equals numbers") +{ + double min = 0; + double max = 0; + find_minmax({1, 1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} +TEST_CASE("distinct equals numbers") { + double min = 0; + double max = 0; + find_minmax({1, 1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} + +TEST_CASE("empty vector") { + double min = -1; + double max = -1; + find_minmax({}, min, max); + // Проверяем, что min и max не изменились (или изменились в ожидаемый способ) + CHECK(min == -1); + CHECK(max == -1); +}