From 726a011b053396d2e656bf0394c45e138272aead Mon Sep 17 00:00:00 2001 From: "cs-lab34 (BushmanovAS)" Date: Tue, 7 May 2024 01:04:43 +0300 Subject: [PATCH] =?UTF-8?q?test:=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=BD=D0=BE=D0=B2=D1=8B=D1=85=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- histogram_internal.h | 2 +- unittest.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/histogram_internal.h b/histogram_internal.h index 34592d8..3a2e060 100644 --- a/histogram_internal.h +++ b/histogram_internal.h @@ -4,6 +4,6 @@ #include void -find_minmax(const std::vector& numbers, double& min, double& max) +find_minmax(const std::vector& numbers, double& min, double& max); #endif // HISTOGRAM_INTERNAL_H_INCLUDED diff --git a/unittest.cpp b/unittest.cpp index e69de29..1ee1609 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -0,0 +1,37 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include +#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("negative numbers") { + double min = 0; + double max = 0; + find_minmax({ -10, 10 }, min, max); + CHECK(min == -10); + CHECK(max == 10); +} + +TEST_CASE("empty numbers") { + double min = 0; + double max = 0; + find_minmax({ }, min, max); + CHECK(min != 0); + CHECK(max != 0); +} + +TEST_CASE("one number") { + double min = 0; + double max = 0; + find_minmax({ 2 }, min, max); + CHECK(min == 2); + CHECK(max == 2); +}