OLD | NEW |
---|---|
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/unguessable_token.h" | 5 #include "base/unguessable_token.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <type_traits> | 8 #include <type_traits> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 token.GetLowForSerialization()), | 109 token.GetLowForSerialization()), |
110 UnguessableTokenHash()(token)); | 110 UnguessableTokenHash()(token)); |
111 } | 111 } |
112 | 112 |
113 TEST(UnguessableTokenTest, VerifyBasicUniqueness) { | 113 TEST(UnguessableTokenTest, VerifyBasicUniqueness) { |
114 EXPECT_NE(UnguessableToken::Create(), UnguessableToken::Create()); | 114 EXPECT_NE(UnguessableToken::Create(), UnguessableToken::Create()); |
115 | 115 |
116 UnguessableToken token = UnguessableToken::Create(); | 116 UnguessableToken token = UnguessableToken::Create(); |
117 EXPECT_NE(token.GetHighForSerialization(), token.GetLowForSerialization()); | 117 EXPECT_NE(token.GetHighForSerialization(), token.GetLowForSerialization()); |
118 } | 118 } |
119 | |
120 TEST(UnguessableTokenTest, UberUniqueness) { | |
121 std::set<UnguessableToken> tokens; | |
122 for (int i = 0; i < 1000000; ++i) | |
123 ASSERT_TRUE(tokens.insert(UnguessableToken::Create()).second); | |
dcheng
2016/12/03 00:50:56
How long does this take to run? Honestly, this fee
Devlin
2016/12/03 01:46:12
Whoops! This wasn't actually supposed to be inclu
| |
119 } | 124 } |
dcheng
2016/12/03 00:50:56
Nit: newline after this
| |
125 } | |
OLD | NEW |