diff --git a/histogram_internal.h b/histogram_internal.h new file mode 100644 index 0000000..6e1e667 --- /dev/null +++ b/histogram_internal.h @@ -0,0 +1,7 @@ +#ifndef HISTOGRAM_INTERNAL_H_INCLUDED +#define HISTOGRAM_INTERNAL_H_INCLUDED + +#include + +bool find_minmax(const std::vector& A, double& min, double& max); +#endif // HISTOGRAM_INTERNAL_H_INCLUDED diff --git a/unittest.cbp b/unittest.cbp new file mode 100644 index 0000000..379d0a2 --- /dev/null +++ b/unittest.cbp @@ -0,0 +1,40 @@ + + + + + + diff --git a/unittest.cpp b/unittest.cpp new file mode 100644 index 0000000..c8f4db1 --- /dev/null +++ b/unittest.cpp @@ -0,0 +1,56 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "histogram_internal.h" + +TEST_CASE("emptyA") { + std::vectorA{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(A, min, max); + CHECK(A.size() !=0 ); +} + +TEST_CASE("min") +{ + std::vectorA{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(A, min, max); + CHECK(min == 1); +} + +TEST_CASE("max") +{ + std::vectorA{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(A, min, max); + CHECK(max == 4); +} + + +TEST_CASE("1A") { + std::vectorA{1,2,3,4}; + double min = 0; + double max = 0; + find_minmax(A, min, max); + CHECK(A.size() !=1 ); +} + + +TEST_CASE("same"){ + std::vectorA{1,1,1,1}; + std::vectorB{1,1,1,1}; + double min = 0; + double max = 0; + find_minmax(A, min, max); + CHECK(A == B); +} + +TEST_CASE("emt"){ + std::vectorA{}; + double min = 0; + double max = 0; + CHECK(find_minmax(A,min,max)==false); +}