diff --git a/cs-lab34.cbp b/cs-lab34.cbp
index d794df6..981bf7b 100644
--- a/cs-lab34.cbp
+++ b/cs-lab34.cbp
@@ -32,6 +32,7 @@
+
@@ -44,6 +45,9 @@
+
+
+
diff --git a/svg.cpp b/svg.cpp
index 1b344d8..fafe0f0 100644
--- a/svg.cpp
+++ b/svg.cpp
@@ -11,11 +11,11 @@ const auto TEXT_WIDTH = 50;
const auto BIN_HEIGHT = 30;
const auto BLOCK_WIDTH = 10;
-double ask_width(size_t numbers_count) {
+double ask_width(size_t numbers_count, std::istream& input) {
while (true) {
double width;
- cout << "Enter width ";
- cin >> width;
+ cerr << "Write width ";
+ input >> width;
if (width < 70) {
cout << "Try again. It's too low.\n";
} else if (width > 800) {
@@ -50,7 +50,7 @@ void svg_rect(double x, double y, double width, double height, string stroke = "
}
void show_histogram_svg(const vector& bins) {
- const auto IMAGE_WIDTH = ask_width(bins.size());
+ const auto IMAGE_WIDTH = ask_width(bins.size(), cin);
const auto MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH;
size_t max_count = 0;
for (size_t count : bins) {
diff --git a/svgg.h b/svgg.h
new file mode 100644
index 0000000..8a217ed
--- /dev/null
+++ b/svgg.h
@@ -0,0 +1,7 @@
+#ifndef SVGG_H_INCLUDED
+#define SVGG_H_INCLUDED
+
+double ask_width(size_t numbers_count);
+
+
+#endif // SVGG_H_INCLUDED
diff --git a/unittest.cbp b/unittest.cbp
index bffa065..534f497 100644
--- a/unittest.cbp
+++ b/unittest.cbp
@@ -31,9 +31,6 @@
-
-
-
diff --git a/unittest2.cbp b/unittest2.cbp
new file mode 100644
index 0000000..eb0c911
--- /dev/null
+++ b/unittest2.cbp
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/unittest2.cpp b/unittest2.cpp
new file mode 100644
index 0000000..9c705f7
--- /dev/null
+++ b/unittest2.cpp
@@ -0,0 +1,10 @@
+#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+#include "doctest.h"
+#include
+
+double ask_width(size_t numbers_count, std::istream& in);
+
+TEST_CASE("ask_width returns correct width") {
+ std::istringstream test_input("800\n");
+ CHECK(ask_width(10, test_input) == 800);
+}