code:итог ЛР№3
Этот коммит содержится в:
@@ -1,8 +1,9 @@
|
||||
#include "histogram.hpp"
|
||||
#include <vector>
|
||||
|
||||
void find_minmax(std::vector<double> &numbers, double& min, double& max)
|
||||
bool find_minmax(std::vector<double> &numbers, double& min, double& max)
|
||||
{
|
||||
if (numbers.empty()) return false;
|
||||
min = numbers[0]; max = numbers[0];
|
||||
for (double x : numbers)
|
||||
{
|
||||
@@ -11,6 +12,7 @@ void find_minmax(std::vector<double> &numbers, double& min, double& max)
|
||||
if (min > x)
|
||||
min = x;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<size_t> make_histogram(std::vector<double> numbers, size_t bin_count)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
||||
Двоичные данные
lab_3.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate
сгенерированный
Двоичные данные
lab_3.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate
сгенерированный
Двоичный файл не отображается.
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildLocationStyle</key>
|
||||
<string>UseAppPreferences</string>
|
||||
<key>CustomBuildLocationType</key>
|
||||
<string>RelativeToDerivedData</string>
|
||||
<key>DerivedDataLocationStyle</key>
|
||||
<string>Default</string>
|
||||
<key>ShowSharedSchemesAutomaticallyEnabled</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
78
lab_3.xcodeproj/xcshareddata/xcschemes/lab_3.xcscheme
Обычный файл
78
lab_3.xcodeproj/xcshareddata/xcschemes/lab_3.xcscheme
Обычный файл
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "35EA3A932A2D54F400ED69F1"
|
||||
BuildableName = "lab_3"
|
||||
BlueprintName = "lab_3"
|
||||
ReferencedContainer = "container:lab_3.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
viewDebuggingEnabled = "No">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "35EA3A932A2D54F400ED69F1"
|
||||
BuildableName = "lab_3"
|
||||
BlueprintName = "lab_3"
|
||||
ReferencedContainer = "container:lab_3.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "35EA3A932A2D54F400ED69F1"
|
||||
BuildableName = "lab_3"
|
||||
BlueprintName = "lab_3"
|
||||
ReferencedContainer = "container:lab_3.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -10,5 +10,13 @@
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>35EA3A932A2D54F400ED69F1</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
5
main.cpp
5
main.cpp
@@ -16,15 +16,16 @@ struct Input
|
||||
Input input_data()
|
||||
{
|
||||
size_t number_count;
|
||||
cout << "Enter number count: ";
|
||||
cerr << "Enter number count: ";
|
||||
cin >> number_count; // Кол-во чисел
|
||||
Input in;
|
||||
in.numbers.resize(number_count);
|
||||
for (size_t i = 0; i < number_count; i++)
|
||||
{
|
||||
cerr << "Enter number №" << i+1 << ": ";
|
||||
cin >> in.numbers[i];
|
||||
}
|
||||
cout << "Enter bin count: ";
|
||||
cerr << "Enter bin count: ";
|
||||
cin >> in.bin_count;
|
||||
return in;
|
||||
}
|
||||
|
||||
8
svg.cpp
8
svg.cpp
@@ -29,9 +29,9 @@ svg_text(double left, double baseline, string text)
|
||||
}
|
||||
|
||||
void
|
||||
svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black")
|
||||
svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black", string fill_opacity = "1.0")
|
||||
{
|
||||
cout << "<rect x='"<<x<<"' y='"<<y<<"' width='"<<width<<"' height='"<<height<<"' stroke='"<<stroke<<"' fill='"<<fill<<"'";
|
||||
cout << "<rect x='"<<x<<"' y='"<<y<<"' width='"<<width<<"' height='"<<height<<"' stroke='"<<stroke<<"' fill='"<<fill<<"'" << " fill-opacity ='" << fill_opacity << "'" << " /> ";
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,8 @@ show_histogram_svg(const vector<size_t>& bins)
|
||||
{
|
||||
double bin_width = (MAX_WIDTH)*(bins[i]/max_count);
|
||||
double opacity = (bins[i]/max_count);
|
||||
string fill_opacity = to_string(opacity);
|
||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]));
|
||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, BOARD_COLOR, FILL_COLOR);
|
||||
cout << " fill-opacity ='" << fill_opacity << "'" << " /> ";
|
||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, BOARD_COLOR, FILL_COLOR, to_string(opacity));
|
||||
top += BIN_HEIGHT;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
void find_minmax(std::vector<double> &numbers, double& min, double& max)
|
||||
bool find_minmax(std::vector<double> &numbers, double& min, double& max)
|
||||
{
|
||||
if (numbers.empty()) return false;
|
||||
min = numbers[0]; max = numbers[0];
|
||||
for (double x : numbers)
|
||||
{
|
||||
@@ -11,4 +12,5 @@ void find_minmax(std::vector<double> &numbers, double& min, double& max)
|
||||
if (min > x)
|
||||
min = x;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "histogram_internal.hpp"
|
||||
#include <vector>
|
||||
|
||||
TEST_CASE("distinct positive numbers") {
|
||||
TEST_CASE("test_negative_numbers") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
std::vector<double> numbers3 = {-5, -3, -4, -1, -2};
|
||||
@@ -11,8 +11,15 @@ TEST_CASE("distinct positive numbers") {
|
||||
CHECK(min == -5);
|
||||
CHECK(max == -1);
|
||||
}
|
||||
|
||||
TEST_CASE("vector with same elements") {
|
||||
TEST_CASE("test_ positive_numbers") { //тест не должен быть удачным
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
std::vector<double> numbers3 = {1,2,3,4,0};
|
||||
find_minmax(numbers3, min, max);
|
||||
CHECK(min == 1); //min должен быть равен 0
|
||||
CHECK(max == 4);
|
||||
}
|
||||
TEST_CASE("test_same_elements") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
std::vector<double> numbers3 = {2,2,2};
|
||||
@@ -20,7 +27,7 @@ TEST_CASE("vector with same elements") {
|
||||
CHECK(min == 2);
|
||||
CHECK(max == 2);
|
||||
}
|
||||
TEST_CASE("distinct positive numbers 2") {
|
||||
TEST_CASE("test_one_element") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
std::vector<double> numbers3 = {-4};
|
||||
@@ -28,3 +35,9 @@ TEST_CASE("distinct positive numbers 2") {
|
||||
CHECK(min == -4);
|
||||
CHECK(max == -4);
|
||||
}
|
||||
TEST_CASE("test_no_element") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
std::vector<double> numbers3 = {};
|
||||
CHECK(find_minmax(numbers3, min, max) == false);
|
||||
}
|
||||
|
||||
Двоичные данные
unittest/unittest.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate
сгенерированный
Двоичные данные
unittest/unittest.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate
сгенерированный
Двоичный файл не отображается.
Ссылка в новой задаче
Block a user