|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <vector> |
|
18 #include <algorithm> |
|
19 |
|
20 #include "cppunit/cppunit_proxy.h" |
|
21 |
|
22 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) |
|
23 using namespace std; |
|
24 #endif |
|
25 |
|
26 // |
|
27 // TestCase class |
|
28 // |
|
29 class FillTest : public CPPUNIT_NS::TestCase |
|
30 { |
|
31 CPPUNIT_TEST_SUITE(FillTest); |
|
32 CPPUNIT_TEST(fill1); |
|
33 CPPUNIT_TEST(filln1); |
|
34 CPPUNIT_TEST_SUITE_END(); |
|
35 |
|
36 protected: |
|
37 void fill1(); |
|
38 void filln1(); |
|
39 }; |
|
40 |
|
41 CPPUNIT_TEST_SUITE_REGISTRATION(FillTest); |
|
42 |
|
43 // |
|
44 // tests implementation |
|
45 // |
|
46 void FillTest::fill1() |
|
47 { |
|
48 vector <int> v(10); |
|
49 fill(v.begin(), v.end(), 42); |
|
50 |
|
51 CPPUNIT_ASSERT(v[0]==42); |
|
52 CPPUNIT_ASSERT(v[1]==42); |
|
53 CPPUNIT_ASSERT(v[2]==42); |
|
54 CPPUNIT_ASSERT(v[3]==42); |
|
55 CPPUNIT_ASSERT(v[4]==42); |
|
56 CPPUNIT_ASSERT(v[5]==42); |
|
57 CPPUNIT_ASSERT(v[6]==42); |
|
58 CPPUNIT_ASSERT(v[7]==42); |
|
59 CPPUNIT_ASSERT(v[8]==42); |
|
60 CPPUNIT_ASSERT(v[9]==42); |
|
61 } |
|
62 void FillTest::filln1() |
|
63 { |
|
64 vector <int> v(10); |
|
65 fill_n(v.begin(), v.size(), 42); |
|
66 |
|
67 CPPUNIT_ASSERT(v[0]==42); |
|
68 CPPUNIT_ASSERT(v[1]==42); |
|
69 CPPUNIT_ASSERT(v[2]==42); |
|
70 CPPUNIT_ASSERT(v[3]==42); |
|
71 CPPUNIT_ASSERT(v[4]==42); |
|
72 CPPUNIT_ASSERT(v[5]==42); |
|
73 CPPUNIT_ASSERT(v[6]==42); |
|
74 CPPUNIT_ASSERT(v[7]==42); |
|
75 CPPUNIT_ASSERT(v[8]==42); |
|
76 CPPUNIT_ASSERT(v[9]==42); |
|
77 } |