Update contrib.
2 * Copyright (c) 2002-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.
19 #include "tbasicmathsvector.h"
23 CTestAction* CBasicMathsVector::NewL(RFs& aFs, CConsoleBase& aConsole,
24 Output& aOut, const TTestActionSpec& aTestActionSpec)
26 CTestAction* self = CBasicMathsVector::NewLC(aFs, aConsole,
27 aOut, aTestActionSpec);
32 CTestAction* CBasicMathsVector::NewLC(RFs& aFs, CConsoleBase& aConsole,
33 Output& aOut, const TTestActionSpec& aTestActionSpec)
35 CBasicMathsVector* self = new(ELeave) CBasicMathsVector(aFs, aConsole, aOut);
36 CleanupStack::PushL(self);
37 self->ConstructL(aTestActionSpec);
41 CBasicMathsVector::~CBasicMathsVector()
49 CBasicMathsVector::CBasicMathsVector(RFs& aFs, CConsoleBase& aConsole,
50 Output& aOut) : CTestAction(aConsole, aOut), iFs(aFs)
54 void CBasicMathsVector::ConstructL(const TTestActionSpec& aTestActionSpec)
56 CTestAction::ConstructL(aTestActionSpec);
57 iBody = HBufC8::NewL(aTestActionSpec.iActionBody.Length());
58 iBody->Des().Copy(aTestActionSpec.iActionBody);
60 iA = Input::ParseElementHexL(*iBody, _L8("<a>"));
61 iB = Input::ParseElementHexL(*iBody, _L8("<b>"));
62 iAns = Input::ParseElementHexL(*iBody, _L8("<ans>"));
63 TPtrC8 op = Input::ParseElement(*iBody, _L8("<op>"));
64 if( op == _L8("add") )
68 else if( op == _L8("subtract") )
72 else if( op == _L8("multiply") )
76 else if( op == _L8("divide") )
80 else if( op == _L8("modulus") )
84 else if( op == _L8("gcd") )
88 else if( op == _L8("inversemod") )
94 User::Panic(_L("tbasicmathsvector"), 1);
98 void CBasicMathsVector::DoPerformPrerequisite(TRequestStatus& aStatus)
100 TRequestStatus* status = &aStatus;
101 User::RequestComplete(status, KErrNone);
102 iActionState = CTestAction::EAction;
105 void CBasicMathsVector::DoPerformPostrequisite(TRequestStatus& aStatus)
107 TRequestStatus* status = &aStatus;
109 User::RequestComplete(status, KErrNone);
112 void CBasicMathsVector::DoReportAction(void)
116 void CBasicMathsVector::DoCheckResult(TInt)
120 void CBasicMathsVector::PerformAction(TRequestStatus& aStatus)
123 TRequestStatus* status = &aStatus;
126 RInteger a = RInteger::NewL(*iA);
127 CleanupStack::PushL(a);
128 RInteger b = RInteger::NewL(*iB);
129 CleanupStack::PushL(b);
130 RInteger ans = RInteger::NewL(*iAns);
131 CleanupStack::PushL(ans);
155 result = a.InverseModL(b);
159 User::Panic(_L("tbasicmathsvector"), 2);
167 CleanupStack::PopAndDestroy(&ans);
168 CleanupStack::PopAndDestroy(&b);
169 CleanupStack::PopAndDestroy(&a);
171 User::RequestComplete(status, KErrNone);
172 iActionState = CTestAction::EPostrequisite;