1 /* |
|
2 * Copyright (c) 2005-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 |
|
18 |
|
19 |
|
20 /** |
|
21 @file CTestSuiteA.cpp |
|
22 */ |
|
23 |
|
24 #include "ctestsuitea.h" |
|
25 #include "ctestsuiteb.h" |
|
26 |
|
27 void CTestSuiteA::SetupL() |
|
28 /** |
|
29 * SetupL |
|
30 */ |
|
31 { |
|
32 } |
|
33 |
|
34 void CTestSuiteA::TearDownL() |
|
35 /** |
|
36 * TearDownL |
|
37 */ |
|
38 { |
|
39 } |
|
40 |
|
41 void CTestSuiteA::TestOne() |
|
42 /** |
|
43 * TestOne |
|
44 */ |
|
45 { |
|
46 INFO_PRINTF1(_L("Running SuiteA:One")); |
|
47 TInt theInt = 0; |
|
48 TBool res = iConfig.GetInt(_L("SectionOne"),_L("TheInt"),theInt); |
|
49 ASSERT_TRUE(res); |
|
50 |
|
51 TBool theBool = EFalse; |
|
52 res = iConfig.GetBool(_L("SectionOne"),_L("TheBool"), theBool); |
|
53 ASSERT_TRUE(res); |
|
54 |
|
55 // Test all the Logging functions |
|
56 INFO_PRINTF1(_L("Info Print Tests")); |
|
57 INFO_PRINTF2(_L("Int = %d"),theInt); |
|
58 INFO_PRINTF3(_L("Int = %d Bool = %d"),theInt,theBool); |
|
59 INFO_PRINTF4(_L("Int = %d Bool = %d Int = %d"),theInt,theBool,theInt); |
|
60 INFO_PRINTF5(_L("Int = %d Bool = %d Int = %d Bool = %d"),theInt,theBool,theInt, theBool); |
|
61 INFO_PRINTF6(_L("Int = %d Bool = %d Int = %d Bool = %d Int = %d"),theInt,theBool,theInt,theBool,theInt); |
|
62 INFO_PRINTF7(_L("Int = %d Bool = %d Int = %d Bool = %d Int = %d Bool = %d"),theInt,theBool,theInt,theBool, theInt, theBool); |
|
63 |
|
64 WARN_PRINTF1(_L("Warn Print Tests")); |
|
65 WARN_PRINTF2(_L("Int = %d"),theInt); |
|
66 WARN_PRINTF3(_L("Int = %d Bool = %d"),theInt,theBool); |
|
67 WARN_PRINTF4(_L("Int = %d Bool = %d Int = %d"),theInt,theBool,theInt); |
|
68 WARN_PRINTF5(_L("Int = %d Bool = %d Int = %d Bool = %d"),theInt,theBool,theInt, theBool); |
|
69 WARN_PRINTF6(_L("Int = %d Bool = %d Int = %d Bool = %d Int = %d"),theInt,theBool,theInt,theBool,theInt); |
|
70 WARN_PRINTF7(_L("Int = %d Bool = %d Int = %d Bool = %d Int = %d Bool = %d"),theInt,theBool,theInt,theBool, theInt, theBool); |
|
71 |
|
72 ERR_PRINTF1(_L("Err Print Tests")); |
|
73 ERR_PRINTF2(_L("Int = %d"),theInt); |
|
74 ERR_PRINTF3(_L("Int = %d Bool = %d"),theInt,theBool); |
|
75 ERR_PRINTF4(_L("Int = %d Bool = %d Int = %d"),theInt,theBool,theInt); |
|
76 ERR_PRINTF5(_L("Int = %d Bool = %d Int = %d Bool = %d"),theInt,theBool,theInt, theBool); |
|
77 ERR_PRINTF6(_L("Int = %d Bool = %d Int = %d Bool = %d Int = %d"),theInt,theBool,theInt,theBool,theInt); |
|
78 ERR_PRINTF7(_L("Int = %d Bool = %d Int = %d Bool = %d Int = %d Bool = %d"),theInt,theBool,theInt,theBool, theInt, theBool); |
|
79 } |
|
80 |
|
81 void CTestSuiteA::TestTwo() |
|
82 /** |
|
83 * TestTwo |
|
84 */ |
|
85 { |
|
86 INFO_PRINTF1(_L("Running SuiteA:Two")); |
|
87 |
|
88 // Test all the configuration info is retrieved correctly from SectionOne |
|
89 TInt theInt = 0; |
|
90 TBool res = iConfig.GetInt(_L("SectionOne"),_L("TheInt"),theInt); |
|
91 ASSERT_TRUE(res); |
|
92 ASSERT_EQUALS( theInt, 999 ); |
|
93 |
|
94 TBool theBool = EFalse; |
|
95 res = iConfig.GetBool(_L("SectionOne"),_L("TheBool"), theBool); |
|
96 ASSERT_TRUE(res); |
|
97 ASSERT_TRUE( theBool ); |
|
98 |
|
99 TInt theHex = 0; |
|
100 res = iConfig.GetHex(_L("SectionOne"), _L("TheHex"), theHex); |
|
101 ASSERT_TRUE(res); |
|
102 ASSERT_EQUALS( theHex, (TInt)0x12345678 ); |
|
103 |
|
104 TPtrC theString; |
|
105 res = iConfig.GetString(_L("SectionOne"), _L("TheString"), theString); |
|
106 ASSERT_TRUE(res); |
|
107 ASSERT_EQUALS( theString, _L("TheString") ); |
|
108 |
|
109 // Test all the configuration info is retrieved correctly from SectionTwo |
|
110 res = iConfig.GetInt(_L("SectionTwo"),_L("TheInt"),theInt); |
|
111 ASSERT_TRUE(res); |
|
112 ASSERT_EQUALS( theInt, 666 ); |
|
113 |
|
114 res = iConfig.GetBool(_L("SectionTwo"),_L("TheBool"), theBool); |
|
115 ASSERT_TRUE(res); |
|
116 ASSERT_FALSE( theBool ); |
|
117 |
|
118 res = iConfig.GetHex(_L("SectionTwo"), _L("TheHex"), theHex); |
|
119 ASSERT_TRUE(res); |
|
120 ASSERT_EQUALS( theHex, (TInt)0x87654321 ); |
|
121 |
|
122 res = iConfig.GetString(_L("SectionTwo"), _L("TheString"), theString); |
|
123 ASSERT_TRUE(res); |
|
124 ASSERT_EQUALS( theString, _L("TheStringReturns") ); |
|
125 |
|
126 // Test all the asserts work |
|
127 TInt a = 5; |
|
128 TInt b = 5; |
|
129 ASSERT_EQUALS(a, b); |
|
130 |
|
131 CTestConfig* aPtr = NULL; |
|
132 ASSERT_NULL( aPtr ); |
|
133 |
|
134 aPtr = &iConfig; |
|
135 ASSERT_NOT_NULL( aPtr ); |
|
136 |
|
137 ASSERT_SAME( aPtr, &iConfig ); |
|
138 |
|
139 aPtr = NULL; |
|
140 ASSERT_NOT_SAME( aPtr, &iConfig ); |
|
141 |
|
142 TBool aBool = ETrue; |
|
143 ASSERT_TRUE(aBool); |
|
144 ASSERT_FALSE(!aBool); |
|
145 } |
|
146 |
|
147 void CTestSuiteA::TestThree() |
|
148 /** |
|
149 * TestThree |
|
150 */ |
|
151 { |
|
152 INFO_PRINTF1(_L("Running SuiteA:Three")); |
|
153 |
|
154 // Test all the configuration info is retrieved correctly from SectionOne |
|
155 TInt theInt = 90021; |
|
156 TBool res = iConfig.WriteInt(_L("SectionWriteTest2"),_L("TheInt"),theInt); |
|
157 ASSERT_TRUE(res); |
|
158 |
|
159 TBool theBool = EFalse; |
|
160 res = iConfig.WriteBool(_L("SectionWriteTest2"),_L("TheBool"), theBool); |
|
161 ASSERT_TRUE(res); |
|
162 |
|
163 TInt theHex = 12345; |
|
164 res = iConfig.WriteHex(_L("SectionWriteTest2"), _L("TheHex"), theHex); |
|
165 ASSERT_TRUE(res); |
|
166 |
|
167 TPtrC theString(_L("WriteThisStringToSectionWriteTest2Section")); |
|
168 res = iConfig.WriteString(_L("SectionWriteTest2"), _L("TheString"), theString); |
|
169 ASSERT_TRUE(res); |
|
170 |
|
171 // Test all the configuration info is retrieved correctly from SectionTwo |
|
172 res = iConfig.WriteInt(_L("TheInt"),theInt); |
|
173 ASSERT_TRUE(res); |
|
174 |
|
175 res = iConfig.WriteBool(_L("TheBool"), theBool); |
|
176 ASSERT_TRUE(res); |
|
177 |
|
178 res = iConfig.WriteHex(_L("TheHex"), theHex); |
|
179 ASSERT_TRUE(res); |
|
180 |
|
181 res = iConfig.WriteString(_L("TheString"), theString); |
|
182 ASSERT_TRUE(res); |
|
183 } |
|
184 |
|
185 CTestSuite* CTestSuiteA::CreateSuiteL( const TDesC& aName ) |
|
186 /** |
|
187 * CreateSuiteL |
|
188 * |
|
189 * @param aName - Suite name |
|
190 * @return - Suite |
|
191 */ |
|
192 { |
|
193 SUB_SUITE; |
|
194 #ifndef __GCCXML__ |
|
195 ADD_TEST_STEP( TestOne ); |
|
196 ADD_TEST_STEP( TestTwo ); |
|
197 ADD_TEST_STEP( TestThree ); |
|
198 #endif |
|
199 #ifdef __GCCXML__ |
|
200 ADD_TEST_STEP_CLASS( CTestSuiteA, TestOne ); |
|
201 ADD_TEST_STEP_CLASS( CTestSuiteA, TestTwo ); |
|
202 ADD_TEST_STEP_CLASS( CTestSuiteA, TestThree ); |
|
203 #endif |
|
204 ADD_TEST_SUITE( CTestSuiteB ) |
|
205 END_SUITE; |
|
206 } |
|