Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 LOCAL_D CTrapCleanup* TheTrapCleanup;
22 LOCAL_D RTest test(_L("T_CLIENT"));
24 LOCAL_D const TPtrC KColName(_S("A_column_name"));
25 LOCAL_D TDbColName VarName(_S("Column_A"));
27 const TInt KTestCleanupStack=0x20;
28 const TInt KLeaveError=-4000;
29 const TInt KColCount=26;
32 @SYMTestCaseID SYSLIB-DBMS-CT-0586
33 @SYMTestCaseDesc Tests for TDbCol class
34 @SYMTestPriority Medium
35 @SYMTestActions Tests for column name and type after creating them.
36 @SYMTestExpectedResults Test must not fail
39 LOCAL_C void TestTDbCol()
41 test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0586 Testing TDbCol "));
42 TDbCol c1(KColName,EDbColText8);
43 test(c1.iName==KColName);
44 test(c1.iType==EDbColText8);
45 test(c1.iMaxLength==KDbDefaultTextColLength);
46 test(c1.iAttributes==0);
47 TDbCol c2(KColName,EDbColText8,1234);
48 test(c2.iName==KColName);
49 test(c2.iType==EDbColText8);
50 test(c2.iMaxLength==1234);
51 test(c2.iAttributes==0);
52 TDbCol c3(KColName,EDbColBit);
53 test(c3.iName==KColName);
54 test(c3.iType==EDbColBit);
55 test(c3.iMaxLength==KDbUndefinedLength);
56 test(c3.iAttributes==0);
60 @SYMTestCaseID SYSLIB-DBMS-CT-0587
61 @SYMTestCaseDesc CDbColSet class test
62 @SYMTestPriority Medium
63 @SYMTestActions Tests for creation of a CDbColSet column set object
64 Tests for adding and removing columns to the column set
65 @SYMTestExpectedResults Test must not fail
68 LOCAL_C void TestCDbColSet()
71 test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0587 ctor and dtor "));
72 CDbColSet* c=CDbColSet::NewL(); // assume it will succeed
79 TRAP(r,c=CDbColSet::NewL());
87 CleanupStack::PopAndDestroy();
90 TDbCol col(KColName,EDbColText,20);
94 TRAP(r,c=CDbColSet::NewLC();c->AddL(col);User::Leave(KLeaveError););
98 test.Next(_L("Add columns"));
101 for (ii=1;ii<=KColCount;ii++)
103 VarName[7]=(TUint8)('A'-1+ii);
104 test(c->Col(VarName)==NULL);
105 TDbCol column(VarName,EDbColInt32);
107 test(c->Count()==ii);
108 test(c->ColNo(VarName)!=KDbNullColNo);
109 test(c->Col(VarName)!=NULL);
111 test.Next(_L("Check columns: operator[] and ColNo()"));
112 for (ii=1;ii<=KColCount;ii++)
114 const TDbCol& col=(*c)[ii];
115 test(c->ColNo(col.iName)==ii);
117 test.Next(_L("Remove columns"));
118 for (ii=1;ii<=KColCount;ii+=2)
120 VarName[7]=(TUint8)('A'-1+ii);
123 test(c->Count()==13);
124 test.Next(_L("Clear"));
127 CleanupStack::PopAndDestroy();
133 @SYMTestCaseID SYSLIB-DBMS-CT-0588
134 @SYMTestCaseDesc Tests for TDbColSetIter class
135 @SYMTestPriority Medium
136 @SYMTestActions Tests for iterate over the contents of a column set
137 @SYMTestExpectedResults Test must not fail
140 LOCAL_C void TestTDbColSetIter()
142 test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0588 Testing TDbColSetIter "));
143 CDbColSet* c=CDbColSet::NewLC();
145 for (ii=0;ii<KColCount;++ii)
147 VarName[7]=(TUint8)('A'-1+ii);
148 c->AddL(TDbCol(VarName,EDbColInt32));
150 TDbColSetIter iter1(*c);
151 TDbColSetIter iter2(iter1);
155 test(iter1.Col()==++ii);
156 test(iter1.operator->()==&iter1.operator*());
157 test(&*iter1++==&*iter2);
160 test(&*iter1==&*++iter2);
164 CleanupStack::PopAndDestroy();
169 @SYMTestCaseID SYSLIB-DBMS-CT-0589
170 @SYMTestCaseDesc Tests for TDbCol,CDbColSet,TDbColSetIter classes
171 @SYMTestPriority Medium
172 @SYMTestActions Executes the tests of TDbCol,CDbColSet,TDbColSetIter
173 @SYMTestExpectedResults Test must not fail
176 LOCAL_C void TestColSet()
178 test.Next(_L("@SYMTestCaseID:SYSLIB-DBMS-CT-0589 "));
180 test.Next(_L("Testing CDbColSet"));
182 test.Next(_L("Testing TDbColSetIter"));
188 @SYMTestCaseID SYSLIB-DBMS-CT-0590
189 @SYMTestCaseDesc Tests for TDbKeyCol class
190 @SYMTestPriority Medium
191 @SYMTestActions Attempts to test for attributes of the key column together.
192 @SYMTestExpectedResults Test must not fail
195 LOCAL_C void TestTDbKeyCol()
197 test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0590 Testing TDbKeyCol "));
198 TDbKeyCol c1(KColName);
199 test(c1.iName==KColName);
200 test(c1.iOrder==TDbKeyCol::EAsc);
201 TDbKeyCol c2(KColName,TDbKeyCol::EDesc);
202 test(c2.iName==KColName);
203 test(c2.iOrder==TDbKeyCol::EDesc);
207 @SYMTestCaseID SYSLIB-DBMS-CT-0591
208 @SYMTestCaseDesc Tests the CDbKey class
209 @SYMTestPriority Medium
210 @SYMTestActions Tests for the new CDbKey creation using NewL and NewLC functions
211 @SYMTestExpectedResults Test must not fail
214 LOCAL_C void TestCDbKey()
217 test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0591 ctor and dtor "));
218 CDbKey* k=CDbKey::NewL(); // assume it will succeed
224 TRAP(r,k=CDbKey::NewL());
232 CleanupStack::PopAndDestroy();
238 TRAP(r,k=CDbKey::NewLC();k->AddL(KColName);User::Leave(KLeaveError););
239 test(r==KLeaveError);
242 test.Next(_L("Add key columns"));
245 for (ii=1;ii<=KColCount;++ii)
247 VarName[7]=(TUint8)('A'-1+ii);
249 test(k->Count()==ii);
250 test((*k)[ii-1].iName==VarName);
252 test.Next(_L("Remove key columns"));
253 for (ii=1;ii<=KColCount;ii+=2)
255 VarName[7]=TUint8('A'-1+ii);
258 test(k->Count()==KColCount/2);
259 test.Next(_L("Clear"));
262 test.Next(_L("Unique flag"));
263 test(!k->IsUnique());
268 CleanupStack::PopAndDestroy();
274 @SYMTestCaseID SYSLIB-DBMS-CT-0592
275 @SYMTestCaseDesc Tests the TDbKeyCol,CDbKey classes
276 @SYMTestPriority Medium
277 @SYMTestActions Executes the TDbKeyCol,CDbKey tests
278 @SYMTestExpectedResults Test must not fail
281 LOCAL_C void TestKey()
283 test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0592 "));
285 test.Next(_L("Testing CDbKey"));
291 LOCAL_C void setupCleanup()
293 // Initialise the cleanup stack.
296 TheTrapCleanup=CTrapCleanup::New();
297 test(TheTrapCleanup!=NULL);
300 for (TInt i=KTestCleanupStack;i>0;i--)\
301 CleanupStack::PushL((TAny*)0);\
302 CleanupStack::Pop(KTestCleanupStack);\
308 GLDEF_C TInt E32Main()
314 test.Start(_L("Test the Column Set"));
315 TRAPD(r,TestColSet();)
318 test.Next(_L("Test the Key"));
324 delete TheTrapCleanup;