summaryrefslogtreecommitdiffstats
path: root/base/pickle_unittest.cc
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 13:40:16 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 13:40:16 +0000
commitd26cd52757991911c111279e900d732ba283dd05 (patch)
tree1ed17eca0119921798175038aa8e3786902ebf57 /base/pickle_unittest.cc
parentf1f642879ba2c3e7edb3af50d70ea11286f3ae93 (diff)
downloadchromium_src-d26cd52757991911c111279e900d732ba283dd05.zip
chromium_src-d26cd52757991911c111279e900d732ba283dd05.tar.gz
chromium_src-d26cd52757991911c111279e900d732ba283dd05.tar.bz2
Some cross platform changes and general cleanups to Pickle.
- Clean up TrimWriteData, and remove the unneeded VariableLengthBuffer struct. Modify a test to slightly test TrimWriteData, but it probably deserves more. - Remove unneeded includes in pickle_unittest, including windows.h. - According to 3.5 of the C++ standard, CustomHeader could not be used as a template argument, because it had no linkage. This now builds on GCC. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pickle_unittest.cc')
-rw-r--r--base/pickle_unittest.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc
index 6780e21..4c38677 100644
--- a/base/pickle_unittest.cc
+++ b/base/pickle_unittest.cc
@@ -26,14 +26,13 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <windows.h>
-#include <string.h>
+
+#include <string>
#include "base/basictypes.h"
-#include "base/check_handler.h"
#include "base/logging.h"
-#include "base/scoped_ptr.h"
#include "base/pickle.h"
+#include "base/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -94,10 +93,13 @@ TEST(PickleTest, EncodeDecode) {
EXPECT_TRUE(pickle.WriteBool(testbool2));
EXPECT_TRUE(pickle.WriteData(testdata, testdatalen));
- char* dest = pickle.BeginWriteData(testdatalen);
+ // Over allocate BeginWriteData so we can test TrimWriteData.
+ char* dest = pickle.BeginWriteData(testdatalen + 100);
EXPECT_TRUE(dest);
memcpy(dest, testdata, testdatalen);
+ pickle.TrimWriteData(testdatalen);
+
VerifyResult(pickle);
// test copy constructor
@@ -206,11 +208,15 @@ TEST(PickleTest, Resize) {
EXPECT_EQ(cur_payload, pickle.payload_size());
}
-TEST(PickleTest, HeaderPadding) {
- struct CustomHeader : Pickle::Header {
- int blah;
- };
+namespace {
+struct CustomHeader : Pickle::Header {
+ int blah;
+};
+
+} // namespace
+
+TEST(PickleTest, HeaderPadding) {
const uint32 kMagic = 0x12345678;
Pickle pickle(sizeof(CustomHeader));
@@ -235,4 +241,4 @@ TEST(PickleTest, EqualsOperator) {
Pickle copy;
copy = copy_refs_source_buffer;
ASSERT_EQ(source.size(), copy.size());
-} \ No newline at end of file
+}