proxygen
RadixSortTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include <folly/Random.h>
21 
22 using namespace folly;
23 using namespace folly::detail;
24 
25 TEST(DoubleRadixSort, Basic) {
26  std::unique_ptr<uint64_t[]> buckets(new uint64_t[256 * 9]);
27  for (int i = 0; i < 100; i++) {
28  size_t sz = folly::Random::rand32(0, 100000);
29  std::unique_ptr<double[]> in(new double[sz]);
30  std::unique_ptr<double[]> out(new double[sz]);
31  for (size_t j = 0; j < sz; j++) {
32  in[j] = folly::Random::randDouble(-100.0, 100.0);
33  }
34  double_radix_sort(sz, buckets.get(), in.get(), out.get());
35  EXPECT_TRUE(std::is_sorted(in.get(), in.get() + sz));
36  }
37 }
void double_radix_sort(uint64_t n, uint64_t *buckets, double *in, double *tmp)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
static double randDouble(double min, double max)
Definition: Random.h:345
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static uint32_t rand32()
Definition: Random.h:213
TEST(SequencedExecutor, CPUThreadPoolExecutor)