1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_BASE_TEST_DATA_STREAM_H_
6 #define NET_BASE_TEST_DATA_STREAM_H_
8 #include <string.h> // for memcpy().
10 #include "net/base/net_export.h"
12 // This is a class for generating an infinite stream of data which can be
13 // verified independently to be the correct stream of data.
17 class NET_EXPORT TestDataStream
{
21 // Fill |buffer| with |length| bytes of data from the stream.
22 void GetBytes(char* buffer
, int length
);
24 // Verify that |buffer| contains the expected next |length| bytes from the
25 // stream. Returns true if correct, false otherwise.
26 bool VerifyBytes(const char *buffer
, int length
);
28 // Resets all the data.
32 // If there is no data spilled over from the previous index, advance the
33 // index and fill the buffer.
36 // Consume data from the spill buffer.
37 void Consume(int bytes
);
47 #endif // NET_BASE_TEST_DATA_STREAM_H_