proxygen
RadixSortTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (DoubleRadixSort, Basic)
 

Function Documentation

TEST ( DoubleRadixSort  ,
Basic   
)

Definition at line 25 of file RadixSortTest.cpp.

References folly::detail::double_radix_sort(), EXPECT_TRUE, i, folly::Random::rand32(), folly::Random::randDouble(), and uint64_t.

25  {
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)
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