diff --git a/unittest.cpp b/unittest.cpp index 09e3f7a..f91aa73 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -10,3 +10,33 @@ TEST_CASE("distinct positive numbers") { CHECK(min == 1); CHECK(max == 2); } +TEST_CASE("empty vector") { + double min = 0; + double max = 0; + find_minmax({NULL}, min, max); + CHECK(min == 0); + CHECK(max == 0); +} +TEST_CASE("one element") { + double min = 0; + double max = 0; + find_minmax({1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} + +TEST_CASE("negative elements") { + double min = 0; + double max = 0; + find_minmax({-1, -2}, min, max); + CHECK(min == -2); + CHECK(max == -1); +} +TEST_CASE("same elements") { + double min = 0; + double max = 0; + find_minmax({1,1,1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} +