1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/manager/t_clobbr.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,97 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\manager\t_clobbr.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <f32file.h>
1.22 +#include <e32test.h>
1.23 +#include "t_server.h"
1.24 +
1.25 +GLDEF_D RTest test(_L("T_CLOBBR"));
1.26 +
1.27 +GLDEF_C void CallTestsL(void)
1.28 +//
1.29 +// Test writing to a file and changing its size
1.30 +//
1.31 +{
1.32 + test.Next(_L("Write file & change size"));
1.33 +
1.34 + RFile file;
1.35 + TInt r=file.Replace(TheFs,_L("test.dat"),EFileWrite);
1.36 + test(r==KErrNone);
1.37 +
1.38 + r=file.Write(0,_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
1.39 + test(r==KErrNone);
1.40 + TBuf8<0x40> buf1;
1.41 + r=file.Read(0,buf1);
1.42 + test(r==KErrNone&&buf1.Length()==36);
1.43 + if (buf1!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
1.44 + test.Printf(_L("1). *BAD*\n"));
1.45 +
1.46 + r=file.SetSize(511);
1.47 + test(r==KErrNone);
1.48 + TBuf8<0x40> buf2;
1.49 + r=file.Read(0,buf2);
1.50 + test(r==KErrNone&&buf2.Length()==0x40);
1.51 + buf2.SetLength(36);
1.52 + if (buf2!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
1.53 + test.Printf(_L("2). *BAD*\n"));
1.54 +
1.55 + r=file.SetSize(512);
1.56 + test(r==KErrNone);
1.57 + TBuf8<0x40> buf3;
1.58 + r=file.Read(0,buf3);
1.59 + test(r==KErrNone&&buf3.Length()==0x40);
1.60 + buf3.SetLength(36);
1.61 + if (buf3!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
1.62 + test.Printf(_L("3). *BAD*\n"));
1.63 +
1.64 + r=file.Write(0,_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
1.65 + test(r==KErrNone);
1.66 + TBuf8<0x40> buf4;
1.67 + r=file.Read(0,buf4);
1.68 + test(r==KErrNone&&buf4.Length()==0x40);
1.69 + buf4.SetLength(36);
1.70 + if (buf4!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
1.71 + test.Printf(_L("4). *BAD*\n"));
1.72 + r=file.SetSize(511);
1.73 + test(r==KErrNone);
1.74 + TBuf8<0x40> buf5;
1.75 + r=file.Read(0,buf5);
1.76 + test(r==KErrNone&&buf5.Length()==0x40);
1.77 + buf5.SetLength(36);
1.78 + if (buf5!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
1.79 + test.Printf(_L("5). *BAD*\n"));
1.80 + r=file.SetSize(512);
1.81 + test(r==KErrNone);
1.82 + TBuf8<0x40> buf6;
1.83 + r=file.Read(0,buf6);
1.84 + test(r==KErrNone&&buf6.Length()==0x40);
1.85 + buf6.SetLength(36);
1.86 + if (buf6!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
1.87 + test.Printf(_L("6). *BAD*\n"));
1.88 +//
1.89 +
1.90 +#if !defined(_UNICODE)
1.91 + test.Printf(_L("\n"));
1.92 + test.Printf(_L("1). %S\n"),&buf1);
1.93 + test.Printf(_L("2). %S\n"),&buf2);
1.94 + test.Printf(_L("3). %S\n"),&buf3);
1.95 + test.Printf(_L("4). %S\n"),&buf4);
1.96 + test.Printf(_L("5). %S\n"),&buf5);
1.97 + test.Printf(_L("6). %S\n"),&buf6);
1.98 +#endif
1.99 + file.Close();
1.100 + }