any_internal_unittest.cc 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2019 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.
  4. #include "base/containers/any_internal.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. namespace base {
  7. namespace internal {
  8. namespace {
  9. struct OutOfLineStruct {
  10. void* one;
  11. void* two;
  12. void* three;
  13. void* four;
  14. };
  15. } // namespace
  16. TEST(AnyInternalTest, InlineOrOutlineStorage) {
  17. static_assert(AnyInternal::InlineStorageHelper<int>::kUseInlineStorage,
  18. "int should be stored inline");
  19. static_assert(AnyInternal::InlineStorageHelper<int*>::kUseInlineStorage,
  20. "int* should be stored inline");
  21. static_assert(
  22. AnyInternal::InlineStorageHelper<std::unique_ptr<int>>::kUseInlineStorage,
  23. "std::unique_ptr<int> should be stored inline");
  24. static_assert(
  25. !AnyInternal::InlineStorageHelper<OutOfLineStruct>::kUseInlineStorage,
  26. "A struct with four pointers should be stored out of line");
  27. }
  28. } // namespace internal
  29. } // namespace base