Родитель
0f0f6b3f84
Сommit
5ce5f598fb
@ -0,0 +1,7 @@
|
||||
//
|
||||
// Untitled.hpp
|
||||
// Gistogramma
|
||||
//
|
||||
// Created by MacBook Pro on 01.05.2025.
|
||||
//
|
||||
|
@ -0,0 +1,7 @@
|
||||
#ifndef histogram_internal_h
|
||||
#define histogram_internal_h
|
||||
#include <vector>
|
||||
|
||||
void find_minmax(const std::vector<double>& numbers, double& minimum, double& maximum);
|
||||
|
||||
#endif /* histogram_internal_h */
|
@ -0,0 +1,50 @@
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
#include "histogram_internal.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
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("empty vector"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
vector<double> empty(3);
|
||||
find_minmax(empty, min, max);
|
||||
CHECK(min == 0);
|
||||
CHECK(max == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("single vector"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
vector<double> single = {3};
|
||||
find_minmax(single, min, max);
|
||||
CHECK(min == 3);
|
||||
CHECK(max == 3);
|
||||
}
|
||||
|
||||
TEST_CASE("negative vector"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
vector<double> negative = {-1, -2};
|
||||
find_minmax(negative, min, max);
|
||||
CHECK(min == -2);
|
||||
CHECK(max == -1);
|
||||
}
|
||||
|
||||
TEST_CASE("identical vector"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
vector<double> identical = {1, 1};
|
||||
find_minmax(identical, min, max);
|
||||
CHECK(min == 1);
|
||||
CHECK(max == 1);
|
||||
}
|
Загрузка…
Ссылка в новой задаче