Split tests into test and benchmarks.
[folly.git] / folly / test / RandomTest.cpp
index c8b96d2d5ad806f2aa942c933eed18be485ddf08..2f3c97d5cc03180e185f986886fb69c5354d91de 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "folly/Random.h"
+#include <folly/Random.h>
 
 #include <glog/logging.h>
 #include <gtest/gtest.h>
 #include <algorithm>
 #include <thread>
 #include <vector>
+#include <random>
 
 using namespace folly;
 
+TEST(Random, StateSize) {
+  using namespace folly::detail;
+
+  // uint_fast32_t is uint64_t on x86_64, w00t
+  EXPECT_EQ(sizeof(uint_fast32_t) / 4 + 3,
+            StateSize<std::minstd_rand0>::value);
+  EXPECT_EQ(624, StateSize<std::mt19937>::value);
+#if FOLLY_HAVE_EXTRANDOM_SFMT19937
+  EXPECT_EQ(624, StateSize<__gnu_cxx::sfmt19937>::value);
+#endif
+  EXPECT_EQ(24, StateSize<std::ranlux24_base>::value);
+}
+
 TEST(Random, Simple) {
   uint32_t prev = 0, seed = 0;
   for (int i = 0; i < 1024; ++i) {
@@ -34,7 +48,7 @@ TEST(Random, Simple) {
 }
 
 TEST(Random, MultiThreaded) {
-  const int n = 1024;
+  const int n = 100;
   std::vector<uint32_t> seeds(n);
   std::vector<std::thread> threads;
   for (int i = 0; i < n; ++i) {