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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/crypto/quic_random.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/quic_random_test.cc
===================================================================
--- net/quic/crypto/quic_random_test.cc (revision 0)
+++ net/quic/crypto/quic_random_test.cc (revision 0)
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/crypto/quic_random.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace test {
+
+TEST(QuicRandomTest, RandBytes) {
+ unsigned char buf1[16];
+ unsigned char buf2[16];
+ memset(buf1, 0xaf, sizeof(buf1));
+ memset(buf2, 0xaf, sizeof(buf2));
+ ASSERT_TRUE(memcmp(buf1, buf2, sizeof(buf1)) == 0);
+
+ QuicRandom* rng = QuicRandom::GetInstance();
+ rng->RandBytes(buf1, sizeof(buf1));
+ EXPECT_FALSE(memcmp(buf1, buf2, sizeof(buf1)) == 0);
+}
+
+TEST(QuicRandomTest, RandUint64) {
+ QuicRandom* rng = QuicRandom::GetInstance();
+ uint64 value1 = rng->RandUint64();
+ uint64 value2 = rng->RandUint64();
+ EXPECT_NE(value1, value2);
+}
+
+TEST(QuicRandomTest, Reseed) {
+ char buf[1024];
+ memset(buf, 0xaf, sizeof(buf));
+
+ QuicRandom* rng = QuicRandom::GetInstance();
+ rng->Reseed(buf, sizeof(buf));
+}
+
+} // namespace test
+
+} // namespace net
Property changes on: net/quic/crypto/quic_random_test.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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