ReactOS 0.4.16-dev-336-gb667d82
count_test.cpp
Go to the documentation of this file.
1#include <algorithm>
2#include <vector>
4
5#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
6using namespace std;
7#endif
8
9//
10// TestCase class
11//
12class CountTest : public CPPUNIT_NS::TestCase
13{
19
20protected:
21 void count0();
22 void count1();
23 void countif1();
24 static int odd(int a_);
25};
26
28
29//
30// tests implementation
31//
33{
34 int numbers[10] = { 1, 2, 4, 1, 2, 4, 1, 2, 4, 1 };
35
36 int result = count(numbers, numbers + 10, 1);
38#if defined (STLPORT) && !defined (_STLP_NO_ANACHRONISMS)
39 result = 0;
40 count(numbers, numbers + 10, 1, result);
42#endif
43}
45{
46 vector <int> numbers(100);
47 for(int i = 0; i < 100; i++)
48 numbers[i] = i % 3;
49 int elements = count(numbers.begin(), numbers.end(), 2);
50 CPPUNIT_ASSERT(elements==33);
51#if defined (STLPORT) && !defined (_STLP_NO_ANACHRONISMS)
52 elements = 0;
53 count(numbers.begin(), numbers.end(), 2, elements);
54 CPPUNIT_ASSERT(elements==33);
55#endif
56}
58{
59 vector <int> numbers(100);
60 for(int i = 0; i < 100; i++)
61 numbers[i] = i % 3;
62 int elements = count_if(numbers.begin(), numbers.end(), odd);
63 CPPUNIT_ASSERT(elements==33);
64#if defined (STLPORT) && !defined (_STLP_NO_ANACHRONISMS)
65 elements = 0;
66 count_if(numbers.begin(), numbers.end(), odd, elements);
67 CPPUNIT_ASSERT(elements==33);
68#endif
69}
70int CountTest::odd(int a_)
71{
72 return a_ % 2;
73}
_STLP_INLINE_LOOP void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size &__n)
Definition: _algo.h:115
CPPUNIT_TEST(countif1)
static int odd(int a_)
Definition: count_test.cpp:70
CPPUNIT_TEST(count1)
void count0()
Definition: count_test.cpp:32
CPPUNIT_TEST_SUITE(CountTest)
void countif1()
Definition: count_test.cpp:57
CPPUNIT_TEST(count0)
void count1()
Definition: count_test.cpp:44
CPPUNIT_TEST_SUITE_END()
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
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
Definition: features.h:417
Definition: unary.h:11