ReactOS 0.4.15-dev-7906-g1b85a5f
CAtlArray.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Test for CAtlArray
5 * COPYRIGHT: Copyright 2016-2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 * Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
7 */
8
9#ifdef HAVE_APITEST
10 #include <apitest.h>
11#else
12 #include "atltest.h"
13#endif
14
15#include <atlbase.h>
16#include <atlcoll.h>
17
19{
20 static int s_nCtorCount;
22 static int s_nCCtorCount;
23 static int s_nDtorCount;
24 static int s_nOpIsCount;
25
26 int m_id;
27
28 CCreature(int id = 0x123456)
29 :m_id(id)
30 {
32 if (id == 0x123456)
34 }
36 :m_id(c.m_id)
37 {
39 }
41 {
43 }
45 {
46 m_id = other.m_id;
48 return *this;
49 }
50};
51
57
58
60{
61 {
63
69
70 array1.SetCount(2);
71
77
78 array1.SetCount(1);
79
85
86 CCreature test(111);
87
93
94 ok_size_t(array1.GetCount(), 1u);
95 ok_int(array1[0].m_id, 0x123456);
96 ok_int(array1.GetAt(0).m_id, 0x123456);
97
98 array1.Add(test);
99
105
106 ok_size_t(array1.GetCount(), 2u);
107 ok_int(array1[0].m_id, 0x123456);
108 ok_int(array1.GetAt(0).m_id, 0x123456);
109 ok_int(array1[1].m_id, 111);
110 ok_int(array1.GetAt(1).m_id, 111);
111
112 test.m_id = 222;
113 array1[0] = test;
114
120
121 // Default traits does not call anything when relocating objects!
122 array1.SetCount(100);
123
129
130 // Does not compile:
131 //CAtlArray<CCreature> array2(array1);
132
133 // Does not compile:
134 //CAtlArray<CCreature> array2;
135 //array2 = array1;
136 }
137
138 // Objects are cleaned up when the list goes away
144}
#define ok_size_t(expression, result)
Definition: atltest.h:115
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
size_t Add(INARGTYPE element)
Definition: atlcoll.h:295
size_t GetCount() const
Definition: atlcoll.h:373
E & GetAt(size_t iElement)
Definition: atlcoll.h:395
bool SetCount(size_t nNewSize, int nGrowBy=- 1)
Definition: atlcoll.h:325
const GLubyte * c
Definition: glext.h:8905
GLuint id
Definition: glext.h:5910
int other
Definition: msacm.c:1376
#define test
Definition: rosglue.h:37
CCreature(int id=0x123456)
Definition: CAtlArray.cpp:28
CCreature & operator=(const CCreature &other)
Definition: CAtlArray.cpp:44
static int s_nCtorCount
Definition: CAtlArray.cpp:20
static int s_nOpIsCount
Definition: CAtlArray.cpp:24
static int s_nCtorCount_Default
Definition: CAtlArray.cpp:21
static int s_nDtorCount
Definition: CAtlArray.cpp:23
static int s_nCCtorCount
Definition: CAtlArray.cpp:22
CCreature(const CCreature &c)
Definition: CAtlArray.cpp:35