blob: c0282437e2e1d5f29787f9019c271933dcacd1dd [file] [log] [blame]
Michael J. Spencer1eb3b892013-04-12 18:40:39 +00001//===- 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. Spencer1eb3b892013-04-12 18:40:39 +000016#include "lld/Core/Parallel.h"
Michael J. Spencer1eb3b892013-04-12 18:40:39 +000017#include <array>
18#include <random>
19
20uint32_t array[1024 * 1024];
21
22TEST(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}