Грудинин Егор 12 месяцев назад
Родитель 6e021a4b71
Сommit 5845a2206a

@ -36,6 +36,9 @@
<Unit filename="histogram.h" /> <Unit filename="histogram.h" />
<Unit filename="histogram_internal.h" /> <Unit filename="histogram_internal.h" />
<Unit filename="main.cpp" /> <Unit filename="main.cpp" />
<Unit filename="proverka.h" />
<Unit filename="svg.cpp" />
<Unit filename="svg.h" />
<Unit filename="text.cpp" /> <Unit filename="text.cpp" />
<Unit filename="text.h" /> <Unit filename="text.h" />
<Extensions> <Extensions>

@ -0,0 +1,7 @@
#ifndef PROVERKA_H_INCLUDED
#define PROVERKA_H_INCLUDED
void
proverka (bool& flag, int font_size);
#endif // PROVERKA_H_INCLUDED

@ -39,20 +39,26 @@ svg_end() {
} }
void void
show_histogram_svg(const vector<size_t>& bins) { proverka(bool& flag, int font_size){
int font_size = 12;
bool flag = true;
while(flag) {
cerr << "Enter font size (8-32): ";
cin >> font_size;
if (font_size < 8) { if (font_size < 8) {
cerr << "Font size is too small. Please enter a value between 8 and 32." << endl; cerr << "Font size is too small. Please enter a value between 8 and 32." << endl;
flag = true;
} else if (font_size > 32) { } else if (font_size > 32) {
cerr << "Font size is too large. Please enter a value between 8 and 32." << endl; cerr << "Font size is too large. Please enter a value between 8 and 32." << endl;
flag = true;
} else { } else {
flag = false; flag = false;
} }
}
void
show_histogram_svg(const vector<size_t>& bins) {
int font_size = 12;
bool flag = true;
while(flag) {
cerr << "Enter font size (8-32): ";
cin >> font_size;
proverka(flag, font_size);
} }
const auto MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH; const auto MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH;
size_t max_count = 0; size_t max_count = 0;

@ -33,6 +33,8 @@
</Compiler> </Compiler>
<Unit filename="histogram.cpp" /> <Unit filename="histogram.cpp" />
<Unit filename="histogram_internal.h" /> <Unit filename="histogram_internal.h" />
<Unit filename="proverka.h" />
<Unit filename="svg.cpp" />
<Unit filename="unittest.cpp" /> <Unit filename="unittest.cpp" />
<Extensions> <Extensions>
<lib_finder disable_auto="1" /> <lib_finder disable_auto="1" />

@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include "doctest.h" #include "doctest.h"
#include "histogram_internal.h" #include "histogram_internal.h"
#include "proverka.h"
TEST_CASE("distinct positive numbers") { TEST_CASE("distinct positive numbers") {
double min = 0; double min = 0;
@ -20,13 +21,6 @@ TEST_CASE("negative numbers") {
CHECK(max == 10); CHECK(max == 10);
} }
TEST_CASE("empty numbers") {
double min = 0;
double max = 0;
find_minmax({ }, min, max);
CHECK(min != 0);
CHECK(max != 0);
}
TEST_CASE("one number") { TEST_CASE("one number") {
double min = 0; double min = 0;
@ -36,4 +30,11 @@ TEST_CASE("one number") {
CHECK(max == 2); CHECK(max == 2);
} }
TEST_CASE("not in 8 - 32") {
int font_size = 8;
bool flag = true;
proverka(flag, font_size);
CHECK(flag == false);
}

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