Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

73 строки
2.1 KiB
C++

#define DOCTEST_CONFIG_NO_MULTITHREADING
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "svg_internal.h"
TEST_CASE("User height is zero") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 0;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 0);
}
TEST_CASE("empty array") {
std::vector<std::size_t> bins;
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 50;
auto BIN_HEIGHT = calculate_bin_height (bins, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 50);
}
TEST_CASE("User height is over image_height") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 800;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 350);
}
TEST_CASE("User height is irrational") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 0.5;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 0.5);
}
TEST_CASE("User height is BIG irrational") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 1000.5;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 350);
}
TEST_CASE("negative numbers") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = -5;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 0);
}
TEST_CASE("negative irrational numbers") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = -0.5;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 0);
}
TEST_CASE("negative numbers") {
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 0;
auto BIN_HEIGHT = calculate_bin_height ({1,2}, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 0);
}
TEST_CASE("big array") {
std::vector<std::size_t> bins(1000);
double IMAGE_HEIGHT = 700;
double USER_BIN_HEIGHT = 50;
auto BIN_HEIGHT = calculate_bin_height (bins, USER_BIN_HEIGHT, IMAGE_HEIGHT);
CHECK(BIN_HEIGHT == 0.7);
}