sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "tutility.h" sl@0: sl@0: sl@0: using namespace std; sl@0: sl@0: // ============================= LOCAL FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // ?function_name ?description. sl@0: // ?description sl@0: // Returns: ?value_1: ?description sl@0: // ?value_n: ?description_line1 sl@0: // ?description_line2 sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: /* sl@0: ?type ?function_name( sl@0: ?arg_type arg, // ?description sl@0: ?arg_type arg) // ?description sl@0: { sl@0: sl@0: ?code // ?comment sl@0: sl@0: // ?comment sl@0: ?code sl@0: } sl@0: */ sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctutility::Delete sl@0: // Delete here all resources allocated and opened from test methods. sl@0: // Called from destructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void Ctutility::Delete() sl@0: { sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctutility::RunMethodL sl@0: // Run specified method. Contains also table of test mothods and their names. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctutility::RunMethodL( sl@0: CStifItemParser& aItem ) sl@0: { sl@0: sl@0: static TStifFunctionInfo const KFunctions[] = sl@0: { sl@0: // Copy this line for every implemented function. sl@0: // First string is the function name used in TestScripter script file. sl@0: // Second is the actual implementation member function. sl@0: ENTRY( "Uninitialized_Copy", Ctutility::Uninitialized_Copy ), sl@0: ENTRY( "Uninitialized_Copy_n", Ctutility::Uninitialized_Copy_n ), sl@0: ENTRY( "Uninitialized_Fill", Ctutility::Uninitialized_Fill ), sl@0: ENTRY( "Uninitialized_Fill_n", Ctutility::Uninitialized_Fill_n ), sl@0: sl@0: //ADD NEW ENTRY HERE sl@0: sl@0: }; sl@0: sl@0: const TInt count = sizeof( KFunctions ) / sl@0: sizeof( TStifFunctionInfo ); sl@0: sl@0: return RunInternalL( KFunctions, count, aItem ); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctutility::Uninitialized_Copy sl@0: // Uninitialized_Copy test method function. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctutility::Uninitialized_Copy( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: __UHEAP_MARK; sl@0: int Array1[] = { 10, 20, 30, 40 }; sl@0: const int N = sizeof( Array1 ) / sizeof( int ); sl@0: sl@0: int i, testfail = 0; sl@0: sl@0: Integer* ArrayPtr = ( Integer* )::operator new( N * sizeof( int ) ); sl@0: Integer* LArrayPtr = uninitialized_copy(Array1, Array1 + N, ArrayPtr); sl@0: sl@0: if ( ( &Array1[0] + N ) == ( void* )LArrayPtr ) sl@0: { sl@0: testfail++; sl@0: } sl@0: sl@0: if ( ( void* )LArrayPtr != ( void* )( ArrayPtr + N ) ) sl@0: { sl@0: testfail++; sl@0: } sl@0: sl@0: delete ArrayPtr ; sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: if( testfail == 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctutility::Uninitialized_Copy_n sl@0: // Uninitialized_Copy_n test method function. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctutility::Uninitialized_Copy_n( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: __UHEAP_MARK; sl@0: int Array1[] = { 10, 20, 30, 40 }; sl@0: const int N = sizeof( Array1 ) / sizeof( int ); sl@0: sl@0: int i; sl@0: sl@0: Integer* ArrayPtr = ( Integer* )::operator new( N * sizeof( int ) ); sl@0: std::pair LArrayPtr = uninitialized_copy_n(Array1, N, ArrayPtr); sl@0: sl@0: delete ArrayPtr ; sl@0: __UHEAP_MARKEND; sl@0: sl@0: return KErrNone; sl@0: sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctutility::Uninitialized_Fill sl@0: // Uninitialized_Fill test method function. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctutility::Uninitialized_Fill( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: __UHEAP_MARK; sl@0: int testfail = 0 , p = 0; sl@0: const int N = 10; sl@0: Integer val ( 25 ); sl@0: Integer* Array1 = ( Integer* )::operator new( N * sizeof( int ) ); sl@0: uninitialized_fill( Array1, Array1 + N, val ); sl@0: sl@0: for ( int i = 0 ; i < N; i++ ) sl@0: { sl@0: p = Array1[ i ].get( ); sl@0: if( p != 25 ) sl@0: testfail++; sl@0: } sl@0: sl@0: delete Array1 ; sl@0: __UHEAP_MARKEND; sl@0: sl@0: if( testfail == 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctutility::Uninitialized_Fill_n sl@0: // Uninitialized_Fill_n test method function. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctutility::Uninitialized_Fill_n( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: __UHEAP_MARK; sl@0: int testfail = 0 , p = 0; sl@0: const int N = 10; sl@0: Integer val ( 60 ); sl@0: Integer* Array1 = ( Integer* )::operator new( N * sizeof( int ) ); sl@0: uninitialized_fill_n( Array1, N, val ); sl@0: sl@0: for ( int i = 0 ; i < N; i++ ) sl@0: { sl@0: p = Array1[ i ].get( ); sl@0: if( p != 60 ) sl@0: testfail++; sl@0: } sl@0: sl@0: delete Array1 ; sl@0: __UHEAP_MARKEND; sl@0: sl@0: if( testfail == 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: // ========================== OTHER EXPORTED FUNCTIONS ========================= sl@0: // None sl@0: sl@0: // End of File