personal test
Этот коммит содержится в:
8
svg.cpp
8
svg.cpp
@@ -22,9 +22,9 @@ void svg_begin(double width, double height) {
|
||||
|
||||
}
|
||||
|
||||
void svg_end(double top) {
|
||||
cout << "<line x1='10' y1='" << top << "' x2='" << IMAGE_WIDTH <<"' y2='" << top << "' stroke-dasharray = '10 10' stroke='black'/>\n";
|
||||
cout << "</svg>\n";
|
||||
void svg_end(double top, ostream& stream) {
|
||||
stream << "<line x1='10' y1='" << top << "' x2='" << IMAGE_WIDTH <<"' y2='" << top << "' stroke-dasharray = '10 10' stroke='black'/>\n";
|
||||
stream << "</svg>\n";
|
||||
}
|
||||
|
||||
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);
|
||||
top += BIN_HEIGHT;
|
||||
}
|
||||
svg_end(top);
|
||||
svg_end(top, cout);
|
||||
}
|
||||
4
svg_iternal.h
Обычный файл
4
svg_iternal.h
Обычный файл
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
|
||||
void svg_end(double top, std::ostream& stream);
|
||||
17
unittest.cpp
17
unittest.cpp
@@ -2,6 +2,9 @@
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
#include "histogram_internal.h"
|
||||
#include "svg_iternal.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
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() == "<line x1='10' y1='100' x2='400' y2='100' stroke-dasharray = '10 10' stroke='black'/>\n</svg>\n");
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user