Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: net/quic/crypto/quic_random_test.cc

Issue 11476031: Add the QuicRandom interface with a default implementation that is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Export QuicRandom for net_unittesrs Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/quic_random.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #include "net/quic/crypto/quic_random.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace net {
10
11 namespace test {
12
13 TEST(QuicRandomTest, RandBytes) {
14 unsigned char buf1[16];
15 unsigned char buf2[16];
16 memset(buf1, 0xaf, sizeof(buf1));
17 memset(buf2, 0xaf, sizeof(buf2));
18 ASSERT_TRUE(memcmp(buf1, buf2, sizeof(buf1)) == 0);
19
20 QuicRandom* rng = QuicRandom::GetInstance();
21 rng->RandBytes(buf1, sizeof(buf1));
22 EXPECT_FALSE(memcmp(buf1, buf2, sizeof(buf1)) == 0);
23 }
24
25 TEST(QuicRandomTest, RandUint64) {
26 QuicRandom* rng = QuicRandom::GetInstance();
27 uint64 value1 = rng->RandUint64();
28 uint64 value2 = rng->RandUint64();
29 EXPECT_NE(value1, value2);
30 }
31
32 TEST(QuicRandomTest, Reseed) {
33 char buf[1024];
34 memset(buf, 0xaf, sizeof(buf));
35
36 QuicRandom* rng = QuicRandom::GetInstance();
37 rng->Reseed(buf, sizeof(buf));
38 }
39
40 } // namespace test
41
42 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_random.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698