OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "net/http2/tools/random_decoder_test.h" | 5 #include "net/http2/tools/random_decoder_test.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 << "\nFailed with SelectZeroAndOne"; | 120 << "\nFailed with SelectZeroAndOne"; |
121 VERIFY_EQ(first_consumed, input.Offset()) | 121 VERIFY_EQ(first_consumed, input.Offset()) |
122 << "\nFailed with SelectZeroAndOne; input.Offset=" << input.Offset() | 122 << "\nFailed with SelectZeroAndOne; input.Offset=" << input.Offset() |
123 << "; input.Remaining=" << input.Remaining(); | 123 << "; input.Remaining=" << input.Remaining(); |
124 } | 124 } |
125 { | 125 { |
126 // Decode again, with randomly selected segment sizes. | 126 // Decode again, with randomly selected segment sizes. |
127 DecodeBuffer input(original->cursor(), original_remaining); | 127 DecodeBuffer input(original->cursor(), original_remaining); |
128 VLOG(2) << "DecodeSegmentsAndValidate with SelectRandom"; | 128 VLOG(2) << "DecodeSegmentsAndValidate with SelectRandom"; |
129 VERIFY_SUCCESS(DecodeSegmentsAndValidate( | 129 VERIFY_SUCCESS(DecodeSegmentsAndValidate( |
130 &input, RandomDecoderTest::SelectRandom(return_non_zero_on_first), | 130 &input, SelectRandom(return_non_zero_on_first), validator)) |
131 validator)) | |
132 << "\nFailed with SelectRandom; input.Offset=" << input.Offset() | 131 << "\nFailed with SelectRandom; input.Offset=" << input.Offset() |
133 << "; input.Remaining=" << input.Remaining(); | 132 << "; input.Remaining=" << input.Remaining(); |
134 VERIFY_EQ(first_consumed, input.Offset()) << "\nFailed with SelectRandom"; | 133 VERIFY_EQ(first_consumed, input.Offset()) << "\nFailed with SelectRandom"; |
135 } | 134 } |
136 VERIFY_EQ(original_remaining, original->Remaining()); | 135 VERIFY_EQ(original_remaining, original->Remaining()); |
137 original->AdvanceCursor(first_consumed); | 136 original->AdvanceCursor(first_consumed); |
138 VLOG(1) << "DecodeAndValidateSeveralWays - SUCCESS"; | 137 VLOG(1) << "DecodeAndValidateSeveralWays - SUCCESS"; |
139 return ::testing::AssertionSuccess(); | 138 return ::testing::AssertionSuccess(); |
140 } | 139 } |
141 | 140 |
(...skipping 28 matching lines...) Expand all Loading... |
170 return r % (remaining + 1); // size in range [0, remaining]. | 169 return r % (remaining + 1); // size in range [0, remaining]. |
171 }; | 170 }; |
172 } | 171 } |
173 | 172 |
174 uint32_t RandomDecoderTest::RandStreamId() { | 173 uint32_t RandomDecoderTest::RandStreamId() { |
175 return random_.Rand32() & StreamIdMask(); | 174 return random_.Rand32() & StreamIdMask(); |
176 } | 175 } |
177 | 176 |
178 } // namespace test | 177 } // namespace test |
179 } // namespace net | 178 } // namespace net |
OLD | NEW |