Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#15

AW: System.Generics.Collections.TArray.Copy

  Alt 24. Nov 2014, 13:58
Als Ergänzung hier mal meine TestCases, die ich an den jeweiligen BugReport gehängt habe

RSP-9620
Delphi-Quellcode:
unit Test.System;

interface

uses
  TestFramework;

type
  Test_System_Routines = class( TTestCase )
  strict private
  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure Test_CopyArray_Integer;
    procedure Test_CopyArray_Int64;
    procedure Test_CopyArray_String;
    procedure Test_CopyArray_Variant;
  end;

implementation

procedure Test_System_Routines.SetUp;
begin
  inherited;
end;

procedure Test_System_Routines.TearDown;
begin
  inherited;
end;

procedure Test_System_Routines.Test_CopyArray_Integer;
var
  LSource : TArray<Integer>;
  LDest: TArray<Integer>;
  LLength : Integer;
begin
  LLength := 5;
  SetLength( LSource, LLength );
  SetLength( LDest, LLength );
  CopyArray( @LDest[0], @LSource[0], TypeInfo( Integer ), LLength );
end;

procedure Test_System_Routines.Test_CopyArray_Int64;
var
  LSource : TArray<Int64>;
  LDest: TArray<Int64>;
  LLength : Integer;
begin
  LLength := 5;
  SetLength( LSource, LLength );
  SetLength( LDest, LLength );
  CopyArray( @LDest[0], @LSource[0], TypeInfo( Int64 ), LLength );
end;

procedure Test_System_Routines.Test_CopyArray_String;
var
  LSource : TArray<string>;
  LDest: TArray<string>;
  LLength : Integer;
begin
  LLength := 5;
  SetLength( LSource, LLength );
  SetLength( LDest, LLength );
  CopyArray( @LDest[0], @LSource[0], TypeInfo( string ), LLength );
end;

procedure Test_System_Routines.Test_CopyArray_Variant;
var
  LSource : TArray<Variant>;
  LDest: TArray<Variant>;
  LLength : Integer;
begin
  LLength := 5;
  SetLength( LSource, LLength );
  SetLength( LDest, LLength );
  CopyArray( @LDest[0], @LSource[0], TypeInfo( Variant ), LLength );
end;

initialization

RegisterTest( Test_System_Routines.Suite );

end.
RSP-9622
Delphi-Quellcode:
unit Test.System.Generics.Collections;

interface

uses
  TestFramework,
  System.Generics.Collections;

type
  Test_System_Generics_Collections_TArray = class( TTestCase )
  strict private
    FSource: TArray<Integer>;
  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure Test_Copy_1;
    procedure Test_Copy_2;
    procedure Test_Copy_3;
    procedure Test_Copy_4;
  end;

implementation

procedure Test_System_Generics_Collections_TArray.SetUp;
begin
  inherited;
  SetLength( FSource, 10 );
end;

procedure Test_System_Generics_Collections_TArray.TearDown;
begin
  inherited;

end;

procedure Test_System_Generics_Collections_TArray.Test_Copy_1;
var
  LDest: TArray<Integer>;
begin
  SetLength( LDest, 5 );
  TArray.Copy<Integer>( FSource, LDest, Length( LDest ) );
end;

procedure Test_System_Generics_Collections_TArray.Test_Copy_2;
var
  LDest: TArray<Integer>;
begin
  SetLength( LDest, 5 );
  TArray.Copy<Integer>( FSource, LDest, Length( LDest ) - 1 );
end;

procedure Test_System_Generics_Collections_TArray.Test_Copy_3;
var
  LDest: TArray<Integer>;
begin
  SetLength( LDest, 5 );
  TArray.Copy<Integer>( FSource, LDest, 0, 0, Length( LDest ) );
end;

procedure Test_System_Generics_Collections_TArray.Test_Copy_4;
var
  LDest: TArray<Integer>;
begin
  SetLength( LDest, 5 );
  TArray.Copy<Integer>( FSource, LDest, 0, 0, Length( LDest ) - 1 );
end;

initialization

RegisterTest( Test_System_Generics_Collections_TArray.Suite );

end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat