• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 PDFium 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 
5 #include "core/fxcrt/fx_memory_wrappers.h"
6 
7 #include <memory>
8 #include <vector>
9 
10 #include "build/build_config.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 
TEST(fxcrt,FxFreeDeleter)13 TEST(fxcrt, FxFreeDeleter) {
14   std::unique_ptr<int, FxFreeDeleter> empty(nullptr);
15   std::unique_ptr<int, FxFreeDeleter> thing(FX_Alloc(int, 1));
16   std::unique_ptr<int, FxFreeDeleter> several(FX_Alloc(int, 100));
17   EXPECT_FALSE(empty);
18   EXPECT_TRUE(thing);
19   EXPECT_TRUE(several);
20 }
21 
TEST(fxcrt,FxAllocAllocator)22 TEST(fxcrt, FxAllocAllocator) {
23   std::vector<int, FxAllocAllocator<int>> vec;
24   vec.push_back(42);
25   vec.reserve(100);
26   vec.resize(20);
27   vec[11] = 42;
28 
29   std::vector<int, FxAllocAllocator<int>> vec2 = vec;
30   vec = std::move(vec2);
31   vec2.resize(0);
32   vec2.push_back(42);
33 }
34