Родитель
6e9a629025
Сommit
f73a7a6228
@ -0,0 +1,23 @@
|
||||
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
|
||||
void
|
||||
find_minmax(const std::vector<double>& numbers, double& Min, double& Max) {
|
||||
Min = numbers[0];
|
||||
Max = numbers[0];
|
||||
for(size_t x : numbers)
|
||||
{
|
||||
if(x < Min)
|
||||
{
|
||||
Min = x;
|
||||
}else
|
||||
{
|
||||
if(x > Max)
|
||||
{
|
||||
Max = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
@ -0,0 +1,12 @@
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
#include "histogram_internal.h"
|
||||
|
||||
TEST_CASE("distinct positive numbers") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({1, 2}, min, max);
|
||||
CHECK(min == 1);
|
||||
CHECK(max == 2);
|
||||
}
|
Загрузка…
Ссылка в новой задаче