ReactOS 0.4.15-dev-8119-g4fb2fdb
CSimpleArray.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for CSimpleArray
5 * PROGRAMMER: Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#ifdef HAVE_APITEST
9 #include <apitest.h>
10#else
11 #include "atltest.h"
12#endif
13
14#include <atlbase.h>
15#include <atlsimpcoll.h>
16
17struct CCreature
18{
19 static int s_nCount;
20 static int s_nCopyCount;
22 {
24 }
26 {
28 }
30 {
32 }
34 {
36 return *this;
37 }
38};
39
42
43
45{
46 CSimpleArray<int> array1;
47
48 ok_int(array1.GetSize(), 0);
49
50 array1.Add(123);
51
52 ok_int(array1.GetSize(), 1);
53 ok_int(array1.GetData()[0], 123);
54 ok_int(array1[0], 123);
55
56 array1.Add(456);
57
58 ok_int(array1.GetSize(), 2);
59 ok_int(array1.GetData()[0], 123);
60 ok_int(array1[0], 123);
61 ok_int(array1.GetData()[1], 456);
62 ok_int(array1[1], 456);
63
64 array1.RemoveAll();
65 ok_int(array1.GetSize(), 0);
66
67 array1.Add(1);
68 array1.Add(1);
69 array1.Add(1);
70 array1.Add(2);
71 array1.Add(2);
72 array1.Add(3);
73 ok_int(array1.GetSize(), 6);
74
75 array1.Remove(2);
76 ok_int(array1.GetSize(), 5);
77
78 array1.Remove(1);
79 ok_int(array1.GetSize(), 4);
80
81 ok_int(array1[0], 1);
82 ok_int(array1[1], 1);
83 ok_int(array1[2], 2);
84 ok_int(array1[3], 3);
85
88
90 {
91 CCreature creature1, creature2;
92
95 array2.Add(creature1);
98 array2.Add(creature2);
101 }
104
105 {
106 CSimpleArray<CCreature> array3(array2), array4, array5;
109
110 array4 = array2;
113
114 CCreature creature1;
117
118 array4.Add(creature1);
121
122 array3 = array4;
125
126 array5 = array2;
129
130 array5 = array2;
133 }
136
137 array2.RemoveAll();
140
141 array1.RemoveAll();
142 ok_int(array1.GetSize(), 0);
143 for (int i = 0; i < 100; ++i)
144 {
145 array1.Add(i);
146 }
147 ok_int(array1.GetSize(), 100);
148
149 array1.RemoveAll();
150 ok_int(array1.GetSize(), 0);
151 array1.Add(123);
152 array1.Add(321);
153 ok(!!array1.RemoveAt(0), "Expected RemoveAt(0) to succeed\n");
154 ok_int(array1.GetSize(), 1);
155 if (array1.GetSize() == 1)
156 {
157 ok_int(array1[0], 321);
158 }
159 ok(!!array1.RemoveAt(0), "Expected RemoveAt(0) to succeed\n");
160 ok_int(array1.GetSize(), 0);
161}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int other
Definition: msacm.c:1376
static int s_nCopyCount
CCreature & operator=(const CCreature &other)
static int s_nCount
CCreature(const CCreature &c)