From d0a42c431495031d7e51dd2eaf093675395a8206 Mon Sep 17 00:00:00 2001 From: LedovskojMM Date: Sun, 23 Apr 2023 22:12:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BC=D0=B0=20=D0=B4=D0=BE=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82?= =?UTF-8?q?=D0=B0=206=20(=D1=82=D0=B5=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- histogam.cpp | 3 ++- histogam.h | 1 - histogam_internal.h | 7 +++++ lab1.depend | 7 ++--- unittest.cbp | 38 +++++++++++++++++++++++++++ unittest.cpp | 17 ++++++++++++ unittest.depend | 64 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 histogam_internal.h create mode 100644 unittest.cbp create mode 100644 unittest.cpp create mode 100644 unittest.depend diff --git a/histogam.cpp b/histogam.cpp index e3fc6aa..25ee82b 100644 --- a/histogam.cpp +++ b/histogam.cpp @@ -2,9 +2,10 @@ #include #include #include "histogam.h" +#include "histogam_internal.h" using namespace std; -static find_minmax(vector numbers, double& min, double& max) { +void find_minmax(vector numbers, double& min, double& max) { min = numbers[0]; for (auto i = 0; i < numbers.size(); i++) { if (numbers[i] < min) { diff --git a/histogam.h b/histogam.h index 994a9c4..af2d8ad 100644 --- a/histogam.h +++ b/histogam.h @@ -2,7 +2,6 @@ #define HISTOGAM_H_INCLUDED #include - std::vector make_histogram(const std::vector& numbers, size_t bin_count); diff --git a/histogam_internal.h b/histogam_internal.h new file mode 100644 index 0000000..58eecb6 --- /dev/null +++ b/histogam_internal.h @@ -0,0 +1,7 @@ +#ifndef HISTOGAM_INTERNAL_H_INCLUDED +#define HISTOGAM_INTERNAL_H_INCLUDED + +#include +void find_minmax(std::vector numbers, double& min, double& max); + +#endif // HISTOGAM_INTERNAL_H_INCLUDED diff --git a/lab1.depend b/lab1.depend index fdaeffe..5f3bc1d 100644 --- a/lab1.depend +++ b/lab1.depend @@ -3,16 +3,17 @@ -1682272330 source:c:\users\admin\onedrive\Рабочий стол\lab1\main.cpp +1682273505 source:c:\users\admin\onedrive\Рабочий стол\lab1\main.cpp "histogam.h" + "text.h" -1682271932 c:\users\admin\onedrive\Рабочий стол\lab1\histogam.h +1682273839 c:\users\admin\onedrive\Рабочий стол\lab1\histogam.h -1682272812 source:c:\users\admin\onedrive\Рабочий стол\lab1\histogam.cpp +1682273664 source:c:\users\admin\onedrive\Рабочий стол\lab1\histogam.cpp 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..87d0670 --- /dev/null +++ b/unittest.cpp @@ -0,0 +1,17 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "histogam_internal.h" +#include + +TEST_CASE("distinct positive numbers") { + double min = 0; + double max = 0; + std::vectorf{1,2}; + CHECK(f.size() != 0); + CHECK(f.size() != 1); + find_minmax(f, min, max); + CHECK(min == 1); + CHECK(max == 2); + CHECK(min != max); +} diff --git a/unittest.depend b/unittest.depend new file mode 100644 index 0000000..5760bab --- /dev/null +++ b/unittest.depend @@ -0,0 +1,64 @@ +# depslib dependency file v1.0 +1682273864 source:c:\users\admin\onedrive\Рабочий стол\lab1\histogam.cpp + + + + "histogam.h" + "histogam_internal.h" + +1682273839 c:\users\admin\onedrive\Рабочий стол\lab1\histogam.h + + +1682273796 c:\users\admin\onedrive\Рабочий стол\lab1\histogam_internal.h + + +1682276727 source:c:\users\admin\onedrive\Рабочий стол\lab1\unittest.cpp + "doctest.h" + "histogam_internal.h" + + +1682274769 c:\users\admin\onedrive\Рабочий стол\lab1\doctest.h + + + + + + + "doctest_fwd.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +