Родитель
89b1f2f308
Сommit
d8a083e554
@ -0,0 +1,49 @@
|
|||||||
|
#define DOCTEST_CINFIG_NO_MULTITHREADING
|
||||||
|
#define DOCTEST_CINFIG_IMOLEMENT_WITH_MAIN
|
||||||
|
#include "doctest.h"
|
||||||
|
#include "histogram_internal.h"
|
||||||
|
#include "svg.h"
|
||||||
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
TEST_CASE("distinct positive numbers") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({ 1, 2 }, min, max);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("check if vector is only one in length") {
|
||||||
|
double min = 3;
|
||||||
|
double max = 3;
|
||||||
|
find_minmax({ 3 }, min, max);
|
||||||
|
CHECK(min == 3);
|
||||||
|
CHECK(max == 3);
|
||||||
|
}
|
||||||
|
TEST_CASE("all numbers are the same") {
|
||||||
|
double min = 1;
|
||||||
|
double max = 1;
|
||||||
|
find_minmax({ 1, 1, 1, 1, 1, 1, 1, }, min, max);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 1);
|
||||||
|
}
|
||||||
|
TEST_CASE("all numbers are the same") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
CHECK(!find_minmax({}, min, max));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("histogram for 10 variant is correct") {
|
||||||
|
std::fstream in, compare;
|
||||||
|
std::string line, compline;
|
||||||
|
bool flag = 0;
|
||||||
|
in.open("result.txt");
|
||||||
|
compare.open("compare.txt");
|
||||||
|
while (std::getline(in, line) && std::getline(compare, compline) && !flag) {
|
||||||
|
if (line != compline) {
|
||||||
|
flag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CHECK(flag == 0);
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче