From 5ad9cd1a1a18bc97ff0bc651f9704e8fa0c7eedb Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 10 Nov 2015 20:30:51 +0100 Subject: COMMON: More sort unit tests --- test/common/algorithm.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/common') diff --git a/test/common/algorithm.h b/test/common/algorithm.h index 6eecae3635..ccf6469f67 100644 --- a/test/common/algorithm.h +++ b/test/common/algorithm.h @@ -46,11 +46,29 @@ public: } void test_pod_sort() { + { + int dummy; + Common::sort(&dummy, &dummy); + TS_ASSERT_EQUALS(checkSort(&dummy, &dummy, Common::Less()), true); + } + { + int array[] = { 12 }; + Common::sort(array, ARRAYEND(array)); + TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less()), true); + + // already sorted + Common::sort(array, ARRAYEND(array)); + TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less()), true); + } { int array[] = { 63, 11, 31, 72, 1, 48, 32, 69, 38, 31 }; Common::sort(array, ARRAYEND(array)); TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less()), true); + int sortedArray[] = { 1, 11, 31, 31, 32, 38, 48, 63, 69, 72 }; + for (size_t i = 0; i < 10; ++i) + TS_ASSERT_EQUALS(array[i], sortedArray[i]); + // already sorted Common::sort(array, ARRAYEND(array)); TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less()), true); -- cgit v1.2.3