• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "core/fxcrt/fx_random.h"
6 
7 #include <array>
8 #include <set>
9 
10 #include "testing/gtest/include/gtest/gtest.h"
11 
TEST(FX_Random,GenerateMT3600times)12 TEST(FX_Random, GenerateMT3600times) {
13   // Prove this doesn't spin wait for a second each time.
14   // Since our global seeds are sequential, they wont't collide once
15   // seeded until 2^32 calls, and if the PNRG is any good, we won't
16   // get the same sequence from different seeds, esp. with this few
17   // iterations.
18   std::set<std::array<uint32_t, 16>> seen;
19   std::array<uint32_t, 16> current;
20   for (int i = 0; i < 3600; ++i) {
21     FX_Random_GenerateMT(current.data(), 16);
22     EXPECT_TRUE(seen.insert(current).second);
23   }
24 }
25