blob: 1361e2496b78b5c1510275fd583b635151d98249 [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2017 The PDFium Authors
Tom Sepeze8b3e0c2017-09-08 10:18:37 -07002// 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
12TEST(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}