First public contribution.
2 * Copyright (c) 2001-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 * Implementation for testing null object encoding/decoding
21 #include "tasn1normaltest.h"
27 CTestNull* CTestNull::NewL(CASN1NormalTest &aASN1Action)
29 CTestNull* test = new (ELeave) CTestNull(aASN1Action);
33 CTestNull::CTestNull(CASN1NormalTest &aASN1Action) : CTestBase(aASN1Action)
37 void CTestNull::GetName(TDes& aBuf)
39 aBuf.Copy(_L("Test Null"));
42 TBool CTestNull::PerformTestsL(CConsoleBase& aConsole)
44 // Get the encoder and decoder
45 CASN1EncNull* encoder = CASN1EncNull::NewLC();
49 TInt totalLength = encoder->LengthDER();
50 HBufC8* buf = HBufC8::NewMaxLC(totalLength);
51 TPtr8 tBuf = buf->Des();
53 // Write into the buffer
54 TUint writeLength = 0;
55 encoder->WriteDERL(tBuf, writeLength);
57 // Read it out again + check lengths
59 decoder.DecodeDERL(tBuf, readLength);
61 if (writeLength != STATIC_CAST(TUint, readLength))
63 aConsole.Write(_L("ERROR!\n"));
64 iASN1Action.ReportProgressL(KErrASN1EncodingError, 1, 1);
65 CleanupStack::PopAndDestroy(2); // buf, encoder
70 iASN1Action.ReportProgressL(KErrNone, 1, 1);
71 CleanupStack::PopAndDestroy(2); // buf, encoder