Этот коммит содержится в:
Alexey (MinovAS)
2023-06-07 12:18:26 +03:00
родитель df5e1b8914
Коммит 996458039d
11 изменённых файлов: 134 добавлений и 13 удалений

Просмотреть файл

@@ -1,8 +1,9 @@
#include <iostream>
#include <vector>
void find_minmax(std::vector<double> &numbers, double& min, double& max)
bool find_minmax(std::vector<double> &numbers, double& min, double& max)
{
if (numbers.empty()) return false;
min = numbers[0]; max = numbers[0];
for (double x : numbers)
{
@@ -11,4 +12,5 @@ void find_minmax(std::vector<double> &numbers, double& min, double& max)
if (min > x)
min = x;
}
return true;
}

Просмотреть файл

@@ -3,7 +3,7 @@
#include "histogram_internal.hpp"
#include <vector>
TEST_CASE("distinct positive numbers") {
TEST_CASE("test_negative_numbers") {
double min = 0;
double max = 0;
std::vector<double> numbers3 = {-5, -3, -4, -1, -2};
@@ -11,8 +11,15 @@ TEST_CASE("distinct positive numbers") {
CHECK(min == -5);
CHECK(max == -1);
}
TEST_CASE("vector with same elements") {
TEST_CASE("test_ positive_numbers") { //тест не должен быть удачным
double min = 0;
double max = 0;
std::vector<double> numbers3 = {1,2,3,4,0};
find_minmax(numbers3, min, max);
CHECK(min == 1); //min должен быть равен 0
CHECK(max == 4);
}
TEST_CASE("test_same_elements") {
double min = 0;
double max = 0;
std::vector<double> numbers3 = {2,2,2};
@@ -20,7 +27,7 @@ TEST_CASE("vector with same elements") {
CHECK(min == 2);
CHECK(max == 2);
}
TEST_CASE("distinct positive numbers 2") {
TEST_CASE("test_one_element") {
double min = 0;
double max = 0;
std::vector<double> numbers3 = {-4};
@@ -28,3 +35,9 @@ TEST_CASE("distinct positive numbers 2") {
CHECK(min == -4);
CHECK(max == -4);
}
TEST_CASE("test_no_element") {
double min = 0;
double max = 0;
std::vector<double> numbers3 = {};
CHECK(find_minmax(numbers3, min, max) == false);
}

Двоичный файл не отображается.