KovalenkoDM 12 месяцев назад
Родитель b8ad5f3fa4
Сommit c866736f5d

@ -22,9 +22,9 @@ void svg_begin(double width, double height) {
} }
void svg_end(double top) { void svg_end(double top, ostream& stream) {
cout << "<line x1='10' y1='" << top << "' x2='" << IMAGE_WIDTH <<"' y2='" << top << "' stroke-dasharray = '10 10' stroke='black'/>\n"; stream << "<line x1='10' y1='" << top << "' x2='" << IMAGE_WIDTH <<"' y2='" << top << "' stroke-dasharray = '10 10' stroke='black'/>\n";
cout << "</svg>\n"; stream << "</svg>\n";
} }
void svg_text(double left, double baseline, string text) { void svg_text(double left, double baseline, string text) {
@ -57,5 +57,5 @@ void show_histogram_svg(const vector<size_t>& bins) {
svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT); svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT);
top += BIN_HEIGHT; top += BIN_HEIGHT;
} }
svg_end(top); svg_end(top, cout);
} }

@ -0,0 +1,4 @@
#pragma once
#include <iostream>
void svg_end(double top, std::ostream& stream);

@ -2,6 +2,9 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h" #include "doctest.h"
#include "histogram_internal.h" #include "histogram_internal.h"
#include "svg_iternal.h"
#include <iostream>
TEST_CASE("distinct positive numbers") { TEST_CASE("distinct positive numbers") {
double min = 0; double min = 0;
@ -11,14 +14,6 @@ TEST_CASE("distinct positive numbers") {
CHECK(max == 2); 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") { TEST_CASE("one element") {
double min = 0; double min = 0;
double max = 0; double max = 0;
@ -34,3 +29,9 @@ TEST_CASE("negative elements") {
CHECK(min == -81); CHECK(min == -81);
CHECK(max == 2); CHECK(max == 2);
} }
TEST_CASE("svg_check") {
std::stringstream stream;
svg_end(100, stream);
CHECK(stream.str() == "<line x1='10' y1='100' x2='400' y2='100' stroke-dasharray = '10 10' stroke='black'/>\n</svg>\n");
}

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