mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 02:15:43 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
73
sdk/lib/3rdparty/stlport/test/unit/rndshf_test.cpp
vendored
Normal file
73
sdk/lib/3rdparty/stlport/test/unit/rndshf_test.cpp
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "iota.h"
|
||||
#include "cppunit/cppunit_proxy.h"
|
||||
|
||||
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
//
|
||||
// TestCase class
|
||||
//
|
||||
class RndShuffleTest : public CPPUNIT_NS::TestCase
|
||||
{
|
||||
class MyRandomGenerator
|
||||
{
|
||||
public:
|
||||
unsigned long operator()(unsigned long n_)
|
||||
{
|
||||
return rand() % n_;
|
||||
}
|
||||
};
|
||||
CPPUNIT_TEST_SUITE(RndShuffleTest);
|
||||
CPPUNIT_TEST(rndshuf0);
|
||||
CPPUNIT_TEST(rndshuf2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
protected:
|
||||
void rndshuf0();
|
||||
void rndshuf2();
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(RndShuffleTest);
|
||||
|
||||
//
|
||||
// tests implementation
|
||||
//
|
||||
void RndShuffleTest::rndshuf0()
|
||||
{
|
||||
int numbers[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
random_shuffle(numbers, numbers + 6);
|
||||
|
||||
CPPUNIT_ASSERT(count(numbers, numbers+6, 1)==1);
|
||||
CPPUNIT_ASSERT(count(numbers, numbers+6, 2)==1);
|
||||
CPPUNIT_ASSERT(count(numbers, numbers+6, 3)==1);
|
||||
CPPUNIT_ASSERT(count(numbers, numbers+6, 4)==1);
|
||||
CPPUNIT_ASSERT(count(numbers, numbers+6, 5)==1);
|
||||
CPPUNIT_ASSERT(count(numbers, numbers+6, 6)==1);
|
||||
}
|
||||
void RndShuffleTest::rndshuf2()
|
||||
{
|
||||
vector <int> v1(10);
|
||||
__iota(v1.begin(), v1.end(), 0);
|
||||
|
||||
MyRandomGenerator r;
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
random_shuffle(v1.begin(), v1.end(), r);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 0)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 1)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 2)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 3)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 4)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 5)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 6)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 7)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 8)==1);
|
||||
CPPUNIT_ASSERT(count(v1.begin(), v1.end(), 9)==1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue