1 #include <algorithm>
2 #include <iterator>
3 #include <memory>
4 
5 #include "cppunit/cppunit_proxy.h"
6 
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8 using namespace std;
9 #endif
10 
11 class X
12 {
13   public:
14     X(int i_ = 0) : i(i_) {}
15     ~X() {}
16     operator int() const { return i; }
17 
18   private:
19     int i;
20 };
21 
22 
23 //
24 // TestCase class
25 //
26 class RawriterTest : public CPPUNIT_NS::TestCase
27 {
28   CPPUNIT_TEST_SUITE(RawriterTest);
29   CPPUNIT_TEST(rawiter1);
30   CPPUNIT_TEST_SUITE_END();
31 
32 protected:
33   void rawiter1();
34 };
35 
36 CPPUNIT_TEST_SUITE_REGISTRATION(RawriterTest);
37 
38 //
39 // tests implementation
40 //
41 void RawriterTest::rawiter1()
42 {
43   allocator<X> a;
44   typedef X* x_pointer;
45   x_pointer save_p, p;
46   p = a.allocate(5);
47   save_p=p;
48   raw_storage_iterator<X*, X> r(p);
49   int i;
50   for(i = 0; i < 5; i++)
51     *r++ = X(i);
52 
53   CPPUNIT_ASSERT(*p++ == 0);
54   CPPUNIT_ASSERT(*p++ == 1);
55   CPPUNIT_ASSERT(*p++ == 2);
56   CPPUNIT_ASSERT(*p++ == 3);
57   CPPUNIT_ASSERT(*p++ == 4);
58 
59 //#if defined (STLPORT) || defined (__GNUC__)
60   a.deallocate(save_p, 5);
61 /*
62 #else
63   a.deallocate(save_p);
64 #endif
65 */
66 }
67