From c866736f5d63b18cc9b2ecb1d0f9e4ecb4c0e43d Mon Sep 17 00:00:00 2001 From: KovalenkoDM Date: Mon, 13 May 2024 13:47:19 +0300 Subject: [PATCH] personal test --- svg.cpp | 8 ++++---- svg_iternal.h | 4 ++++ unittest.cpp | 17 +++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 svg_iternal.h 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"); +}