ReactOS 0.4.15-dev-7961-gdcf9eb0
transform_test.cpp
Go to the documentation of this file.
1#include <string>
2#include <iterator>
3#include <vector>
4#include <algorithm>
5
7
8#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
9using namespace std;
10#endif
11
12//
13// TestCase class
14//
15class TransformTest : public CPPUNIT_NS::TestCase
16{
22
23protected:
24 void trnsfrm1();
25 void trnsfrm2();
26 void self_str();
27
28 static int negate_int(int a_) {
29 return -a_;
30 }
31 static char map_char(char a_, int b_) {
32 return char(a_ + b_);
33 }
34 static char shift( char c ) {
35 return char(((int)c + 1) % 256);
36 }
37};
38
40
41//
42// tests implementation
43//
45{
46 int numbers[6] = { -5, -1, 0, 1, 6, 11 };
47
48 int result[6];
49 transform((int*)numbers, (int*)numbers + 6, (int*)result, negate_int);
50
54 CPPUNIT_ASSERT(result[3]==-1);
55 CPPUNIT_ASSERT(result[4]==-6);
56 CPPUNIT_ASSERT(result[5]==-11);
57}
59{
60#if defined (__MVS__)
61 int trans[] = {-11, 4, -6, -6, -18, 0, 18, -14, 6, 0, -1, -59};
62#else
63 int trans[] = {-4, 4, -6, -6, -10, 0, 10, -6, 6, 0, -1, -77};
64#endif
65 char n[] = "Larry Mullen";
66 const size_t count = ::strlen(n);
67
68 string res;
70 CPPUNIT_ASSERT( res == "Hello World!" )
71}
72
74{
75 string s( "0123456789abcdefg" );
76 string r( "123456789:bcdefgh" );
77 transform( s.begin(), s.end(), s.begin(), shift );
78 CPPUNIT_ASSERT( s == r );
79}
80
back_insert_iterator< _Container > _STLP_CALL back_inserter(_Container &__x)
Definition: _iterator.h:187
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
CPPUNIT_TEST(trnsfrm1)
CPPUNIT_TEST(self_str)
static int negate_int(int a_)
static char map_char(char a_, int b_)
CPPUNIT_TEST(trnsfrm2)
CPPUNIT_TEST_SUITE(TransformTest)
static char shift(char c)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
unsigned char
Definition: typeof.h:29
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLuint res
Definition: glext.h:9613
const GLubyte * c
Definition: glext.h:8905
GLuint64EXT * result
Definition: glext.h:11304
#define shift
Definition: input.c:1755
Definition: features.h:417