Пункт 4: Модульные тесты

main
Александр Чирка 4 недель назад
Родитель 8fb31a89d6
Сommit 52e6758f27

@ -3,7 +3,7 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
static void find_minmax(const vector<double>& numbers, double& minN, double& maxN) void find_minmax(const vector<double>& numbers, double& minN, double& maxN)
{ {
minN = numbers[0]; minN = numbers[0];
maxN = numbers[0]; maxN = numbers[0];

@ -0,0 +1,9 @@
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
#define HISTOGRAM_INTERNAL_H_INCLUDED
#include <vector>
std::vector<size_t>
find_minmax( const std::vector<double>& numbers, double& minN, double& maxN);
#endif // HISTOGRAM_INTERNAL_H_INCLUDED

@ -0,0 +1,29 @@
#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);
}
*/
TEST_CASE("distinct negative numbers")
{
double min = 0;
double max = 0;
find_minmax({-1, -2}, min, max);
CHECK(min == -2);
CHECK(max == -1);
}
TEST_CASE("vector 1 element")
{
double min = 0;
double max = 0;
find_minmax({1}, min, max);
CHECK(min == 1);
CHECK(max == 1);
}
Загрузка…
Отмена
Сохранить