os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/modulus_test.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 #include <algorithm>
     2 #include <functional>
     3 
     4 #include "cppunit/cppunit_proxy.h"
     5 
     6 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
     7 using namespace std;
     8 #endif
     9 
    10 //
    11 // TestCase class
    12 //
    13 class ModulusTest : public CPPUNIT_NS::TestCase
    14 {
    15   CPPUNIT_TEST_SUITE(ModulusTest);
    16   CPPUNIT_TEST(modulus0);
    17   CPPUNIT_TEST_SUITE_END();
    18 
    19 protected:
    20   void modulus0();
    21 };
    22 
    23 CPPUNIT_TEST_SUITE_REGISTRATION(ModulusTest);
    24 
    25 //
    26 // tests implementation
    27 //
    28 void ModulusTest::modulus0()
    29 {
    30   int input1 [4] = { 6, 8, 10, 2 };
    31   int input2 [4] = { 4, 2, 11, 3 };
    32 
    33   int output [4];
    34 
    35   transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, modulus<int>());
    36   CPPUNIT_ASSERT(output[0]==2);
    37   CPPUNIT_ASSERT(output[1]==0);
    38   CPPUNIT_ASSERT(output[2]==10);
    39   CPPUNIT_ASSERT(output[3]==2);
    40 }