From af84aa5e46203eb1d21959dfc9690b4d8aebad8f Mon Sep 17 00:00:00 2001 From: "Ivan (BeloziorovIA)" Date: Mon, 5 May 2025 03:48:32 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B5=D1=89=D1=91=204=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2=20=D0=B2=20unittest.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unittest.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/unittest.cpp b/unittest.cpp index a9ba7e5..1f47d26 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -10,3 +10,35 @@ TEST_CASE("distinct positive numbers") { CHECK(min == 1); CHECK(max == 2); } + +TEST_CASE("empty array") { + double min = 0; + double max = 0; + find_minmax({}, min, max); + CHECK(min == 0); + CHECK(max == 0); +} + +TEST_CASE("array with a single element") { + double min = 0; + double max = 0; + find_minmax({1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} + +TEST_CASE("array of negative elements") { + double min = 0; + double max = 0; + find_minmax({-1, -2}, min, max); + CHECK(min == -2); + CHECK(max == -1); +} + +TEST_CASE("array of identical elements") { + double min = 0; + double max = 0; + find_minmax({1, 1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +}