xref: /aosp_15_r20/external/cronet/base/containers/any_internal_unittest.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/containers/any_internal.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace base {
10 namespace internal {
11 
12 namespace {
13 struct OutOfLineStruct {
14   void* one;
15   void* two;
16   void* three;
17   void* four;
18 };
19 }  // namespace
20 
TEST(AnyInternalTest,InlineOrOutlineStorage)21 TEST(AnyInternalTest, InlineOrOutlineStorage) {
22   static_assert(AnyInternal::InlineStorageHelper<int>::kUseInlineStorage,
23                 "int should be stored inline");
24   static_assert(AnyInternal::InlineStorageHelper<int*>::kUseInlineStorage,
25                 "int* should be stored inline");
26   static_assert(
27       AnyInternal::InlineStorageHelper<std::unique_ptr<int>>::kUseInlineStorage,
28       "std::unique_ptr<int> should be stored inline");
29   static_assert(
30       !AnyInternal::InlineStorageHelper<OutOfLineStruct>::kUseInlineStorage,
31       "A struct with four pointers should be stored out of line");
32 }
33 
34 }  // namespace internal
35 }  // namespace base
36