diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp new file mode 100644 index 0000000..be25bcc --- /dev/null +++ b/unittest/unittest.cpp @@ -0,0 +1,49 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "C:\Users\User\Desktop\cs-lab03\histogram_internal.h" +#include "C:\Users\User\Desktop\cs-lab03\svg.h" + +TEST_CASE("distinct positive numbers") { + double min = 0; + double max = 0; + find_minmax({ }, min, max); + CHECK(min == 0); + CHECK(max == 0); +} + +TEST_CASE("distinct identical numbers") { + double min = 10000; + double max = 0; + find_minmax({ 5, 5 }, min, max); + CHECK(min == 5); + CHECK(max == 5); +} + +TEST_CASE("distinct one number") { + double min = 10000; + double max = 0; + find_minmax({ 3 }, min, max); + CHECK(min == 3); + CHECK(max == 3); +} + +TEST_CASE("distinct negative numbers") { + double min = 1000; + double max = -1000; + find_minmax({ -3, -1 }, min, max); + CHECK(min == -3); + CHECK(max == -1); +} + +TEST_CASE("take percent") { + int x = 0; + pers(1, 20, x); + CHECK(x < 10); +} + +TEST_CASE("take percent") { + int x = 0; + pers(5, 10, x); + CHECK(x == 50); +}