chromium/base/pickle_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/pickle.h"

#include <limits.h>
#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <string>
#include <string_view>
#include <tuple>

#include "base/containers/heap_array.h"
#include "base/containers/span.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

namespace {

const bool testbool1 =;
const bool testbool2 =;
const int testint =;
const long testlong =;
const uint16_t testuint16 =;
const uint32_t testuint32 =;
const int64_t testint64 =;
const uint64_t testuint64 =;
const float testfloat =;
const double testdouble =;
const std::string teststring("Hello world");  // note non-aligned string length
const std::wstring testwstring(L"Hello, world");
const std::u16string teststring16(u"Hello, world");
const char testrawstring[] =; // Test raw string writing
// Test raw char16_t writing, assumes UTF16 encoding is ANSI for alpha chars.
const char16_t testrawstring16[] =;
const char testdata[] =;
const size_t testdatalen =;

// checks that the results can be read correctly from the Pickle
void VerifyResult(const Pickle& pickle) {}

}  // namespace

TEST(PickleTest, UnownedVsOwned) {}

TEST(PickleTest, EncodeDecode) {}

// Tests that reading/writing a long works correctly when the source process
// is 64-bit.  We rely on having both 32- and 64-bit trybots to validate both
// arms of the conditional in this test.
TEST(PickleTest, LongFrom64Bit) {}

// Tests that we can handle really small buffers.
TEST(PickleTest, SmallBuffer) {}

// Tests that we can handle improper headers.
TEST(PickleTest, BigSize) {}

// Tests that instances constructed with invalid parameter combinations can be
// properly copied. Regression test for https://crbug.com/1271311.
TEST(PickleTest, CopyWithInvalidHeader) {}

TEST(PickleTest, UnalignedSize) {}

TEST(PickleTest, ZeroLenStr) {}

TEST(PickleTest, ZeroLenStr16) {}

TEST(PickleTest, BadLenStr) {}

TEST(PickleTest, BadLenStr16) {}

TEST(PickleTest, PeekNext) {}

TEST(PickleTest, PeekNextOverflow) {}

TEST(PickleTest, FindNext) {}

TEST(PickleTest, FindNextWithIncompleteHeader) {}

#if defined(COMPILER_MSVC)
#pragma warning(push)
#pragma warning(disable: 4146)
#endif
TEST(PickleTest, FindNextOverflow) {}
#if defined(COMPILER_MSVC)
#pragma warning(pop)
#endif

TEST(PickleTest, GetReadPointerAndAdvance) {}

TEST(PickleTest, Resize) {}

namespace {

struct CustomHeader : Pickle::Header {};

}  // namespace

TEST(PickleTest, HeaderPadding) {}

TEST(PickleTest, EqualsOperator) {}

TEST(PickleTest, EvilLengths) {}

// Check we can write zero bytes of data and 'data' can be NULL.
TEST(PickleTest, ZeroLength) {}

// Check that ReadBytes works properly with an iterator initialized to NULL.
TEST(PickleTest, ReadBytes) {}

// Checks that when a pickle is deep-copied, the result is not larger than
// needed.
TEST(PickleTest, DeepCopyResize) {}

namespace {

// Publicly exposes the ClaimBytes interface for testing.
class TestingPickle : public Pickle {};

}  // namespace

// Checks that claimed bytes are zero-initialized.
TEST(PickleTest, ClaimBytesInitialization) {}

// Checks that ClaimBytes properly advances the write offset.
TEST(PickleTest, ClaimBytes) {}

TEST(PickleTest, ReachedEnd) {}

// Test that reading a value other than 0 or 1 as a bool does not trigger
// UBSan.
TEST(PickleTest, NonCanonicalBool) {}

}  // namespace base