testing: Добавлены случаи

master
MamakinYR 1 год назад
Родитель 4248e1661a
Сommit 38a8c90e0d

@ -5,6 +5,8 @@
using namespace std; using namespace std;
void find_minmax(const vector<double>& numbers, double& min, double& max) { void find_minmax(const vector<double>& numbers, double& min, double& max) {
if (numbers.size() == 2)
{
min = numbers[0]; min = numbers[0];
max = numbers[0]; max = numbers[0];
for (double x : numbers) for (double x : numbers)
@ -19,6 +21,7 @@ void find_minmax(const vector<double>& numbers, double& min, double& max) {
} }
} }
} }
}
vector<size_t> make_histogram(const vector<double>& numbers, size_t bin_count) vector<size_t> make_histogram(const vector<double>& numbers, size_t bin_count)
{ {

@ -0,0 +1,27 @@
#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("empty vector") {
double min = 0;
double max = 0;
find_minmax({}, min, max);
CHECK(min == 0);
CHECK(max == 0);
}
TEST_CASE("negative values") {
double min = 0;
double max = 0;
find_minmax({-2, -4}, min, max);
CHECK(min == -4);
CHECK(max == -2);
}

@ -17,7 +17,6 @@
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion> <VCProjectVersion>17.0</VCProjectVersion>
@ -53,7 +52,6 @@
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
@ -71,9 +69,7 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
@ -130,8 +126,14 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup>
<ItemGroup></ItemGroup> <ClCompile Include="histogram.cpp" />
<ClCompile Include="unittest.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="doctest.h" />
<ClInclude Include="histogram_internal.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

Загрузка…
Отмена
Сохранить