unittest для собственного варианта

master
Alex 11 месяцев назад
Родитель 9d94c68847
Сommit c8f4ebca96

@ -1,4 +1,5 @@
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED #ifndef HISTOGRAM_INTERNAL_H_INCLUDED
#define HISTOGRAM_INTERNAL_H_INCLUDED #define HISTOGRAM_INTERNAL_H_INCLUDED
void find_minmax(const std::vector<double>& numbers, double& min, double& max); void find_minmax(const std::vector<double>& numbers, double& min, double& max);
std::string check_color(const std::string& color);
#endif // HISTOGRAM_INTERNAL_H_INCLUDED #endif // HISTOGRAM_INTERNAL_H_INCLUDED

@ -2,7 +2,6 @@
#include <vector> #include <vector>
#include "svg.h" #include "svg.h"
void svg_begin(double width, double height) void svg_begin(double width, double height)
{ {
std::cout << "<?xml version='1.0' encoding='UTF-8'?>\n"; std::cout << "<?xml version='1.0' encoding='UTF-8'?>\n";

@ -3,6 +3,7 @@
#include "doctest.h" #include "doctest.h"
#include "histogram_internal.h" #include "histogram_internal.h"
TEST_CASE("distinct positive numbers") { TEST_CASE("distinct positive numbers") {
double min = 0; double min = 0;
double max = 0; double max = 0;
@ -42,3 +43,15 @@ TEST_CASE("equal elements") {
CHECK(min == 4); CHECK(min == 4);
CHECK(max == 4); CHECK(max == 4);
} }
TEST_CASE("correct input 1") {
CHECK(check_color("red") == "red");
}
TEST_CASE("uncorrect input 2") {
CHECK(check_color("light red") == "black");
}
TEST_CASE("uncorrect input 2") {
CHECK(check_color("FF0000") == "black");
}

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