ReactOS  0.4.15-dev-499-g1f31905
innerprod_test.cpp
Go to the documentation of this file.
1 #include <vector>
2 #include <algorithm>
3 #include <numeric>
4 
6 
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8 using namespace std;
9 #endif
10 
11 //
12 // TestCase class
13 //
14 class InnerprodTest : public CPPUNIT_NS::TestCase
15 {
17  CPPUNIT_TEST(inprod0);
18  CPPUNIT_TEST(inprod1);
19  CPPUNIT_TEST(inprod2);
21 
22 protected:
23  void inprod0();
24  void inprod1();
25  void inprod2();
26 
27  static size_t add(size_t a_, size_t b_) {
28  return a_ + b_;
29  }
30 
31  static size_t mult(size_t a_, size_t b_) {
32  return a_ * b_;
33  }
34 };
35 
37 
38 //
39 // tests implementation
40 //
42 {
43  int vector1[5] = { 1, 2, 3, 4, 5 };
44  int vector2[5] = { 1, 2, 3, 4, 5 };
45 
46  int result;
47  result = inner_product(vector1, vector1 + 5, vector2, 0);
49 }
51 {
52  vector<size_t> v1(3);
53  vector<size_t> v2(v1.size());
54  for (size_t i = 0; i < v1.size(); ++i) {
55  v1[i] = i + 1;
56  v2[i] = v1.size() - i;
57  }
58  size_t result = inner_product(v1.begin(), v1.end(), v2.begin(), (size_t)0);
59  CPPUNIT_ASSERT(result == 10);
60 }
62 {
63  vector<size_t> v1(3);
64  vector<size_t> v2(v1.size());
65  for(size_t i = 0; i < v1.size(); ++i) {
66  v1[i] = i + 1;
67  v2[i] = v1.size() - i;
68  }
69  size_t result=inner_product(v1.begin(), v1.end(), v2.begin(), (size_t)1, mult, add);
70 
71  CPPUNIT_ASSERT(result == 64);
72 }
int add
Definition: i386-dis.c:3122
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
Definition: features.h:417
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
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
_STLP_INLINE_LOOP _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp _Init)
Definition: _numeric.h:61
__kernel_size_t size_t
Definition: linux.h:237
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
static size_t mult(size_t a_, size_t b_)
CPPUNIT_TEST_SUITE_REGISTRATION(InnerprodTest)
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat v1
Definition: glext.h:6062
static size_t add(size_t a_, size_t b_)