From 28bdec9c3a319c510ec916fa400cd8608accbc34 Mon Sep 17 00:00:00 2001 From: PodlovchenkoDD Date: Sun, 27 Apr 2025 20:52:36 +0300 Subject: [PATCH] =?UTF-8?q?4=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- histogram.cpp | 1 + unittest.cbp | 38 ++++++++++++++++++++++++++++++++++++++ unittest.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 unittest.cbp create mode 100644 unittest.cpp diff --git a/histogram.cpp b/histogram.cpp index 4920da2..a247501 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -1,6 +1,7 @@ #include #include #include "histogram.h" +#include "histogram_internal.h" using namespace std; void find_minmax(const vector& numbers, double& min, double& max) { diff --git a/unittest.cbp b/unittest.cbp new file mode 100644 index 0000000..7f9621b --- /dev/null +++ b/unittest.cbp @@ -0,0 +1,38 @@ + + + + + + diff --git a/unittest.cpp b/unittest.cpp new file mode 100644 index 0000000..fde8f10 --- /dev/null +++ b/unittest.cpp @@ -0,0 +1,29 @@ +#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("all negative numbers"){ + double min = 0; + double max = 0; + find_minmax({-1, -2}, min, max); + CHECK(min == -2); + CHECK(max == -1); +} + +TEST_CASE("vector of the same elements"){ + double min = 0; + double max = 0; + find_minmax({3,3,3}, min, max); + CHECK(min == 3); + CHECK(max == 3); + +}