16#include <initializer_list>
27 TestClass() =
default;
28 TestClass(
const TestClass&) =
default;
29 TestClass& operator=(
const TestClass&) =
default;
30 TestClass(
int v) :
value(v) {}
31 virtual ~TestClass() {}
43template <
typename ArrayType>
45 using T =
typename ArrayType::value_type;
71 T b[5] = {
T{0},
T{1},
T{2},
T{3},
T{4}};
94 using ValueType =
typename T::value_type;
108 arrayInitial.push_back(ValueType{1});
109 arrayInitial.push_back(ValueType{2});
110 arrayInitial.push_back(ValueType{3});
112 T arrayCopy(arrayInitial);
123 T arrayMove(std::move(arrayInitial));
124 if (hasMoveSemantics) {
133 typename T::value_type
data[3] = { 7, 8, 9 };
134 T arrayPtrCount(
data, 3);
141 T arrayInitializer{8, 6, 7, 5, 3, 0, 9};
152template <
typename T,
typename U>
176 arrayAssignment = tArray;
187 U arrayMove(std::move(tArray));
196 arrayMoveAssign = std::move(tArray2);
207 MoveOnlyInt(
int i) : fInt(
i) {}
208 MoveOnlyInt(MoveOnlyInt&& that) : fInt(that.fInt) {}
217 for (
auto a : arrays) {
218 for (
auto b : arrays) {
223 for (
auto sizeA : sizes) {
224 for (
auto sizeB : sizes) {
229 for (
int i = 0;
i < sizeA;
i++) {
a->push_back(curr++); }
230 for (
int i = 0;
i < sizeB;
i++) {
b->push_back(curr++); }
248 static constexpr int kSizes[] = {0, 1, 5, 10, 15, 20, 25};
254 TArray<int>* arrays[] = { &arr, &arr5, &arr10, &arr20 };
269 for (
auto a : arrays) {
270 for (
auto sizeA : sizes) {
272 for (
int i = 0;
i < sizeA;
i++) {
a->push_back(
i); }
275 for (
int i = 0;
i < sizeA;
i++) {
281 for (
auto a : arrays) {
282 for (
auto b : arrays) {
287 for (
auto sizeA : sizes) {
288 for (
auto sizeB : sizes) {
293 for (
int i = 0;
i < sizeA;
i++) {
a->push_back(curr++); }
294 for (
int i = 0;
i < sizeB;
i++) {
b->push_back(curr++); }
307 static constexpr int kSizes[] = {0, 1, 5, 10, 15, 20, 25};
313 TArray<int>* arrays[] = { &arr, &arr5, &arr10, &arr20 };
382template <
typename ArrayType>
390 a =
static_cast<ArrayType&
>(
a);
397 test_self_assignment<TArray<int>>(
reporter);
398 test_self_assignment<STArray<3, unsigned short>>(
reporter);
402 test_self_assignment<FixedArray<1, int>>(
reporter);
403 test_self_assignment<FixedArray<4, unsigned short>>(
reporter);
406template <
typename ArrayType>
408 using T =
typename ArrayType::value_type;
416 for (
int x = 0;
x < 10; ++
x) {
424 for (
int x = 0;
x < 10; ++
x) {
434 for (
int x = 0;
x < 10; ++
x) {
445 test_comparison<TArray<int>>(
reporter);
446 test_comparison<TArray<double>>(
reporter);
447 test_comparison<TArray<TestClass>>(
reporter);
448 test_comparison<STArray<1, int>>(
reporter);
449 test_comparison<STArray<5, char>>(
reporter);
450 test_comparison<STArray<7, TestClass>>(
reporter);
451 test_comparison<STArray<10, float>>(
reporter);
455 test_comparison<FixedArray<15, int>>(
reporter);
456 test_comparison<FixedArray<20, char>>(
reporter);
457 test_comparison<FixedArray<25, float>>(
reporter);
461 Array* array,
int reserveCount) {
468 while (array->size() < reserveCount) {
472 }
else if (array->size() > 0) {
482 for (
int reserveCount : {1, 2, 10, 100}) {
484 Array array1(reserveCount);
489 array2.reserve(reserveCount);
493 Array array3(reserveCount/2);
494 array3.reserve(reserveCount);
499 array4.push_back_n(reserveCount);
500 array4.reserve(2 * reserveCount);
501 array4.pop_back_n(reserveCount);
510 for (
int x=0;
x<50; ++
x) {
511 a.push_back(
a.front());
513 for (
int x=0;
x<50; ++
x) {
514 a.push_back(
a.back());
529 a.emplace_back(12345);
530 for (
int x=0;
x<50; ++
x) {
531 a.emplace_back(
a.front().fValue);
533 for (
int x=0;
x<50; ++
x) {
534 a.emplace_back(
a.back().fValue);
539 return s.fValue == 12345;
545 TestTSet_basic<TArray<int, true>>(
reporter);
546 TestTSet_basic<TArray<int, false>>(
reporter);
549 TestTSet_basic<TArray<TestClass, false>>(
reporter);
553 TestTSet_basic<FixedArray<5, char>>(
reporter);
554 TestTSet_basic<FixedArray<7, int>>(
reporter);
555 TestTSet_basic<FixedArray<100, double>>(
reporter);
559 test_reserve<TArray<int>>(
reporter);
560 test_reserve<STArray<1, int>>(
reporter);
561 test_reserve<STArray<2, int>>(
reporter);
562 test_reserve<STArray<16, int>>(
reporter);
564 test_reserve<TArray<TestClass>>(
reporter);
565 test_reserve<STArray<1, TestClass>>(
reporter);
566 test_reserve<STArray<2, TestClass>>(
reporter);
567 test_reserve<STArray<16, TestClass>>(
reporter);
571 test_construction<TArray<int>>(
reporter);
572 test_construction<TArray<double>>(
reporter);
573 test_construction<TArray<TestClass>>(
reporter);
574 test_construction<STArray<1, int>>(
reporter);
575 test_construction<STArray<5, char>>(
reporter);
576 test_construction<STArray<7, TestClass>>(
reporter);
577 test_construction<STArray<10, float>>(
reporter);
581 test_construction<FixedArray<15, int>>(
reporter,
false);
582 test_construction<FixedArray<20, char>>(
reporter,
false);
583 test_construction<FixedArray<25, float>>(
reporter,
false);
587 test_inner_push<TArray<int>>(
reporter);
588 test_inner_push<STArray<1, int>>(
reporter);
589 test_inner_push<STArray<99, int>>(
reporter);
590 test_inner_push<STArray<200, int>>(
reporter);
594 test_inner_push<FixedArray<101, int>>(
reporter);
595 test_inner_push<FixedArray<150, short>>(
reporter);
596 test_inner_push<FixedArray<250, double>>(
reporter);
600 test_inner_emplace<TArray<EmplaceStruct>>(
reporter);
601 test_inner_emplace<STArray<1, EmplaceStruct>>(
reporter);
602 test_inner_emplace<STArray<99, EmplaceStruct>>(
reporter);
603 test_inner_emplace<STArray<200, EmplaceStruct>>(
reporter);
626#if defined(SK_SANITIZE_ADDRESS)
628template <
typename Array>
630 int allocated = array.
size() *
sizeof(
typename Array::value_type);
631 int capacity = array.capacity() *
sizeof(
typename Array::value_type);
632 const std::byte*
data =
reinterpret_cast<const std::byte*
>(array.data());
634 for (
int index = 0; index < allocated; ++index) {
642 for (
int index = allocated; index < capacity; ++index) {
647template <
typename Array>
651 for (
int index = 0; index < 20; ++index) {
652 array.emplace_back();
656 for (
int index = 0; index < 20; ++index) {
661 for (
int index = 0; index < 20; ++index) {
662 array.reserve(array.capacity() + 3);
672 test_poison<STArray<1, double>>(
reporter);
673 test_poison<STArray<2, char>>(
reporter);
674 test_poison<STArray<16, TestClass>>(
reporter);
static int sk_asan_address_is_poisoned(void const volatile *addr)
static void test_reserve(skiatest::Reporter *reporter)
static void test_array_reserve(skiatest::Reporter *reporter, Array *array, int reserveCount)
static void test_construction(skiatest::Reporter *reporter, bool hasMoveSemantics=true)
static void test_comparison(skiatest::Reporter *reporter)
static void test_inner_emplace(skiatest::Reporter *reporter)
static void test_swap(skiatest::Reporter *reporter, SkSpan< TArray< T > * > arrays, SkSpan< const int > sizes)
static void test_inner_push(skiatest::Reporter *reporter)
static void TestTSet_basic(skiatest::Reporter *reporter)
static void test_array_move(skiatest::Reporter *reporter, SkSpan< TArray< T > * > arrays, SkSpan< const int > sizes)
DEF_TEST(TArray_Swap, reporter)
static void test_starray_compatibility(skiatest::Reporter *reporter)
static void test_self_assignment(skiatest::Reporter *reporter)
#define REPORTER_ASSERT(r, cond,...)
uint32_t nextULessThan(uint32_t count)
static const size_t kSizes[]
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
bool operator!=(C p1, const scoped_nsprotocol< C > &p2)
std::shared_ptr< const fml::Mapping > data