|
1 // Copyright (c) 2004-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This contains ESock Test cases from section 13 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 |
|
22 // Test system includes |
|
23 |
|
24 #include "SocketTestSection13.h" |
|
25 |
|
26 |
|
27 // Test step 13.1 |
|
28 const TDesC& CSocketTest13_1::GetTestName() |
|
29 { |
|
30 _LIT(ret,"Test13.1"); |
|
31 return ret; |
|
32 } |
|
33 |
|
34 enum TVerdict CSocketTest13_1::InternalDoTestStepL( void ) |
|
35 { |
|
36 TVerdict verdict = EPass; |
|
37 |
|
38 Logger().WriteFormat(_L("Test Purpose: Utility Classes")); |
|
39 |
|
40 TUint8 data[]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10}; |
|
41 |
|
42 Logger().WriteFormat(_L("Big endian get")); |
|
43 |
|
44 TUint32 res32=BigEndian::Get32(data+1); |
|
45 |
|
46 // Integer bytes are tested in reverse order as Intel is LittleEndian |
|
47 TESTL(res32 == 0x02030405); |
|
48 |
|
49 TUint16 res16 = BigEndian::Get16(data+5); |
|
50 TESTL(res16 == 0x0607); |
|
51 |
|
52 Logger().WriteFormat(_L("Big endian set")); |
|
53 BigEndian::Put32(data+3, 0x10090807); |
|
54 TESTL(data[3] == 0x10); |
|
55 TESTL(data[4] == 0x09); |
|
56 TESTL(data[5] == 0x08); |
|
57 TESTL(data[6] == 0x07); |
|
58 |
|
59 BigEndian::Put16(data+7, 0x0201); |
|
60 TESTL(data[7] == 0x02); |
|
61 TESTL(data[8] == 0x01); |
|
62 |
|
63 Logger().WriteFormat(_L("Little endian get")); |
|
64 |
|
65 res32 = LittleEndian::Get32(data+1); |
|
66 TESTL(res32 == 0x09100302); |
|
67 |
|
68 res16 = LittleEndian::Get16(data+5); |
|
69 TESTL(res16 == 0x0708); |
|
70 |
|
71 Logger().WriteFormat(_L("Little endian set")); |
|
72 LittleEndian::Put32(data+1, 0x05060708); |
|
73 TESTL(data[1] == 0x08); |
|
74 TESTL(data[2] == 0x07); |
|
75 TESTL(data[3] == 0x06); |
|
76 TESTL(data[4] == 0x05); |
|
77 |
|
78 LittleEndian::Put16(data+1, 0x0102); |
|
79 TESTL(data[0] == 0x01); |
|
80 TESTL(data[1] == 0x02); |
|
81 TESTL(data[2] == 0x01); |
|
82 TESTL(data[3] == 0x06); |
|
83 TESTL(data[4] == 0x05); |
|
84 TESTL(data[5] == 0x08); |
|
85 TESTL(data[6] == 0x07); |
|
86 TESTL(data[7] == 0x02); |
|
87 TESTL(data[8] == 0x01); |
|
88 TESTL(data[9] == 0x10); |
|
89 |
|
90 LittleEndian::Put32(data+1,0xFeedFace); |
|
91 TUint16 res1 = BigEndian::Get16(data+1); |
|
92 TUint16 res2 = BigEndian::Get16(data+3); |
|
93 LittleEndian::Put16(data+3, res1); |
|
94 LittleEndian::Put16(data+1, res2); |
|
95 res32 = BigEndian::Get32(data+1); |
|
96 TESTL(res32 == 0xFeedFace); |
|
97 |
|
98 BigEndian::Put32(data+1, 0xFeedFace); |
|
99 res1 = LittleEndian::Get16(data+1); |
|
100 res2 = LittleEndian::Get16(data+3); |
|
101 BigEndian::Put16(data+3, res1); |
|
102 BigEndian::Put16(data+1, res2); |
|
103 res32 = LittleEndian::Get32(data+1); |
|
104 TESTL(res32 == 0xFeedFace); |
|
105 |
|
106 SetTestStepResult(verdict); |
|
107 return verdict; |
|
108 } |
|
109 |