#define DOCTEST_CONFIG_NO_MULTITHREADING #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doctest.h" #include "histogram_internal.h" #include "svg.h" #include 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("negative numbers") { double min = 0; double max = 0; find_minmax({ -10, 10 }, min, max); CHECK(min == -10); CHECK(max == 10); } TEST_CASE("one number") { double min = 0; double max = 0; find_minmax({ 2 }, min, max); CHECK(min == 2); CHECK(max == 2); } #include "doctest.h" #include "svg.h" #include #include TEST_CASE("show_histogram_svg") { std::ostringstream oss; std::streambuf* p_cout_streambuf = std::cout.rdbuf(); std::cout.rdbuf(oss.rdbuf()); show_histogram_svg({1, 2, 3, 4}); std::cout.rdbuf(p_cout_streambuf); std::string result = oss.str(); std::string expected = "" "" "" "1" "2" "3" "4"; CHECK(result == expected); }