chromium/cc/base/list_container_unittest.cc

// Copyright 2014 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/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "cc/base/list_container.h"

#include <stddef.h>

#include <algorithm>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
namespace {

// Element class having derived classes.
class DerivedElement {};

class DerivedElement1 : public DerivedElement {};

class DerivedElement2 : public DerivedElement {};

class DerivedElement3 : public DerivedElement {};

const size_t kLargestDerivedElementSize =;
const size_t kLargestDerivedElementAlign =;

static_assert;
static_assert;
static_assert;
static_assert;

// Element class having no derived classes.
class NonDerivedElement {};

bool isConstNonDerivedElementPointer(const NonDerivedElement* ptr) {}

bool isConstNonDerivedElementPointer(NonDerivedElement* ptr) {}

const int kMagicNumberToUseForSimpleDerivedElementOne =;
const int kMagicNumberToUseForSimpleDerivedElementTwo =;
const int kMagicNumberToUseForSimpleDerivedElementThree =;

class SimpleDerivedElement : public DerivedElement {};

class SimpleDerivedElementConstructMagicNumberOne
    : public SimpleDerivedElement {};

class SimpleDerivedElementConstructMagicNumberTwo
    : public SimpleDerivedElement {};

class SimpleDerivedElementConstructMagicNumberThree
    : public SimpleDerivedElement {};

// This class' instances are moved by ListContainer via memcpy(). This behavior
// is not supported by gmock's FunctionMocker, so this class must roll its own
// mocking code.
class MockDerivedElement : public SimpleDerivedElementConstructMagicNumberOne {};

class MockDerivedElementSubclass : public MockDerivedElement {};

const size_t kCurrentLargestDerivedElementSize =;
const size_t kCurrentLargestDerivedElementAlign =;

TEST(ListContainerTest, ConstructorCalledInAllocateAndConstruct) {}

TEST(ListContainerTest, DestructorCalled) {}

TEST(ListContainerTest, DestructorCalledOnceWhenClear) {}

TEST(ListContainerTest, ClearDoesNotMalloc) {}

TEST(ListContainerTest, ReplaceExistingElement) {}

TEST(ListContainerTest, DestructorCalledOnceWhenErase) {}

TEST(ListContainerTest, SimpleIndexAccessNonDerivedElement) {}

TEST(ListContainerTest, SimpleInsertionNonDerivedElement) {}

TEST(ListContainerTest, SimpleInsertionAndClearNonDerivedElement) {}

TEST(ListContainerTest, SimpleInsertionClearAndInsertAgainNonDerivedElement) {}

// This test is used to test when there is more than one allocation needed
// for, ListContainer can still perform like normal vector.
TEST(ListContainerTest,
     SimpleInsertionTriggerMoreThanOneAllocationNonDerivedElement) {}

TEST(ListContainerTest,
     CorrectAllocationSizeForMoreThanOneAllocationNonDerivedElement) {}

TEST(ListContainerTest, SimpleIterationNonDerivedElement) {}

TEST(ListContainerTest, SimpleConstIteratorIterationNonDerivedElement) {}

TEST(ListContainerTest, SimpleReverseInsertionNonDerivedElement) {}

TEST(ListContainerTest, SimpleDeletion) {}

TEST(ListContainerTest, DeletionAllInAllocation) {}

TEST(ListContainerTest, DeletionAllInAllocationReversed) {}

TEST(ListContainerTest, DeletionWhileIterating) {}

TEST(ListContainerTest, InsertCopyBeforeBegin) {}

TEST(ListContainerTest, InsertCopyBeforeEnd) {}

TEST(ListContainerTest, InsertCopyBeforeEmpty) {}

TEST(ListContainerTest, InsertCopyBeforeMany) {}

TEST(ListContainerTest, InsertBeforeBegin) {}

TEST(ListContainerTest, InsertBeforeEnd) {}

TEST(ListContainerTest, InsertBeforeEmpty) {}

TEST(ListContainerTest, InsertBeforeMany) {}

TEST(ListContainerTest, InsertAfterBegin) {}

TEST(ListContainerTest, InsertAfterEnd) {}

TEST(ListContainerTest, InsertAfterEmpty) {}

TEST(ListContainerTest, InsertAfterMany) {}

TEST(ListContainerTest, SimpleManipulationWithIndexSimpleDerivedElement) {}

TEST(ListContainerTest,
     SimpleManipulationWithIndexMoreThanOneAllocationSimpleDerivedElement) {}

TEST(ListContainerTest,
     SimpleIterationAndReverseIterationWithIndexNonDerivedElement) {}

// Increments an int when constructed (or the counter pointer is supplied) and
// decrements when destructed.
class InstanceCounter {};

TEST(ListContainerTest, RemoveLastDestruction) {}

// TODO(jbroman): std::equal would work if ListContainer iterators satisfied the
// usual STL iterator constraints. We should fix that.
template <typename It1, typename It2>
bool Equal(It1 it1, const It1& end1, It2 it2) {}

TEST(ListContainerTest, RemoveLastIteration) {}

TEST(ListContainerTest, Swap) {}

TEST(ListContainerTest, GetCapacityInBytes) {}

}  // namespace
}  // namespace cc