Michael J. Spencer | 1eb3b89 | 2013-04-12 18:40:39 +0000 | [diff] [blame] | 1 | //===- lld/unittest/ParallelTest.cpp --------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// \brief Parallel.h unit tests. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "gtest/gtest.h" |
Michael J. Spencer | 1eb3b89 | 2013-04-12 18:40:39 +0000 | [diff] [blame] | 16 | #include "lld/Core/Parallel.h" |
Michael J. Spencer | 1eb3b89 | 2013-04-12 18:40:39 +0000 | [diff] [blame] | 17 | #include <array> |
| 18 | #include <random> |
| 19 | |
| 20 | uint32_t array[1024 * 1024]; |
| 21 | |
| 22 | TEST(Parallel, sort) { |
| 23 | std::mt19937 randEngine; |
| 24 | std::uniform_int_distribution<uint32_t> dist; |
| 25 | |
| 26 | for (auto &i : array) |
| 27 | i = dist(randEngine); |
| 28 | |
| 29 | lld::parallel_sort(std::begin(array), std::end(array)); |
| 30 | ASSERT_TRUE(std::is_sorted(std::begin(array), std::end(array))); |
| 31 | } |