Browse Source

* Add const for string where possible

Michaël Van Canneyt 1 year ago
parent
commit
5d20c0f749

+ 13 - 13
packages/testinsight/src/testinsightclient.pp

@@ -43,15 +43,15 @@ Type
     function GetLastErrorMessage: String; virtual; abstract;
     function JSONToTests(const aJSON: string): TStringDynArray;
     // URL is Relative to base URL
-    procedure ServerPost(aURL: string; const aContent: string = ''); virtual; abstract;
-    Function ServerGet(aURL: string) : string; virtual; abstract;
-    Procedure ServerDelete(aURL: string) ; virtual; abstract;
-    Function ConcatURL(aURL : String) : String; virtual;
+    procedure ServerPost(const aURL: string; const aContent: string = ''); virtual; abstract;
+    Function ServerGet(const aURL: string) : string; virtual; abstract;
+    Procedure ServerDelete(const aURL: string) ; virtual; abstract;
+    Function ConcatURL(const aURL : String) : String; virtual;
   public
     constructor Create(const aBaseURL : String); virtual;
     destructor Destroy; override;
     procedure LoadConfig(const aConfigFileName : String; aSection : String = '');
-    procedure LoadConfig(aIni : TCustomIniFile; aSection : String);
+    procedure LoadConfig(aIni : TCustomIniFile; const aSection : String);
     procedure GetServerOptions;
     // The client will free the result.
     procedure PostResult(const testResult: TTestInsightResult; forceSend: Boolean);
@@ -80,9 +80,9 @@ Type
   protected
     function GetHasError: Boolean; override;
     function GetLastErrorMessage: string; override;
-    procedure ServerPost(aURL: string; const aContent: string = ''); override;
-    Function ServerGet(aURL: string) : string; override;
-    Procedure ServerDelete(aURL: string); override;
+    procedure ServerPost(const aURL: string; const aContent: string = ''); override;
+    Function ServerGet(const aURL: string) : string; override;
+    Procedure ServerDelete(const aURL: string); override;
   public
     Constructor Create(Const aBaseURL : String); override;
     Destructor Destroy; override;
@@ -93,7 +93,7 @@ implementation
 
 { TTestInsightHTTPClient }
 
-procedure TTestInsightHTTPClient.ServerPost(aURL: string; const aContent: string = '');
+procedure TTestInsightHTTPClient.ServerPost(const aURL: string; const aContent: string = '');
 
 Var
   Body,Res : TStringStream;
@@ -120,7 +120,7 @@ begin
   end;
 end;
 
-function TTestInsightHTTPClient.ServerGet(aURL: string): string;
+function TTestInsightHTTPClient.ServerGet(const aURL: string): string;
 Var
   Res : TStringStream;
 
@@ -140,7 +140,7 @@ begin
   end;
 end;
 
-procedure TTestInsightHTTPClient.ServerDelete(aURL: string);
+procedure TTestInsightHTTPClient.ServerDelete(const aURL: string);
 begin
   try
     FHTTP.Delete(ConcatURL(aURL));
@@ -222,7 +222,7 @@ begin
   end;
 end;
 
-function TAbstractTestInsightClient.ConcatURL(aURL: String): String;
+function TAbstractTestInsightClient.ConcatURL(const aURL: String): String;
 begin
   Result:=fBaseURL;
   if (Result<>'') and (aURL<>'') and (Result[Length(Result)]<>'/') then
@@ -261,7 +261,7 @@ begin
   end;
 end;
 
-procedure TAbstractTestInsightClient.LoadConfig(aIni: TCustomIniFile;aSection : String);
+procedure TAbstractTestInsightClient.LoadConfig(aIni: TCustomIniFile; const aSection : String);
 begin
   FBaseURL:=aIni.ReadString(aSection,KeyBaseURL,BaseURL);
   Options.ShowProgress:=aIni.ReadBool(aSection,keyShowProgress,Self.Options.ShowProgress);

+ 7 - 7
packages/testinsight/src/testinsightprotocol.pp

@@ -127,15 +127,15 @@ Const
   TestPhaseNames: array[TTestPhase] of string
     = ('Setup', 'Run', 'TearDown','');
 
-Function StringToResultType(aValue : string) : TTestResultType;
+Function StringToResultType(const aValue : string) : TTestResultType;
 Function ResultTypeToString(aValue : TTestResultType) : string;
 
-Function StringToTestPhase(aValue : string) : TTestPhase;
+Function StringToTestPhase(const aValue : string) : TTestPhase;
 Function TestPhaseToString(aValue : TTestPhase) : string;
 
 
 // Convert CR/LF separated list name to expected JSON format
-Function TestStringsToJSON(aContent : String): TJSONObject;
+Function TestStringsToJSON(const aContent : String): TJSONObject;
 
 
 implementation
@@ -145,7 +145,7 @@ begin
   Result:=ResultTypeNames[aValue];
 end;
 
-function StringToTestPhase(aValue: string): TTestPhase;
+function StringToTestPhase(const aValue: string): TTestPhase;
 Var
   T : TTestPhase;
 
@@ -161,7 +161,7 @@ begin
   Result:=TestPhaseNames[aValue];
 end;
 
-Function StringToResultType(aValue : string) : TTestResultType;
+Function StringToResultType(const aValue : string) : TTestResultType;
 
 Var
   T : TTestResultType;
@@ -173,7 +173,7 @@ begin
       Exit(T);
 end;
 
-Procedure AddTests(aParent : TJSONObject; aList : TStrings; aPath : String; var aIdx : Integer);
+Procedure AddTests(aParent : TJSONObject; aList : TStrings; const aPath : String; var aIdx : Integer);
 
 Var
   P : integer;
@@ -210,7 +210,7 @@ begin
 end;
 
 
-Function TestStringsToJSON(aContent : String): TJSONObject;
+Function TestStringsToJSON(const aContent : String): TJSONObject;
 
 Var
   L : TStringList;