author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
/* |
sl@0 | 2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 3 |
* All rights reserved. |
sl@0 | 4 |
* This component and the accompanying materials are made available |
sl@0 | 5 |
* under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 6 |
* which accompanies this distribution, and is available |
sl@0 | 7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 8 |
* |
sl@0 | 9 |
* Initial Contributors: |
sl@0 | 10 |
* Nokia Corporation - initial contribution. |
sl@0 | 11 |
* |
sl@0 | 12 |
* Contributors: |
sl@0 | 13 |
* |
sl@0 | 14 |
* Description: |
sl@0 | 15 |
* TestParameter.cpp: implementation of the CTestParameter class. |
sl@0 | 16 |
* |
sl@0 | 17 |
*/ |
sl@0 | 18 |
|
sl@0 | 19 |
|
sl@0 | 20 |
/** |
sl@0 | 21 |
@file |
sl@0 | 22 |
*/ |
sl@0 | 23 |
|
sl@0 | 24 |
#include "testparameter.h" |
sl@0 | 25 |
|
sl@0 | 26 |
|
sl@0 | 27 |
CTestParameter::CTestParameter() : iValid(EFalse) |
sl@0 | 28 |
{ |
sl@0 | 29 |
}; |
sl@0 | 30 |
|
sl@0 | 31 |
|
sl@0 | 32 |
CIntTestParameter* CIntTestParameter::NewL(TDes& aValue) |
sl@0 | 33 |
{ |
sl@0 | 34 |
CIntTestParameter* self = CIntTestParameter::NewLC(aValue); |
sl@0 | 35 |
CleanupStack::Pop(self); |
sl@0 | 36 |
return self; |
sl@0 | 37 |
} |
sl@0 | 38 |
|
sl@0 | 39 |
CIntTestParameter* CIntTestParameter::NewLC(TDes& aValue) |
sl@0 | 40 |
{ |
sl@0 | 41 |
CIntTestParameter* self = new(ELeave) CIntTestParameter(); |
sl@0 | 42 |
CleanupStack::PushL(self); |
sl@0 | 43 |
self->Construct(aValue); |
sl@0 | 44 |
return self; |
sl@0 | 45 |
} |
sl@0 | 46 |
|
sl@0 | 47 |
void CIntTestParameter::Construct(TDes& aValue) |
sl@0 | 48 |
{ |
sl@0 | 49 |
TLex lexValue(aValue); |
sl@0 | 50 |
|
sl@0 | 51 |
if(aValue.Left(2) == _L("0x")) |
sl@0 | 52 |
{ |
sl@0 | 53 |
// its a hex number |
sl@0 | 54 |
TUint hexValue; |
sl@0 | 55 |
TLex hexLex(aValue.Mid(2)); |
sl@0 | 56 |
|
sl@0 | 57 |
if(hexLex.Val(hexValue, EHex)!=KErrNone) |
sl@0 | 58 |
return; |
sl@0 | 59 |
// checks if hexLex is at end of string, if not there was garbage in the string |
sl@0 | 60 |
// so throw it out |
sl@0 | 61 |
else if(!hexLex.Eos()) |
sl@0 | 62 |
return; |
sl@0 | 63 |
|
sl@0 | 64 |
iValue = STATIC_CAST(TInt,hexValue); |
sl@0 | 65 |
} |
sl@0 | 66 |
else if(lexValue.Val(iValue)!=KErrNone) |
sl@0 | 67 |
return; |
sl@0 | 68 |
// checks if lexValue is at end of string, if not there was garbage in the string |
sl@0 | 69 |
// so throw it out |
sl@0 | 70 |
else if(!lexValue.Eos()) |
sl@0 | 71 |
return; |
sl@0 | 72 |
|
sl@0 | 73 |
iValid = ETrue; |
sl@0 | 74 |
} |
sl@0 | 75 |
|
sl@0 | 76 |
CIntRangeTestParameter* CIntRangeTestParameter::NewL(TDes& aValue) |
sl@0 | 77 |
{ |
sl@0 | 78 |
CIntRangeTestParameter* self = CIntRangeTestParameter::NewLC(aValue); |
sl@0 | 79 |
CleanupStack::Pop(self); |
sl@0 | 80 |
return self; |
sl@0 | 81 |
} |
sl@0 | 82 |
|
sl@0 | 83 |
CIntRangeTestParameter* CIntRangeTestParameter::NewLC(TDes& aValue) |
sl@0 | 84 |
{ |
sl@0 | 85 |
CIntRangeTestParameter* self = new(ELeave) CIntRangeTestParameter(); |
sl@0 | 86 |
CleanupStack::PushL(self); |
sl@0 | 87 |
self->Construct(aValue); |
sl@0 | 88 |
return self; |
sl@0 | 89 |
} |
sl@0 | 90 |
|
sl@0 | 91 |
void CIntRangeTestParameter::Construct(TDes& aValue) |
sl@0 | 92 |
{ |
sl@0 | 93 |
if(aValue.Find(_L("..")) != KErrNotFound) |
sl@0 | 94 |
{ |
sl@0 | 95 |
TInt pos = aValue.Find(_L("..")); |
sl@0 | 96 |
TLex startLex(aValue.Left(pos)); |
sl@0 | 97 |
TLex endLex(aValue.Mid(pos+2)); |
sl@0 | 98 |
|
sl@0 | 99 |
if(startLex.Val(iStart)!=KErrNone) |
sl@0 | 100 |
return; |
sl@0 | 101 |
// checks if startLex is at end of string, if not there was garbage in the string so throw it out |
sl@0 | 102 |
else if(!startLex.Eos()) |
sl@0 | 103 |
return; |
sl@0 | 104 |
|
sl@0 | 105 |
if(endLex.Val(iFinish)!=KErrNone) |
sl@0 | 106 |
return; |
sl@0 | 107 |
// checks if startLex is at end of string, if not there was garbage in the string so throw it out |
sl@0 | 108 |
else if(!endLex.Eos()) |
sl@0 | 109 |
return; |
sl@0 | 110 |
// checks if range is doable |
sl@0 | 111 |
if(iStart > iFinish) |
sl@0 | 112 |
return; |
sl@0 | 113 |
} |
sl@0 | 114 |
else |
sl@0 | 115 |
return; |
sl@0 | 116 |
iValid = ETrue; |
sl@0 | 117 |
} |
sl@0 | 118 |
|
sl@0 | 119 |
CRandomTestParameter* CRandomTestParameter::NewL(TDes& aValue) |
sl@0 | 120 |
{ |
sl@0 | 121 |
CRandomTestParameter* self = CRandomTestParameter::NewLC(aValue); |
sl@0 | 122 |
CleanupStack::Pop(self); |
sl@0 | 123 |
return self; |
sl@0 | 124 |
} |
sl@0 | 125 |
|
sl@0 | 126 |
CRandomTestParameter* CRandomTestParameter::NewLC(TDes& aValue) |
sl@0 | 127 |
{ |
sl@0 | 128 |
CRandomTestParameter* self = new(ELeave) CRandomTestParameter(); |
sl@0 | 129 |
CleanupStack::PushL(self); |
sl@0 | 130 |
self->Construct(aValue); |
sl@0 | 131 |
return self; |
sl@0 | 132 |
} |
sl@0 | 133 |
|
sl@0 | 134 |
|
sl@0 | 135 |
void CRandomTestParameter::Construct(TDes& aValue) |
sl@0 | 136 |
{ |
sl@0 | 137 |
TLex lexValue(aValue); |
sl@0 | 138 |
|
sl@0 | 139 |
if(lexValue.Val(iInterations)!=KErrNone) |
sl@0 | 140 |
return; |
sl@0 | 141 |
else if(!lexValue.Eos()) |
sl@0 | 142 |
// checks if startLex is at end of string, if not there was garbage in the string so throw it out |
sl@0 | 143 |
return; |
sl@0 | 144 |
|
sl@0 | 145 |
iValid = ETrue; |
sl@0 | 146 |
} |
sl@0 | 147 |
|
sl@0 | 148 |
CStringTestParameter* CStringTestParameter::NewL(TDes& aValue) |
sl@0 | 149 |
{ |
sl@0 | 150 |
CStringTestParameter* self = CStringTestParameter::NewLC(aValue); |
sl@0 | 151 |
CleanupStack::Pop(self); |
sl@0 | 152 |
return self; |
sl@0 | 153 |
} |
sl@0 | 154 |
|
sl@0 | 155 |
CStringTestParameter* CStringTestParameter::NewLC(TDes& aValue) |
sl@0 | 156 |
{ |
sl@0 | 157 |
CStringTestParameter* self = new(ELeave) CStringTestParameter(); |
sl@0 | 158 |
CleanupStack::PushL(self); |
sl@0 | 159 |
self->Construct(aValue); |
sl@0 | 160 |
return self; |
sl@0 | 161 |
} |
sl@0 | 162 |
|
sl@0 | 163 |
void CStringTestParameter::Construct(TDes& aValue) |
sl@0 | 164 |
{ |
sl@0 | 165 |
iValue.Copy(aValue); |
sl@0 | 166 |
iValid = ETrue; |
sl@0 | 167 |
} |