From a821bb71e453a2ebb951cda1ef3146eef34cb184 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Fri, 7 Sep 2018 11:05:01 +0200 Subject: [PATCH] Add ArrayUtils tests --- tests/CMakeLists.txt | 1 + tests/test_ArrayUtils.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/test_ArrayUtils.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b6c12e701..c36e9a2d5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PASTIS_BINARY_DIR}) add_executable (unit_tests test_main.cpp test_Array.cpp + test_ArrayUtils.cpp test_ItemType.cpp test_PastisAssert.cpp test_RevisionInfo.cpp diff --git a/tests/test_ArrayUtils.cpp b/tests/test_ArrayUtils.cpp new file mode 100644 index 000000000..9861db42a --- /dev/null +++ b/tests/test_ArrayUtils.cpp @@ -0,0 +1,26 @@ +#include <catch.hpp> + +#include <PastisAssert.hpp> +#include <Array.hpp> +#include <ArrayUtils.hpp> + +// Instantiate to ensure full coverage is performed +template class Array<int>; + +TEST_CASE("ArrayUtils", "[utils]") { + + Array<int> a(10); + a[0] =13; + a[1] = 1; + a[2] = 8; + a[3] =-3; + a[4] =23; + a[5] =-1; + a[6] =13; + a[7] = 0; + a[8] =12; + a[9] = 9; + + REQUIRE((ReduceMin(a) == -3)); + REQUIRE((ReduceMax(a) == 23)); +} -- GitLab