|
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: This file contains STIFUnit implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 * STIF_UNIT_INCLUDE SECTION - put all #includes between STIF_UNIT_INCLUDE_SECTION |
|
20 * and STIF_UNIT_INCLUDE_SECTION_END |
|
21 */ |
|
22 #ifdef STIF_UNIT_INCLUDE_SECTION |
|
23 |
|
24 |
|
25 #endif //STIF_UNIT_INCLUDE_SECTION_END |
|
26 |
|
27 /** |
|
28 * GLOBAL VARIABLES SECTION |
|
29 */ |
|
30 #ifdef TEST_VAR_DECLARATIONS |
|
31 /** |
|
32 * Example of variable common for some test cases |
|
33 */ |
|
34 RBuf buffer; |
|
35 |
|
36 #endif |
|
37 /** |
|
38 * END OF GLOBAL VARIABLES SECTION |
|
39 */ |
|
40 |
|
41 |
|
42 /** |
|
43 * TEST CASES SECTION |
|
44 */ |
|
45 #ifdef TEST_CASES |
|
46 /** |
|
47 * STIF_SETUP defines activities needed before every test case. |
|
48 */ |
|
49 STIF_SETUP |
|
50 { |
|
51 /** Example of use of STIF_SETUP - a variable common for some test cases is initialized |
|
52 */ |
|
53 buffer.CreateL(5); |
|
54 buffer.CleanupClosePushL(); |
|
55 } |
|
56 |
|
57 /** |
|
58 * STIF_TEARDOWN defines activities needed after every test case |
|
59 */ |
|
60 STIF_TEARDOWN |
|
61 { |
|
62 /** Example of use of STIF_TEARDOWN - a variable common for some test cases is destroyed |
|
63 */ |
|
64 CleanupStack::PopAndDestroy(); |
|
65 } |
|
66 |
|
67 /** |
|
68 * STIF_TESTDEFINE defines a test case |
|
69 * |
|
70 * Example test case - length of string is checked. |
|
71 * The only argument of macro is a name of test case. |
|
72 */ |
|
73 STIF_TESTDEFINE(test1) |
|
74 { |
|
75 _LIT(KHello, "Hello"); |
|
76 buffer.Copy(KHello()); |
|
77 buffer.ReAllocL(11); |
|
78 |
|
79 _LIT(KWorld, " World"); |
|
80 buffer.Append(KWorld); |
|
81 |
|
82 STIF_ASSERT_EQUALS(buffer.Length(), 11); |
|
83 } |
|
84 |
|
85 #endif |
|
86 /** |
|
87 * END OF TEST CASES SECTION |
|
88 */ |