1 // Copyright (c) 2012 The Chromium 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.
5 #include "net/quic/crypto/quic_random.h"
7 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(QuicRandomTest
, RandBytes
) {
13 unsigned char buf1
[16];
14 unsigned char buf2
[16];
15 memset(buf1
, 0xaf, sizeof(buf1
));
16 memset(buf2
, 0xaf, sizeof(buf2
));
17 ASSERT_EQ(0, memcmp(buf1
, buf2
, sizeof(buf1
)));
19 QuicRandom
* rng
= QuicRandom::GetInstance();
20 rng
->RandBytes(buf1
, sizeof(buf1
));
21 EXPECT_NE(0, memcmp(buf1
, buf2
, sizeof(buf1
)));
24 TEST(QuicRandomTest
, RandUint64
) {
25 QuicRandom
* rng
= QuicRandom::GetInstance();
26 uint64 value1
= rng
->RandUint64();
27 uint64 value2
= rng
->RandUint64();
28 EXPECT_NE(value1
, value2
);
31 TEST(QuicRandomTest
, Reseed
) {
33 memset(buf
, 0xaf, sizeof(buf
));
35 QuicRandom
* rng
= QuicRandom::GetInstance();
36 rng
->Reseed(buf
, sizeof(buf
));