diff --git a/svg.cpp b/svg.cpp
index fd6b1b0..569ec26 100644
--- a/svg.cpp
+++ b/svg.cpp
@@ -22,9 +22,9 @@ void svg_begin(double width, double height) {
}
-void svg_end(double top) {
- cout << "\n";
- cout << "\n";
+void svg_end(double top, ostream& stream) {
+ stream << "\n";
+ stream << "\n";
}
void svg_text(double left, double baseline, string text) {
@@ -57,5 +57,5 @@ void show_histogram_svg(const vector& bins) {
svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT);
top += BIN_HEIGHT;
}
- svg_end(top);
+ svg_end(top, cout);
}
\ No newline at end of file
diff --git a/svg_iternal.h b/svg_iternal.h
new file mode 100644
index 0000000..9a2d203
--- /dev/null
+++ b/svg_iternal.h
@@ -0,0 +1,4 @@
+#pragma once
+#include
+
+void svg_end(double top, std::ostream& stream);
\ No newline at end of file
diff --git a/unittest.cpp b/unittest.cpp
index a26c90a..b33e691 100644
--- a/unittest.cpp
+++ b/unittest.cpp
@@ -2,6 +2,9 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "histogram_internal.h"
+#include "svg_iternal.h"
+#include
+
TEST_CASE("distinct positive numbers") {
double min = 0;
@@ -11,14 +14,6 @@ TEST_CASE("distinct positive numbers") {
CHECK(max == 2);
}
-TEST_CASE("empty vector") {
- double min = 0;
- double max = 0;
- find_minmax({ }, min, max);
- CHECK(min != 0);
- CHECK(max != 0);
-}
-
TEST_CASE("one element") {
double min = 0;
double max = 0;
@@ -34,3 +29,9 @@ TEST_CASE("negative elements") {
CHECK(min == -81);
CHECK(max == 2);
}
+
+TEST_CASE("svg_check") {
+std::stringstream stream;
+svg_end(100, stream);
+CHECK(stream.str() == "\n\n");
+}