From e431557ac6302a3a855f811a7e9990dfbf2166ff Mon Sep 17 00:00:00 2001 From: Danila Date: Mon, 24 Apr 2023 14:48:45 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=205=20=D1=87=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/pr3.cbp | 2 ++ project/svg.cpp | 10 +++++++--- unittest.cpp | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/project/pr3.cbp b/project/pr3.cbp index 6b69c68..4542632 100644 --- a/project/pr3.cbp +++ b/project/pr3.cbp @@ -37,6 +37,8 @@ + + diff --git a/project/svg.cpp b/project/svg.cpp index b58b16f..7166ed2 100644 --- a/project/svg.cpp +++ b/project/svg.cpp @@ -6,6 +6,12 @@ #include "svg.h" using namespace std; +size_t emptiness_width (size_t a, size_t b) +{ + size_t c = a - b; + return c; +} + void svg_begin(double width, double height) { @@ -36,7 +42,6 @@ svg_rect(double x, double y, double width, double height, string stroke = "black } - void show_histogram_svg(const vector& bins) { @@ -67,11 +72,10 @@ show_histogram_svg(const vector& bins) for (size_t bin : bins) { double bin_width = (MAX_WIDTH)*(bin/max_count); - svg_rect(MAX_WIDTH-bin_width, top, bin_width, BIN_HEIGHT, BLACK, RED); + svg_rect(emptiness_width(MAX_WIDTH, bin_width), top, bin_width, BIN_HEIGHT, BLACK, RED); svg_text(TEXT_LEFT+MAX_WIDTH, top + TEXT_BASELINE, to_string(bin)); top += BIN_HEIGHT; } svg_end(); } - diff --git a/unittest.cpp b/unittest.cpp index 907123c..69ba8f3 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -1,9 +1,11 @@ #define DOCTEST_CONFIG_NO_MULTITHREADING #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include #include "doctest.h" #include "project/histogram_internal.h" +#include "project/svg.h" -TEST_CASE("distinct positive numbers 1") +/* TEST_CASE("distinct positive numbers 1") { double min = 0; double max = 0; @@ -39,3 +41,16 @@ TEST_CASE("vector with same elements") { CHECK(min == 2); CHECK(max == 2); } + +*/ + +TEST_CASE("distinct positive numbers 1") +{ + double min = 0; + double max = 0; + find_minmax({1, 2}, min, max); + CHECK(min == 1); + CHECK(max == 2); +} + +