code: заготовка для лабораторной работы №4

main
DevyatovaMY 11 месяцев назад
Родитель 0b29726755
Сommit 5209da476a

@ -5,14 +5,6 @@
using namespace std; using namespace std;
bool
check_width(double width) {
if (width >= 3 && width <= 30)
return true;
else
return false;
}
void void
svg_text(double left, double baseline, string text) { svg_text(double left, double baseline, string text) {
cout << "<text x='" << left cout << "<text x='" << left
@ -55,16 +47,8 @@ show_histogram_svg(const vector<size_t>& bins) {
const auto TEXT_BASELINE = 20; const auto TEXT_BASELINE = 20;
const auto TEXT_WIDTH = 50; const auto TEXT_WIDTH = 50;
const auto BIN_HEIGHT = 30; const auto BIN_HEIGHT = 30;
double BLOCK_WIDTH = 0; const auto BLOCK_WIDTH = 10;
const auto MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH; 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; size_t max_count = 0;
for (size_t x : bins) { for (size_t x : bins) {
if (x > max_count) { if (x > max_count) {

@ -2,7 +2,6 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h" #include "doctest.h"
#include "histogram_internal.h" #include "histogram_internal.h"
#include "svg_internal.h"
TEST_CASE("distinct positive numbers") { TEST_CASE("distinct positive numbers") {
double min = 0; double min = 0;
@ -53,13 +52,3 @@ TEST_CASE("empty vector") {
CHECK(min == 0); CHECK(min == 0);
CHECK(max == 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);
}

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