diff --git a/project/.gitignore b/project/.gitignore index fba4e61..c20a886 100644 --- a/project/.gitignore +++ b/project/.gitignore @@ -1,2 +1,4 @@ /obj /bin +/pr3.depend +/pr3.layout diff --git a/project/histogram_internal.h b/project/histogram_internal.h index da65b3c..3b5a81b 100644 --- a/project/histogram_internal.h +++ b/project/histogram_internal.h @@ -1,7 +1,7 @@ -#ifndef FINDMINMAX_H_INCLUDED -#define FINDMINMAX_H_INCLUDED +#ifndef HISTOGRAM_INTERNAL_H_INCLUDED +#define HISTOGRAM_INTERNAL_H_INCLUDED #include -void find_minmax(vector numbers, double& min, double& max); +void find_minmax(std::vector numbers, double& min, double& max); -#endif // FINDMINMAX_H_INCLUDED +#endif // HISTOGRAM_INTERNAL_H_INCLUDED diff --git a/unittest.cpp b/unittest.cpp index e69de29..907123c 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -0,0 +1,41 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "project/histogram_internal.h" + +TEST_CASE("distinct positive numbers 1") +{ + double min = 0; + double max = 0; + find_minmax({1, 2}, min, max); + CHECK(min == 1); + CHECK(max == 2); +} + +TEST_CASE("distinct positive numbers 2") { + double min = 0; + double max = 0; + std::vectorv{2,1}; + CHECK(v.size() != 0); + CHECK(v.size() != 1); + find_minmax({1, 2}, min, max); + CHECK(min == 1); + CHECK(max == 2); + CHECK(min != max); +} + +TEST_CASE("vector with one element") { + double min = 0; + double max = 0; + find_minmax({1}, min, max); + CHECK(min == 1); + CHECK(max == 1); +} + +TEST_CASE("vector with same elements") { + double min = 0; + double max = 0; + find_minmax({2,2,2}, min, max); + CHECK(min == 2); + CHECK(max == 2); +}