From 736a9d128b54926e074fbbbc8688225f53eb633a Mon Sep 17 00:00:00 2001 From: "lab34 (BiriukovaAlS)" Date: Mon, 22 May 2023 01:41:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BE=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=201=20=D0=B8=20=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 16 ++++++------ unittest.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 9f5e786..0b5bd0e 100644 --- a/main.cpp +++ b/main.cpp @@ -5,25 +5,26 @@ #include "text.h" #include "svg.h" - using namespace std; struct Input { vectornumbers; size_t kol_kor{}; + size_t number_count; }; Input input_data() { - size_t number_count; + Input in; + cerr<<"Marks: "; - cin>>number_count; + cin>>in.number_count; - Input in; - in.numbers.resize(number_count); - for (size_t i=0; inumbers{1,2,3,4,5}; @@ -16,3 +17,71 @@ TEST_CASE("distinct positive numbers") { CHECK(maxp == 5); CHECK(minp!=maxp); } + +TEST_CASE("distinct positive numbers") +{ + double minp = 0; + double maxp = 0; + std::vectornumbers{3,4,4,4,4}; + find_minmax(numbers, minp, maxp); + CHECK(minp == 1); + CHECK(maxp == 5); +} + +TEST_CASE("emptyA") +{ + std::vectornumbers{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(numbers, min, max); + CHECK(numbers.size() !=0 ); +} + +TEST_CASE("min") +{ + std::vectornumbers{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(numbers, min, max); + CHECK(min == 1); +} + +TEST_CASE("max") +{ + std::vectornumbers{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(numbers, min, max); + CHECK(max == 4); +} + + +TEST_CASE("1A") +{ + std::vectornumbers{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(numbers, min, max); + CHECK(numbers.size() !=1 ); +} + + +TEST_CASE("same") +{ + std::vectornumbers{1,1,1,1}; + std::vectorB{1,1,1,1}; + double min = 0; + double max = 0; + find_minmax(numbers, min, max); + CHECK(numbers == B); +} + +TEST_CASE("emt") +{ + std::vectornumbers{}; + double minp = 0; + double maxp = 0; + CHECK(find_minmax(numbers,minp,maxp)==false); +} + +