os/kernelhwsrv/kerneltest/f32test/manager/t_clobbr.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32test\manager\t_clobbr.cpp
    15 // 
    16 //
    17 
    18 #include <f32file.h>
    19 #include <e32test.h>
    20 #include "t_server.h"
    21 
    22 GLDEF_D RTest test(_L("T_CLOBBR"));
    23 
    24 GLDEF_C void CallTestsL(void)
    25 //
    26 // Test writing to a file and changing its size
    27 //
    28 {
    29 	test.Next(_L("Write file & change size"));
    30 
    31 	RFile file;
    32 	TInt r=file.Replace(TheFs,_L("test.dat"),EFileWrite);
    33 	test(r==KErrNone);
    34 	
    35 	r=file.Write(0,_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
    36 	test(r==KErrNone);
    37 	TBuf8<0x40> buf1;
    38 	r=file.Read(0,buf1);
    39 	test(r==KErrNone&&buf1.Length()==36);
    40 	if (buf1!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
    41 		test.Printf(_L("1). *BAD*\n"));
    42 	
    43 	r=file.SetSize(511);
    44 	test(r==KErrNone);
    45 	TBuf8<0x40> buf2;
    46 	r=file.Read(0,buf2);
    47 	test(r==KErrNone&&buf2.Length()==0x40);
    48 	buf2.SetLength(36);
    49 	if (buf2!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
    50 		test.Printf(_L("2). *BAD*\n"));
    51 	
    52 	r=file.SetSize(512);
    53 	test(r==KErrNone);
    54 	TBuf8<0x40> buf3;
    55 	r=file.Read(0,buf3);
    56 	test(r==KErrNone&&buf3.Length()==0x40);
    57 	buf3.SetLength(36);
    58 	if (buf3!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
    59 		test.Printf(_L("3). *BAD*\n"));
    60 	
    61 	r=file.Write(0,_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
    62 	test(r==KErrNone);
    63 	TBuf8<0x40> buf4;
    64 	r=file.Read(0,buf4);
    65 	test(r==KErrNone&&buf4.Length()==0x40);
    66 	buf4.SetLength(36);
    67 	if (buf4!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
    68 		test.Printf(_L("4). *BAD*\n"));
    69 	r=file.SetSize(511);
    70 	test(r==KErrNone);
    71 	TBuf8<0x40> buf5;
    72 	r=file.Read(0,buf5);
    73 	test(r==KErrNone&&buf5.Length()==0x40);
    74 	buf5.SetLength(36);
    75 	if (buf5!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
    76 		test.Printf(_L("5). *BAD*\n"));
    77 	r=file.SetSize(512);
    78 	test(r==KErrNone);
    79 	TBuf8<0x40> buf6;
    80 	r=file.Read(0,buf6);
    81 	test(r==KErrNone&&buf6.Length()==0x40);
    82 	buf6.SetLength(36);
    83 	if (buf6!=_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))
    84 		test.Printf(_L("6). *BAD*\n"));
    85 //
    86 	
    87 #if !defined(_UNICODE)
    88 	test.Printf(_L("\n"));
    89 	test.Printf(_L("1). %S\n"),&buf1);
    90 	test.Printf(_L("2). %S\n"),&buf2);
    91 	test.Printf(_L("3). %S\n"),&buf3);
    92 	test.Printf(_L("4). %S\n"),&buf4);
    93 	test.Printf(_L("5). %S\n"),&buf5);
    94 	test.Printf(_L("6). %S\n"),&buf6);
    95 #endif
    96 	file.Close();
    97     }