From 3e0f5aa9a39eb2d5ec0d97187a31818feb021bf0 Mon Sep 17 00:00:00 2001 From: TarasovEE Date: Sun, 6 Jul 2025 15:00:51 +0300 Subject: [PATCH] =?UTF-8?q?unittest=5Fsource:=20=D1=84=D0=B0=D0=B9=D0=BB?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D0=B5=D1=81=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unittest.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 unittest.cpp diff --git a/unittest.cpp b/unittest.cpp new file mode 100644 index 0000000..6870059 --- /dev/null +++ b/unittest.cpp @@ -0,0 +1,48 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "histogram_internal.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("null vector") +{ + double min = 0; + double max = 0; + find_minmax({1, 2}, min, max); + CHECK(min == 1); + CHECK(max == 2); +} + +// одинаковые положительные элементы + +TEST_CASE("similar positive numbers") +{ + double min = 0; + double max = 0; + find_minmax({1,1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} + +// два разных отрицательных элемента + +TEST_CASE("distinct negative numbers") +{ + double min = 0; + double max = 0; + find_minmax({-2, -1}, min, max); + CHECK(min == -2); + CHECK(max == -1); +}