code: заготовка для лабораторной работы №4
Этот коммит содержится в:
18
svg.cpp
18
svg.cpp
@@ -5,14 +5,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool
|
||||
check_width(double width) {
|
||||
if (width >= 3 && width <= 30)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
svg_text(double left, double baseline, string text) {
|
||||
cout << "<text x='" << left
|
||||
@@ -55,16 +47,8 @@ show_histogram_svg(const vector<size_t>& bins) {
|
||||
const auto TEXT_BASELINE = 20;
|
||||
const auto TEXT_WIDTH = 50;
|
||||
const auto BIN_HEIGHT = 30;
|
||||
double BLOCK_WIDTH = 0;
|
||||
const auto BLOCK_WIDTH = 10;
|
||||
const auto MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH;
|
||||
cerr << "Enter block width: ";
|
||||
cin >> BLOCK_WIDTH;
|
||||
bool check = check_width(BLOCK_WIDTH);
|
||||
while (!check) {
|
||||
cerr << "Incorrectly enter. The block width must be >= 3px and <= 30 px. Please try again." << endl;
|
||||
cin >> BLOCK_WIDTH;
|
||||
check = check_width(BLOCK_WIDTH);
|
||||
}
|
||||
size_t max_count = 0;
|
||||
for (size_t x : bins) {
|
||||
if (x > max_count) {
|
||||
|
||||
11
unittest.cpp
11
unittest.cpp
@@ -2,7 +2,6 @@
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
#include "histogram_internal.h"
|
||||
#include "svg_internal.h"
|
||||
|
||||
TEST_CASE("distinct positive numbers") {
|
||||
double min = 0;
|
||||
@@ -53,13 +52,3 @@ TEST_CASE("empty vector") {
|
||||
CHECK(min == 0);
|
||||
CHECK(max == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("correct block width") {
|
||||
bool check = check_width(23.5);
|
||||
CHECK(check == true);
|
||||
}
|
||||
|
||||
TEST_CASE("incorrect block width") {
|
||||
bool check = check_width(59);
|
||||
CHECK(check == false);
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user