From 8c9fba0c3987bba28cdebf416e0f754bd4a4193b Mon Sep 17 00:00:00 2001 From: MamakinYR Date: Mon, 22 Apr 2024 16:27:06 +0300 Subject: [PATCH] code:void to bool --- histogram.cpp | 4 +++- histogram_internal.h | 2 +- unittest.cpp | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/histogram.cpp b/histogram.cpp index cd7d886..2df2fdd 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -4,7 +4,7 @@ #include "histogram.h" using namespace std; -void find_minmax(const vector& numbers, double& min, double& max) { +bool find_minmax(const vector& numbers, double& min, double& max) { if (numbers.size() != 0) { min = numbers[0]; @@ -20,7 +20,9 @@ void find_minmax(const vector& numbers, double& min, double& max) { max = x; } } + return true; } + return false; } void find_max_capacity(const vector& bins, size_t& max_bin_capacity) diff --git a/histogram_internal.h b/histogram_internal.h index 3fb3176..1afbd13 100644 --- a/histogram_internal.h +++ b/histogram_internal.h @@ -1,4 +1,4 @@ #pragma once #include -void find_minmax(const std::vector& numbers, double& min, double& max); \ No newline at end of file +bool find_minmax(const std::vector& numbers, double& min, double& max); \ No newline at end of file diff --git a/unittest.cpp b/unittest.cpp index 8c4e254..de25e8b 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -15,9 +15,8 @@ TEST_CASE("distinct positive numbers") { TEST_CASE("empty vector") { double min = 0; double max = 0; - find_minmax({}, min, max); - CHECK(min == 0); - CHECK(max == 0); + bool flag; + flag = find_minmax({}, min, max); } TEST_CASE("negative values") {