datacommsserver/esockserver/test/TE_ESock/EsockTestSection21.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2001-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 21
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <in_sock.h>
       
    21 
       
    22 // Test system includes
       
    23 #include "EsockTestSection21.h"
       
    24 
       
    25 
       
    26 // Test step 21.1
       
    27 const TDesC& CEsockTest21_1::GetTestName()
       
    28 	{
       
    29 	// store the name of this test case
       
    30 	_LIT(ret,"Test21.1");
       
    31 	
       
    32 	return ret;
       
    33 	}
       
    34 
       
    35 CEsockTest21_1::~CEsockTest21_1()
       
    36 	{
       
    37 	}
       
    38 
       
    39 enum TVerdict CEsockTest21_1::easyTestStepL()
       
    40 	{
       
    41 	TInetAddr addr;
       
    42 	
       
    43 	// input valid ip addresses
       
    44 	TESTL(addr.Input(_L("::"))==KErrNone);
       
    45 	TESTL(addr.Input(_L("::11"))==KErrNone);
       
    46 	TESTL(addr.Input(_L("::FFF"))==KErrNone);
       
    47 	TESTL(addr.Input(_L("::FFF0"))==KErrNone);
       
    48 	TESTL(addr.Input(_L("::1:FFF"))==KErrNone);
       
    49 	TESTL(addr.Input(_L("::FFFF:100:FFF"))==KErrNone);
       
    50 	TESTL(addr.Input(_L("::1:FFFF:100:FFF"))==KErrNone);
       
    51 	TESTL(addr.Input(_L("::FFFF:1:FFFF:100:FFF"))==KErrNone);
       
    52 	TESTL(addr.Input(_L("::12:FFFF:1:FFFF:100:FFF"))==KErrNone);
       
    53 	TESTL(addr.Input(_L("::FFFF:12:FFFF:1:FFFF:100:FFF"))==KErrNone);
       
    54 	TESTL(addr.Input(_L("1:FFFF:12:FFFF:1:FFFF:100:FFF"))==KErrNone);
       
    55 	
       
    56 	TESTL(addr.Input(_L("1::"))==KErrNone);
       
    57 	TESTL(addr.Input(_L("FFFF:1::"))==KErrNone);
       
    58 	TESTL(addr.Input(_L("1:FFFF:1::"))==KErrNone);
       
    59 	TESTL(addr.Input(_L("FFFF:FFFF:FFFF:1::"))==KErrNone);
       
    60 	TESTL(addr.Input(_L("1:FFFF:FFFF:FFFF:1::"))==KErrNone);
       
    61 	TESTL(addr.Input(_L("FFFF:1:FFFF:FFFF:FFFF:1::"))==KErrNone);
       
    62 	TESTL(addr.Input(_L("1:FFFF:1:FFFF:FFFF:FFFF:1::"))==KErrNone);
       
    63 	TESTL(addr.Input(_L("0:0:0:0:0:0:0:0"))==KErrNone);
       
    64 	TESTL(addr.Input(_L("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"))==KErrNone);
       
    65 	TESTL(addr.Input(_L("FFFF::FFFF"))==KErrNone);
       
    66 	TESTL(addr.Input(_L("FFFF::FFFF:FFFF"))==KErrNone);
       
    67 	TESTL(addr.Input(_L("FFFF:0:0:0:0:0:0:FFFF"))==KErrNone);
       
    68 	TESTL(addr.Input(_L("abcd::"))==KErrNone);
       
    69 	
       
    70 	return EPass;
       
    71 	}
       
    72 
       
    73 
       
    74 // Test step 21.2
       
    75 const TDesC& CEsockTest21_2::GetTestName()
       
    76 	{
       
    77 	// store the name of this test case
       
    78 	_LIT(ret,"Test21.2");
       
    79 	
       
    80 	return ret;
       
    81 	}
       
    82 
       
    83 CEsockTest21_2::~CEsockTest21_2()
       
    84 	{
       
    85 	}
       
    86 
       
    87 enum TVerdict CEsockTest21_2::easyTestStepL()
       
    88 	{
       
    89 	TInetAddr addr;
       
    90 	
       
    91 	// input invalid ip addresses
       
    92 	
       
    93 	TESTL(addr.Input(_L("::FFFF1"))!=KErrNone);
       
    94 	TESTL(addr.Input(_L("::FFFG"))!=KErrNone);
       
    95 	TESTL(addr.Input(_L(":::FFF1"))!=KErrNone);
       
    96 	TESTL(addr.Input(_L("1:::FFF1"))!=KErrNone);
       
    97 	TESTL(addr.Input(_L("::FFF1:1:21:23A1::"))!=KErrNone);
       
    98 	TESTL(addr.Input(_L("0xFFF1:1:21:23A1::"))!=KErrNone);
       
    99 	TESTL(addr.Input(_L("::130:179.21.200"))!=KErrNone);
       
   100 	TESTL(addr.Input(_L("FFFF:FFFF:FFFF"))!=KErrNone);
       
   101 	
       
   102 	return EPass;
       
   103 	}
       
   104 
       
   105 
       
   106 // Test step 21.3
       
   107 const TDesC& CEsockTest21_3::GetTestName()
       
   108 	{
       
   109 	// store the name of this test case
       
   110 	_LIT(ret,"Test21.3");
       
   111 	
       
   112 	return ret;
       
   113 	}
       
   114 
       
   115 CEsockTest21_3::~CEsockTest21_3()
       
   116 	{
       
   117 	}
       
   118 
       
   119 enum TVerdict CEsockTest21_3::easyTestStepL()
       
   120 	{
       
   121 	TInetAddr addr;
       
   122 	TBuf<39> buf;
       
   123 	
       
   124 	// output the IP address
       
   125 	
       
   126 	const TIp6Addr KInet6addr1 = {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}};
       
   127 	const TIp6Addr KInet6addr2 = {{{ 0xff,0xff,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}};
       
   128 	const TIp6Addr KInet6addr3 = {{{ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }}};
       
   129 	const TIp6Addr KInet6addr4 = {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}};
       
   130 	
       
   131 	// set the IP address
       
   132 	addr.SetAddress(KInet6addr1);
       
   133 	
       
   134 	// output as a string and check format
       
   135 	addr.OutputWithScope(buf);
       
   136 	TESTL(buf==_L("::1"));
       
   137 	
       
   138 	// change the IP address
       
   139 	addr.SetAddress(KInet6addr2);
       
   140 	
       
   141 	// output as a string and check format
       
   142 	addr.OutputWithScope(buf);
       
   143 	TESTL(buf==_L("ffff::1"));
       
   144 	
       
   145 	// change the IP address
       
   146 	addr.SetAddress(KInet6addr3);
       
   147 	
       
   148 	// output as a string and check format
       
   149 	addr.OutputWithScope(buf);
       
   150 	TESTL(buf==_L("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
       
   151 	
       
   152 	// change the IP address
       
   153 	addr.SetAddress(KInet6addr4);
       
   154 	
       
   155 	// output as a string and check format
       
   156 	addr.OutputWithScope(buf);
       
   157 	TESTL(buf==_L("::"));
       
   158 	
       
   159 	return EPass;
       
   160 	}
       
   161 
       
   162