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

Unified Diff: net/quic/crypto/strike_register_test.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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: net/quic/crypto/strike_register_test.cc
diff --git a/net/quic/crypto/strike_register_test.cc b/net/quic/crypto/strike_register_test.cc
index ddfa96535de07b9ded55335ae5deb9b1aee5c249..e47393bbb088c939c7ab01977242727e5a0b248d 100644
--- a/net/quic/crypto/strike_register_test.cc
+++ b/net/quic/crypto/strike_register_test.cc
@@ -16,7 +16,7 @@ using net::StrikeRegister;
using std::set;
using std::string;
-const uint8 kOrbit[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+const uint8 kOrbit[8] = {1, 2, 3, 4, 5, 6, 7, 8};
// StrikeRegisterTests don't look at the random bytes so this function can
// simply set the random bytes to 0.
@@ -31,8 +31,10 @@ void SetNonce(uint8 nonce[32], unsigned time, const uint8 orbit[8]) {
TEST(StrikeRegisterTest, SimpleHorizon) {
// The set must reject values created on or before its own creation time.
- StrikeRegister set(10 /* max size */, 1000 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(10 /* max size */,
+ 1000 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[32];
SetNonce(nonce, 999, kOrbit);
@@ -44,8 +46,10 @@ TEST(StrikeRegisterTest, SimpleHorizon) {
TEST(StrikeRegisterTest, NoStartupMode) {
// Check that a strike register works immediately if NO_STARTUP_PERIOD_NEEDED
// is specified.
- StrikeRegister set(10 /* max size */, 0 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(10 /* max size */,
+ 0 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::NO_STARTUP_PERIOD_NEEDED);
uint8 nonce[32];
SetNonce(nonce, 0, kOrbit);
@@ -55,8 +59,10 @@ TEST(StrikeRegisterTest, NoStartupMode) {
TEST(StrikeRegisterTest, WindowFuture) {
// The set must reject values outside the window.
- StrikeRegister set(10 /* max size */, 1000 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(10 /* max size */,
+ 1000 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[32];
SetNonce(nonce, 1101, kOrbit);
@@ -67,18 +73,22 @@ TEST(StrikeRegisterTest, WindowFuture) {
TEST(StrikeRegisterTest, BadOrbit) {
// The set must reject values with the wrong orbit
- StrikeRegister set(10 /* max size */, 1000 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(10 /* max size */,
+ 1000 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[32];
- static const uint8 kBadOrbit[8] = { 0, 0, 0, 0, 1, 1, 1, 1 };
+ static const uint8 kBadOrbit[8] = {0, 0, 0, 0, 1, 1, 1, 1};
SetNonce(nonce, 1101, kBadOrbit);
ASSERT_FALSE(set.Insert(nonce, 1100));
}
TEST(StrikeRegisterTest, OneValue) {
- StrikeRegister set(10 /* max size */, 1000 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(10 /* max size */,
+ 1000 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[32];
SetNonce(nonce, 1101, kOrbit);
@@ -87,8 +97,10 @@ TEST(StrikeRegisterTest, OneValue) {
TEST(StrikeRegisterTest, RejectDuplicate) {
// The set must reject values with the wrong orbit
- StrikeRegister set(10 /* max size */, 1000 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(10 /* max size */,
+ 1000 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[32];
SetNonce(nonce, 1101, kOrbit);
@@ -97,8 +109,10 @@ TEST(StrikeRegisterTest, RejectDuplicate) {
}
TEST(StrikeRegisterTest, HorizonUpdating) {
- StrikeRegister set(5 /* max size */, 1000 /* current time */,
- 100 /* window secs */, kOrbit,
+ StrikeRegister set(5 /* max size */,
+ 1000 /* current time */,
+ 100 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[6][32];
for (unsigned i = 0; i < 5; i++) {
@@ -118,20 +132,21 @@ TEST(StrikeRegisterTest, HorizonUpdating) {
}
TEST(StrikeRegisterTest, InsertMany) {
- StrikeRegister set(5000 /* max size */, 1000 /* current time */,
- 500 /* window secs */, kOrbit,
+ StrikeRegister set(5000 /* max size */,
+ 1000 /* current time */,
+ 500 /* window secs */,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP);
uint8 nonce[32];
SetNonce(nonce, 1101, kOrbit);
for (unsigned i = 0; i < 100000; i++) {
- SetNonce(nonce, 1101 + i/500, kOrbit);
+ SetNonce(nonce, 1101 + i / 500, kOrbit);
memcpy(nonce + 12, &i, sizeof(i));
set.Insert(nonce, 1100);
}
}
-
// For the following test we create a slow, but simple, version of a
// StrikeRegister. The behaviour of this object is much easier to understand
// than the fully fledged version. We then create a test to show, empirically,
@@ -142,8 +157,10 @@ TEST(StrikeRegisterTest, InsertMany) {
// empirically test that their behaviours are identical.
class SlowStrikeRegister {
public:
- SlowStrikeRegister(unsigned max_entries, uint32 current_time,
- uint32 window_secs, const uint8 orbit[8])
+ SlowStrikeRegister(unsigned max_entries,
+ uint32 current_time,
+ uint32 window_secs,
+ const uint8 orbit[8])
: max_entries_(max_entries),
window_secs_(window_secs),
creation_time_(current_time),
@@ -197,10 +214,8 @@ class SlowStrikeRegister {
private:
// TimeFromBytes returns a big-endian uint32 from |d|.
static uint32 TimeFromBytes(const uint8 d[4]) {
- return static_cast<uint32>(d[0]) << 24 |
- static_cast<uint32>(d[1]) << 16 |
- static_cast<uint32>(d[2]) << 8 |
- static_cast<uint32>(d[3]);
+ return static_cast<uint32>(d[0]) << 24 | static_cast<uint32>(d[1]) << 16 |
+ static_cast<uint32>(d[2]) << 8 | static_cast<uint32>(d[3]);
}
uint32 ExternalTimeToInternal(uint32 external_time) {
@@ -246,7 +261,10 @@ TEST(StrikeRegisterStressTest, Stress) {
unsigned max_entries = 64;
uint32 current_time = 10000, window = 200;
scoped_ptr<StrikeRegister> s1(
- new StrikeRegister(max_entries, current_time, window, kOrbit,
+ new StrikeRegister(max_entries,
+ current_time,
+ window,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP));
scoped_ptr<SlowStrikeRegister> s2(
new SlowStrikeRegister(max_entries, current_time, window, kOrbit));
@@ -262,7 +280,10 @@ TEST(StrikeRegisterStressTest, Stress) {
max_entries = rand() % 300 + 2;
current_time = rand() % 10000;
window = rand() % 500;
- s1.reset(new StrikeRegister(max_entries, current_time, window, kOrbit,
+ s1.reset(new StrikeRegister(max_entries,
+ current_time,
+ window,
+ kOrbit,
StrikeRegister::DENY_REQUESTS_AT_STARTUP));
s2.reset(
new SlowStrikeRegister(max_entries, current_time, window, kOrbit));

Powered by Google App Engine
This is Rietveld 408576698