aboutsummaryrefslogtreecommitdiff
path: root/test/common/algorithm.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/common/algorithm.h')
-rw-r--r--test/common/algorithm.h18
1 files changed, 18 insertions, 0 deletions
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
@@ -47,10 +47,28 @@ public:
void test_pod_sort() {
{
+ int dummy;
+ Common::sort(&dummy, &dummy);
+ TS_ASSERT_EQUALS(checkSort(&dummy, &dummy, Common::Less<int>()), true);
+ }
+ {
+ int array[] = { 12 };
+ Common::sort(array, ARRAYEND(array));
+ TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less<int>()), true);
+
+ // already sorted
+ Common::sort(array, ARRAYEND(array));
+ TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less<int>()), 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<int>()), 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<int>()), true);