|
1 /* |
|
2 * Copyright (c) 2004 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 // CLASS HEADER |
|
22 #include "UT_TStreamEncoder.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "StreamFormatter.h" |
|
30 |
|
31 // CONSTRUCTION |
|
32 UT_TStreamEncoder* UT_TStreamEncoder::NewL() |
|
33 { |
|
34 UT_TStreamEncoder* self = UT_TStreamEncoder::NewLC(); |
|
35 CleanupStack::Pop(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 UT_TStreamEncoder* UT_TStreamEncoder::NewLC() |
|
41 { |
|
42 UT_TStreamEncoder* self = new( ELeave ) UT_TStreamEncoder(); |
|
43 CleanupStack::PushL( self ); |
|
44 |
|
45 self->ConstructL(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor (virtual by CBase) |
|
51 UT_TStreamEncoder::~UT_TStreamEncoder() |
|
52 { |
|
53 } |
|
54 |
|
55 // Default constructor |
|
56 UT_TStreamEncoder::UT_TStreamEncoder() |
|
57 { |
|
58 } |
|
59 |
|
60 // Second phase construct |
|
61 void UT_TStreamEncoder::ConstructL() |
|
62 { |
|
63 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
64 // It generates the test case table. |
|
65 CEUnitTestSuiteClass::ConstructL(); |
|
66 } |
|
67 |
|
68 // METHODS |
|
69 |
|
70 |
|
71 |
|
72 void UT_TStreamEncoder::SetupL( ) |
|
73 { |
|
74 |
|
75 } |
|
76 |
|
77 void UT_TStreamEncoder::Teardown( ) |
|
78 { |
|
79 |
|
80 } |
|
81 |
|
82 void UT_TStreamEncoder::UT_TStreamEncoder_InitializeL( ) |
|
83 { |
|
84 TStreamEncoder enc; |
|
85 enc.Initialize( NULL, 0, 0 ); |
|
86 } |
|
87 |
|
88 void UT_TStreamEncoder::UT_TStreamEncoder_EncodeL( ) |
|
89 { |
|
90 TStreamEncoder enc; |
|
91 HBufC8* buf = HBufC8::NewLC( 100 ); |
|
92 enc.Initialize( const_cast<TUint8*>( buf->Des().Ptr() ), 0, 8 ); |
|
93 enc.Encode( 0, 0 ); |
|
94 enc.Encode( 0, 33 ); |
|
95 |
|
96 enc.Encode( 5, 8 ); |
|
97 |
|
98 CleanupStack::PopAndDestroy( buf ); |
|
99 } |
|
100 |
|
101 void UT_TStreamEncoder::UT_TStreamEncoder_Encode_1L( ) |
|
102 { |
|
103 TStreamEncoder enc; |
|
104 HBufC8* buf = HBufC8::NewLC( 100 ); |
|
105 enc.Initialize( const_cast<TUint8*>( buf->Des().Ptr() ), 0, 0 ); |
|
106 |
|
107 TBuf8<50> fromBuf; |
|
108 fromBuf.Format( _L8( "1234568901234568901234567890" ) ); |
|
109 fromBuf.Trim(); |
|
110 |
|
111 enc.Encode( fromBuf.Ptr(), 0, 8, 8 ); |
|
112 |
|
113 CleanupStack::PopAndDestroy( buf ); |
|
114 } |
|
115 |
|
116 void UT_TStreamEncoder::UT_TStreamEncoder_ByteIndexL( ) |
|
117 { |
|
118 TStreamEncoder enc; |
|
119 enc.Initialize( NULL, 1, 2 ); |
|
120 EUNIT_ASSERT_EQUALS( enc.ByteIndex(), 1 ); |
|
121 } |
|
122 |
|
123 void UT_TStreamEncoder::UT_TStreamEncoder_BitIndexL( ) |
|
124 { |
|
125 TStreamEncoder enc; |
|
126 enc.Initialize( NULL, 1, 2 ); |
|
127 EUNIT_ASSERT_EQUALS( enc.BitIndex(), 2 ); |
|
128 } |
|
129 |
|
130 void UT_TStreamEncoder::UT_TStreamEncoder_SetByteIndexL( ) |
|
131 { |
|
132 TStreamEncoder enc; |
|
133 enc.Initialize( NULL, 1, 2 ); |
|
134 enc.SetByteIndex( 3 ); |
|
135 EUNIT_ASSERT_EQUALS( enc.ByteIndex(), 3 ); |
|
136 } |
|
137 |
|
138 void UT_TStreamEncoder::UT_TStreamEncoder_SetBitIndexL( ) |
|
139 { |
|
140 TStreamEncoder enc; |
|
141 enc.Initialize( NULL, 1, 2 ); |
|
142 enc.SetBitIndex( 4 ); |
|
143 EUNIT_ASSERT_EQUALS( enc.BitIndex(), 4 ); |
|
144 } |
|
145 |
|
146 // TEST TABLE |
|
147 |
|
148 EUNIT_BEGIN_TEST_TABLE( |
|
149 UT_TStreamEncoder, |
|
150 "Add test suite description here.", |
|
151 "UNIT" ) |
|
152 |
|
153 EUNIT_TEST( |
|
154 "Initialize - test ", |
|
155 "TStreamEncoder", |
|
156 "Initialize", |
|
157 "FUNCTIONALITY", |
|
158 SetupL, UT_TStreamEncoder_InitializeL, Teardown) |
|
159 |
|
160 EUNIT_TEST( |
|
161 "Encode - test ", |
|
162 "TStreamEncoder", |
|
163 "Encode", |
|
164 "FUNCTIONALITY", |
|
165 SetupL, UT_TStreamEncoder_EncodeL, Teardown) |
|
166 |
|
167 EUNIT_TEST( |
|
168 "Encode - test ", |
|
169 "TStreamEncoder", |
|
170 "Encode", |
|
171 "FUNCTIONALITY", |
|
172 SetupL, UT_TStreamEncoder_Encode_1L, Teardown) |
|
173 |
|
174 EUNIT_TEST( |
|
175 "ByteIndex - test ", |
|
176 "TStreamEncoder", |
|
177 "ByteIndex", |
|
178 "FUNCTIONALITY", |
|
179 SetupL, UT_TStreamEncoder_ByteIndexL, Teardown) |
|
180 |
|
181 EUNIT_TEST( |
|
182 "BitIndex - test ", |
|
183 "TStreamEncoder", |
|
184 "BitIndex", |
|
185 "FUNCTIONALITY", |
|
186 SetupL, UT_TStreamEncoder_BitIndexL, Teardown) |
|
187 |
|
188 EUNIT_TEST( |
|
189 "SetByteIndex - test ", |
|
190 "TStreamEncoder", |
|
191 "SetByteIndex", |
|
192 "FUNCTIONALITY", |
|
193 SetupL, UT_TStreamEncoder_SetByteIndexL, Teardown) |
|
194 |
|
195 EUNIT_TEST( |
|
196 "SetBitIndex - test ", |
|
197 "TStreamEncoder", |
|
198 "SetBitIndex", |
|
199 "FUNCTIONALITY", |
|
200 SetupL, UT_TStreamEncoder_SetBitIndexL, Teardown) |
|
201 |
|
202 |
|
203 EUNIT_END_TEST_TABLE |
|
204 |
|
205 // END OF FILE |