First public contribution.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * TestParameter.cpp: implementation of the CTestParameter class.
24 #include "testparameter.h"
27 CTestParameter::CTestParameter() : iValid(EFalse)
32 CIntTestParameter* CIntTestParameter::NewL(TDes& aValue)
34 CIntTestParameter* self = CIntTestParameter::NewLC(aValue);
35 CleanupStack::Pop(self);
39 CIntTestParameter* CIntTestParameter::NewLC(TDes& aValue)
41 CIntTestParameter* self = new(ELeave) CIntTestParameter();
42 CleanupStack::PushL(self);
43 self->Construct(aValue);
47 void CIntTestParameter::Construct(TDes& aValue)
49 TLex lexValue(aValue);
51 if(aValue.Left(2) == _L("0x"))
55 TLex hexLex(aValue.Mid(2));
57 if(hexLex.Val(hexValue, EHex)!=KErrNone)
59 // checks if hexLex is at end of string, if not there was garbage in the string
61 else if(!hexLex.Eos())
64 iValue = STATIC_CAST(TInt,hexValue);
66 else if(lexValue.Val(iValue)!=KErrNone)
68 // checks if lexValue is at end of string, if not there was garbage in the string
70 else if(!lexValue.Eos())
76 CIntRangeTestParameter* CIntRangeTestParameter::NewL(TDes& aValue)
78 CIntRangeTestParameter* self = CIntRangeTestParameter::NewLC(aValue);
79 CleanupStack::Pop(self);
83 CIntRangeTestParameter* CIntRangeTestParameter::NewLC(TDes& aValue)
85 CIntRangeTestParameter* self = new(ELeave) CIntRangeTestParameter();
86 CleanupStack::PushL(self);
87 self->Construct(aValue);
91 void CIntRangeTestParameter::Construct(TDes& aValue)
93 if(aValue.Find(_L("..")) != KErrNotFound)
95 TInt pos = aValue.Find(_L(".."));
96 TLex startLex(aValue.Left(pos));
97 TLex endLex(aValue.Mid(pos+2));
99 if(startLex.Val(iStart)!=KErrNone)
101 // checks if startLex is at end of string, if not there was garbage in the string so throw it out
102 else if(!startLex.Eos())
105 if(endLex.Val(iFinish)!=KErrNone)
107 // checks if startLex is at end of string, if not there was garbage in the string so throw it out
108 else if(!endLex.Eos())
110 // checks if range is doable
119 CRandomTestParameter* CRandomTestParameter::NewL(TDes& aValue)
121 CRandomTestParameter* self = CRandomTestParameter::NewLC(aValue);
122 CleanupStack::Pop(self);
126 CRandomTestParameter* CRandomTestParameter::NewLC(TDes& aValue)
128 CRandomTestParameter* self = new(ELeave) CRandomTestParameter();
129 CleanupStack::PushL(self);
130 self->Construct(aValue);
135 void CRandomTestParameter::Construct(TDes& aValue)
137 TLex lexValue(aValue);
139 if(lexValue.Val(iInterations)!=KErrNone)
141 else if(!lexValue.Eos())
142 // checks if startLex is at end of string, if not there was garbage in the string so throw it out
148 CStringTestParameter* CStringTestParameter::NewL(TDes& aValue)
150 CStringTestParameter* self = CStringTestParameter::NewLC(aValue);
151 CleanupStack::Pop(self);
155 CStringTestParameter* CStringTestParameter::NewLC(TDes& aValue)
157 CStringTestParameter* self = new(ELeave) CStringTestParameter();
158 CleanupStack::PushL(self);
159 self->Construct(aValue);
163 void CStringTestParameter::Construct(TDes& aValue)