|
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_TStreamDecoder.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_TStreamDecoder* UT_TStreamDecoder::NewL() |
|
33 { |
|
34 UT_TStreamDecoder* self = UT_TStreamDecoder::NewLC(); |
|
35 CleanupStack::Pop(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 UT_TStreamDecoder* UT_TStreamDecoder::NewLC() |
|
41 { |
|
42 UT_TStreamDecoder* self = new( ELeave ) UT_TStreamDecoder(); |
|
43 CleanupStack::PushL( self ); |
|
44 |
|
45 self->ConstructL(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor (virtual by CBase) |
|
51 UT_TStreamDecoder::~UT_TStreamDecoder() |
|
52 { |
|
53 } |
|
54 |
|
55 // Default constructor |
|
56 UT_TStreamDecoder::UT_TStreamDecoder() |
|
57 { |
|
58 } |
|
59 |
|
60 // Second phase construct |
|
61 void UT_TStreamDecoder::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_TStreamDecoder::SetupL( ) |
|
73 { |
|
74 |
|
75 } |
|
76 |
|
77 void UT_TStreamDecoder::Teardown( ) |
|
78 { |
|
79 |
|
80 } |
|
81 |
|
82 void UT_TStreamDecoder::UT_TStreamDecoder_InitializeL( ) |
|
83 { |
|
84 TStreamDecoder dec; |
|
85 dec.Initialize( NULL, 1, 2 ); |
|
86 } |
|
87 |
|
88 void UT_TStreamDecoder::UT_TStreamDecoder_DecodeL( ) |
|
89 { |
|
90 TStreamDecoder dec; |
|
91 TBuf8<50> data; |
|
92 data.Format( _L8( "foo42foo42foo42foo42" ) ); |
|
93 data.Trim(); |
|
94 HBufC8* buf = data.AllocLC(); |
|
95 |
|
96 dec.Initialize( const_cast<TUint8*>( buf->Des().Ptr() ), 0, 8 ); |
|
97 TUint32 dummy( 0 ); |
|
98 dummy = dec.Decode( 0 ); |
|
99 dummy = dec.Decode( 33 ); |
|
100 dummy = dec.Decode( 8 ); |
|
101 |
|
102 CleanupStack::PopAndDestroy( buf ); |
|
103 } |
|
104 |
|
105 void UT_TStreamDecoder::UT_TStreamDecoder_Decode_1L( ) |
|
106 { |
|
107 TStreamDecoder dec; |
|
108 TBuf8<50> data; |
|
109 data.Format( _L8( "foo42foo42foo42foo42" ) ); |
|
110 data.Trim(); |
|
111 HBufC8* buf = data.AllocLC(); |
|
112 |
|
113 dec.Initialize( const_cast<TUint8*>( buf->Des().Ptr() ), 0, 0 ); |
|
114 |
|
115 HBufC8* toBuf = HBufC8::NewLC( 50 ); |
|
116 |
|
117 dec.Decode( const_cast<TUint8*>( toBuf->Des().Ptr() ), 0, 0, 16 ); |
|
118 |
|
119 dec.Decode( const_cast<TUint8*>( toBuf->Des().Ptr() ), 0, 0, 16 ); |
|
120 |
|
121 CleanupStack::PopAndDestroy( toBuf ); |
|
122 CleanupStack::PopAndDestroy( buf ); |
|
123 } |
|
124 |
|
125 void UT_TStreamDecoder::UT_TStreamDecoder_ByteIndexL( ) |
|
126 { |
|
127 TStreamDecoder dec; |
|
128 dec.Initialize( NULL, 1, 2 ); |
|
129 EUNIT_ASSERT_EQUALS( dec.ByteIndex(), 1 ); |
|
130 } |
|
131 |
|
132 void UT_TStreamDecoder::UT_TStreamDecoder_BitIndexL( ) |
|
133 { |
|
134 TStreamDecoder dec; |
|
135 dec.Initialize( NULL, 1, 2 ); |
|
136 EUNIT_ASSERT_EQUALS( dec.BitIndex(), 2 ); |
|
137 } |
|
138 |
|
139 void UT_TStreamDecoder::UT_TStreamDecoder_SetByteIndexL( ) |
|
140 { |
|
141 TStreamDecoder dec; |
|
142 dec.Initialize( NULL, 1, 2 ); |
|
143 dec.SetByteIndex( 3 ); |
|
144 EUNIT_ASSERT_EQUALS( dec.ByteIndex(), 3 ); |
|
145 } |
|
146 |
|
147 void UT_TStreamDecoder::UT_TStreamDecoder_SetBitIndexL( ) |
|
148 { |
|
149 TStreamDecoder dec; |
|
150 dec.Initialize( NULL, 1, 2 ); |
|
151 dec.SetBitIndex( 4 ); |
|
152 EUNIT_ASSERT_EQUALS( dec.BitIndex(), 4 ); |
|
153 } |
|
154 |
|
155 // TEST TABLE |
|
156 |
|
157 EUNIT_BEGIN_TEST_TABLE( |
|
158 UT_TStreamDecoder, |
|
159 "Add test suite description here.", |
|
160 "UNIT" ) |
|
161 |
|
162 EUNIT_TEST( |
|
163 "Initialize - test ", |
|
164 "TStreamDecoder", |
|
165 "Initialize", |
|
166 "FUNCTIONALITY", |
|
167 SetupL, UT_TStreamDecoder_InitializeL, Teardown) |
|
168 |
|
169 EUNIT_TEST( |
|
170 "Decode - test ", |
|
171 "TStreamDecoder", |
|
172 "Decode", |
|
173 "FUNCTIONALITY", |
|
174 SetupL, UT_TStreamDecoder_DecodeL, Teardown) |
|
175 |
|
176 EUNIT_TEST( |
|
177 "Decode - test ", |
|
178 "TStreamDecoder", |
|
179 "Decode", |
|
180 "FUNCTIONALITY", |
|
181 SetupL, UT_TStreamDecoder_Decode_1L, Teardown) |
|
182 |
|
183 EUNIT_TEST( |
|
184 "ByteIndex - test ", |
|
185 "TStreamDecoder", |
|
186 "ByteIndex", |
|
187 "FUNCTIONALITY", |
|
188 SetupL, UT_TStreamDecoder_ByteIndexL, Teardown) |
|
189 |
|
190 EUNIT_TEST( |
|
191 "BitIndex - test ", |
|
192 "TStreamDecoder", |
|
193 "BitIndex", |
|
194 "FUNCTIONALITY", |
|
195 SetupL, UT_TStreamDecoder_BitIndexL, Teardown) |
|
196 |
|
197 EUNIT_TEST( |
|
198 "SetByteIndex - test ", |
|
199 "TStreamDecoder", |
|
200 "SetByteIndex", |
|
201 "FUNCTIONALITY", |
|
202 SetupL, UT_TStreamDecoder_SetByteIndexL, Teardown) |
|
203 |
|
204 EUNIT_TEST( |
|
205 "SetBitIndex - test ", |
|
206 "TStreamDecoder", |
|
207 "SetBitIndex", |
|
208 "FUNCTIONALITY", |
|
209 SetupL, UT_TStreamDecoder_SetBitIndexL, Teardown) |
|
210 |
|
211 |
|
212 EUNIT_END_TEST_TABLE |
|
213 |
|
214 // END OF FILE |