MachulinaDV 2 лет назад
Родитель 2be18e6286
Сommit 70408b5c7d

@ -0,0 +1,7 @@
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
#define HISTOGRAM_INTERNAL_H_INCLUDED
#include <vector>
bool find_minmax(const std::vector<double>& A, double& min, double& max);
#endif // HISTOGRAM_INTERNAL_H_INCLUDED

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="unittest" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/unittest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/unittest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="doctest.h" />
<Unit filename="histogram.cpp" />
<Unit filename="histogram_internal.h" />
<Unit filename="unittest.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>

@ -0,0 +1,56 @@
#define DOCTEST_CONFIG_NO_MULTITHREADING
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "histogram_internal.h"
TEST_CASE("emptyA") {
std::vector<double>A{1,2,3,4};
double min = 0;
double max = 0;
find_minmax(A, min, max);
CHECK(A.size() !=0 );
}
TEST_CASE("min")
{
std::vector<double>A{1,2,3,4};
double min = 0;
double max = 0;
find_minmax(A, min, max);
CHECK(min == 1);
}
TEST_CASE("max")
{
std::vector<double>A{1,2,3,4};
double min = 0;
double max = 0;
find_minmax(A, min, max);
CHECK(max == 4);
}
TEST_CASE("1A") {
std::vector<double>A{1,2,3,4};
double min = 0;
double max = 0;
find_minmax(A, min, max);
CHECK(A.size() !=1 );
}
TEST_CASE("same"){
std::vector<double>A{1,1,1,1};
std::vector<double>B{1,1,1,1};
double min = 0;
double max = 0;
find_minmax(A, min, max);
CHECK(A == B);
}
TEST_CASE("emt"){
std::vector<double>A{};
double min = 0;
double max = 0;
CHECK(find_minmax(A,min,max)==false);
}
Загрузка…
Отмена
Сохранить