Flutter Engine
The Flutter Engine
Classes | Functions
SkContainersTest.cpp File Reference
#include "include/private/base/SkContainers.h"
#include "tests/Test.h"
#include <algorithm>
#include <climits>
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Classes

struct  SkContainerAllocatorTestingPeer
 

Functions

static int max_capacity (size_t sizeOfT)
 
 DEF_TEST (SkContainerAllocatorBasic, reporter)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( SkContainerAllocatorBasic  ,
reporter   
)

Definition at line 30 of file SkContainersTest.cpp.

30 {
31
32 /* Comment out until a solution can be found.
33 // The following test drive the 32-bit machines out of memory so skip them.
34 if constexpr (SIZE_MAX > UINT_MAX) {
35 {
36 SkContainerAllocator a{1, max_capacity(1)};
37
38 SkSpan<std::byte> span = a.allocate(0, 1.0);
39 REPORTER_ASSERT(reporter, span.empty());
40 sk_free(span.data());
41
42 span = a.allocate(0, 1.5);
43 REPORTER_ASSERT(reporter, span.empty());
44 sk_free(span.data());
45
46 span = a.allocate(max_capacity(1), 1.0);
47 REPORTER_ASSERT(reporter, span.size() >= SkToSizeT(max_capacity(1)));
48 sk_free(span.data());
49 }
50
51 {
52 SkContainerAllocator a{16, max_capacity(16)};
53
54 SkSpan<std::byte> span = a.allocate(0, 1.0);
55 REPORTER_ASSERT(reporter, span.empty());
56 sk_free(span.data());
57
58 span = a.allocate(0, 1.5);
59 REPORTER_ASSERT(reporter, span.empty());
60 sk_free(span.data());
61
62 span = a.allocate(max_capacity(16), 1.0);
63 REPORTER_ASSERT(reporter, span.size() >= SkToSizeT(max_capacity(16)) * 16);
64 sk_free(span.data());
65 }
66 } // end skipped on 32-bit Windows tests.
67 */
68
69 for (int i = 1; i < 33; ++i) {
73
76
79 }
80
81 for (int i = 1; i < 33; ++i) {
85
88
91 }
92}
reporter
Definition: FontMgrTest.cpp:39
static int max_capacity(size_t sizeOfT)
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
struct MyStruct a[10]
static constexpr int64_t kCapacityMultiple
static size_t GrowthFactorCapacity(const SkContainerAllocator &a, int capacity, double growthFactor)
static size_t RoundUpCapacity(const SkContainerAllocator &a, int64_t capacity)

◆ max_capacity()

static int max_capacity ( size_t  sizeOfT)
static

Definition at line 26 of file SkContainersTest.cpp.

26 {
27 return std::min(SIZE_MAX / sizeOfT, (size_t)INT_MAX);
28}
static float min(float r, float g, float b)
Definition: hsl.cpp:48