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

Unified Diff: base/rand_util_unittest.cc

Issue 6873156: Move crypto_helpers from sync to base (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Correct WriteInto length. Created 9 years, 8 months 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
Index: base/rand_util_unittest.cc
diff --git a/base/rand_util_unittest.cc b/base/rand_util_unittest.cc
index 3bdb815fee15dd2890e645158676819563735f5c..3febf543fd54d09ece4cfafe2d4cbe65c053a93f 100644
--- a/base/rand_util_unittest.cc
+++ b/base/rand_util_unittest.cc
@@ -28,6 +28,18 @@ TEST(RandUtilTest, RandDouble) {
EXPECT_LE(0.0, number);
}
+TEST(RandUtilTest, RandBytes) {
+ const size_t buffer_size = 145;
+ char buffer[buffer_size];
agl 2011/05/03 14:53:40 you probably want to memset(buffer, 0, buffer_size
+ base::RandBytes(buffer, buffer_size);
+ char accumulator = 0;
+ for(size_t i = 0; i < buffer_size; ++i)
+ accumulator |= buffer[i];
+ // In theory this test can fail, but it won't before the universe dies of
+ // heat death.
+ EXPECT_NE(0, accumulator);
+}
+
TEST(RandUtilTest, RandBytesAsString) {
std::string random_string = base::RandBytesAsString(0);
EXPECT_EQ(0U, random_string.size());

Powered by Google App Engine
This is Rietveld 408576698