mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:23:07 +00:00
Create a branch for working on csrss and co.
svn path=/branches/ros-csrss/; revision=57561
This commit is contained in:
parent
679f8cec0e
commit
65ce146169
20047 changed files with 0 additions and 1175494 deletions
80
lib/3rdparty/stlport/test/unit/transform_test.cpp
vendored
Normal file
80
lib/3rdparty/stlport/test/unit/transform_test.cpp
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include <string>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "cppunit/cppunit_proxy.h"
|
||||
|
||||
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
//
|
||||
// TestCase class
|
||||
//
|
||||
class TransformTest : public CPPUNIT_NS::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TransformTest);
|
||||
CPPUNIT_TEST(trnsfrm1);
|
||||
CPPUNIT_TEST(trnsfrm2);
|
||||
CPPUNIT_TEST(self_str);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
protected:
|
||||
void trnsfrm1();
|
||||
void trnsfrm2();
|
||||
void self_str();
|
||||
|
||||
static int negate_int(int a_) {
|
||||
return -a_;
|
||||
}
|
||||
static char map_char(char a_, int b_) {
|
||||
return char(a_ + b_);
|
||||
}
|
||||
static char shift( char c ) {
|
||||
return char(((int)c + 1) % 256);
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TransformTest);
|
||||
|
||||
//
|
||||
// tests implementation
|
||||
//
|
||||
void TransformTest::trnsfrm1()
|
||||
{
|
||||
int numbers[6] = { -5, -1, 0, 1, 6, 11 };
|
||||
|
||||
int result[6];
|
||||
transform((int*)numbers, (int*)numbers + 6, (int*)result, negate_int);
|
||||
|
||||
CPPUNIT_ASSERT(result[0]==5);
|
||||
CPPUNIT_ASSERT(result[1]==1);
|
||||
CPPUNIT_ASSERT(result[2]==0);
|
||||
CPPUNIT_ASSERT(result[3]==-1);
|
||||
CPPUNIT_ASSERT(result[4]==-6);
|
||||
CPPUNIT_ASSERT(result[5]==-11);
|
||||
}
|
||||
void TransformTest::trnsfrm2()
|
||||
{
|
||||
#if defined (__MVS__)
|
||||
int trans[] = {-11, 4, -6, -6, -18, 0, 18, -14, 6, 0, -1, -59};
|
||||
#else
|
||||
int trans[] = {-4, 4, -6, -6, -10, 0, 10, -6, 6, 0, -1, -77};
|
||||
#endif
|
||||
char n[] = "Larry Mullen";
|
||||
const size_t count = ::strlen(n);
|
||||
|
||||
string res;
|
||||
transform(n, n + count, trans, back_inserter(res), map_char);
|
||||
CPPUNIT_ASSERT( res == "Hello World!" )
|
||||
}
|
||||
|
||||
void TransformTest::self_str()
|
||||
{
|
||||
string s( "0123456789abcdefg" );
|
||||
string r( "123456789:bcdefgh" );
|
||||
transform( s.begin(), s.end(), s.begin(), shift );
|
||||
CPPUNIT_ASSERT( s == r );
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue