diff options
author | Bertrand Augereau | 2015-11-10 20:30:51 +0100 |
---|---|---|
committer | Bertrand Augereau | 2015-11-10 20:30:51 +0100 |
commit | 5ad9cd1a1a18bc97ff0bc651f9704e8fa0c7eedb (patch) | |
tree | d930e116aff9c56f942c9a2ded242ed4f2c1ee9d /test/common/algorithm.h | |
parent | 1311fe5c49146b14a476f47c10529931a467ff98 (diff) | |
download | scummvm-rg350-5ad9cd1a1a18bc97ff0bc651f9704e8fa0c7eedb.tar.gz scummvm-rg350-5ad9cd1a1a18bc97ff0bc651f9704e8fa0c7eedb.tar.bz2 scummvm-rg350-5ad9cd1a1a18bc97ff0bc651f9704e8fa0c7eedb.zip |
COMMON: More sort unit tests
Diffstat (limited to 'test/common/algorithm.h')
-rw-r--r-- | test/common/algorithm.h | 18 |
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); |