@@ -48,6 +48,8 @@ TSettingVariantTest = class
4848 [Test]
4949 procedure TestCopyStrArraySetting ;
5050 [Test]
51+ procedure TestCopyArraySetting ;
52+ [Test]
5153 procedure TestAddToStrArraySetting ();
5254 [Test]
5355 procedure TestAddIfNotContainsToStrArraySetting ();
@@ -123,15 +125,15 @@ procedure TSettingVariantTest.TestWriteToMemIniStr();
123125 ExpectedValue := ' ' ;
124126
125127 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Initialized is not stored. Expected %s should be equal to %s' ,
126- [ExpectedValue, ActualValue]));
128+ [ExpectedValue, ActualValue]));
127129
128130 v.Value := ' ChangedValue' ;
129131 v.StoreToPersister();
130132 ActualValue := IniFile.ReadString(Section, Ident, ' ' );
131133 ExpectedValue := v.Value ;
132134
133135 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Modified should stored. Expected %s should be equal to %s' ,
134- [ExpectedValue, ActualValue]));
136+ [ExpectedValue, ActualValue]));
135137
136138end ;
137139
@@ -153,15 +155,15 @@ procedure TSettingVariantTest.TestWriteToMemIniInt();
153155 ExpectedValue := -1 ;
154156
155157 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Initialized is not stored. Expected %d should be equal to %d' ,
156- [ExpectedValue, ActualValue]));
158+ [ExpectedValue, ActualValue]));
157159
158160 v.Value := 43 ;
159161 v.StoreToPersister();
160162 ActualValue := IniFile.ReadInteger(Section, Ident, -1 );
161163 ExpectedValue := 43 ;
162164
163165 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Modified should be stored. Expected %d should be equal to %d' ,
164- [ExpectedValue, ActualValue]));
166+ [ExpectedValue, ActualValue]));
165167
166168end ;
167169
@@ -182,7 +184,7 @@ procedure TSettingVariantTest.TestWriteToMemIniBool();
182184 ExpectedValue := v.Value ;
183185
184186 Assert.AreNotEqual(ExpectedValue, ActualValue, Format(' Initialized is not stored. Expected %s should be equal to %s' ,
185- [BoolToStr(ExpectedValue), BoolToStr(ActualValue)]));
187+ [BoolToStr(ExpectedValue), BoolToStr(ActualValue)]));
186188
187189 v.Value := False;
188190 v.Value := True;
@@ -192,7 +194,7 @@ procedure TSettingVariantTest.TestWriteToMemIniBool();
192194 ExpectedValue := v.Value ;
193195
194196 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Expected %s should be equal to %s' ,
195- [BoolToStr(ExpectedValue), BoolToStr(ActualValue)]));
197+ [BoolToStr(ExpectedValue), BoolToStr(ActualValue)]));
196198
197199end ;
198200
@@ -216,7 +218,7 @@ procedure TSettingVariantTest.TestWriteToMemIniArray();
216218 ActualValue := IniFile.ReadString(Section, Format(' Item_%d' , [i]), ' ' );
217219 ExpectedValue := varr[i];
218220 Assert.AreNotEqual(ExpectedValue, ActualValue, Format(' Initialized not saved. Expected %s should be equal to %s' ,
219- [ExpectedValue, ActualValue]));
221+ [ExpectedValue, ActualValue]));
220222 end ;
221223
222224 varr := [' 1' , ' 2' , ' 3' ];
@@ -227,7 +229,7 @@ procedure TSettingVariantTest.TestWriteToMemIniArray();
227229 ActualValue := IniFile.ReadString(Section, Format(' Item_%d' , [i]), ' ' );
228230 ExpectedValue := varr[i];
229231 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Modified should stored. Expected %s should be equal to %s' ,
230- [ExpectedValue, ActualValue]));
232+ [ExpectedValue, ActualValue]));
231233 end ;
232234
233235end ;
@@ -317,10 +319,36 @@ procedure TSettingVariantTest.TestCopyStrArraySetting;
317319 v2 := TArraySetting.Create(' v2' );
318320
319321 v2.Copy(v);
320- Assert.AreEqual (v.Value , v2.Value , ' Values should be equal after copy' );
322+ Assert.IsTrue (v.Value .Compare( v2.Value ) , ' Values should be equal after copy' );
321323 Assert.IsTrue(v.Equals(v2), ' Settings should be equal after copy' );
322324end ;
323325
326+ procedure TSettingVariantTest.TestCopyArraySetting ;
327+ var
328+ v, v2 : IArraySetting;
329+ begin
330+ var
331+ a := [' alpha' , ' beta' , ' gamma' ];
332+ v := TArraySetting.Create(' sourceArray' , a);
333+ var
334+ b := [' initial' ];
335+ v2 := TArraySetting.Create(' targetArray' , b);
336+
337+ // Test copy with populated source
338+ v2.Copy(v);
339+ Assert.AreEqual(3 , v2.Value .Count, ' Count should be 3 after copy' );
340+ Assert.AreEqual(' alpha' , v2.Value [0 ], ' First item should be alpha' );
341+ Assert.AreEqual(' beta' , v2.Value [1 ], ' Second item should be beta' );
342+ Assert.AreEqual(' gamma' , v2.Value [2 ], ' Third item should be gamma' );
343+ Assert.IsTrue(v.Value .Compare(v2.Value ), ' Values should be equal after copy' );
344+
345+ // Test copy with empty source
346+ var
347+ v3 := TArraySetting.Create(' emptyArray' );
348+ v2.Copy(v3);
349+ Assert.AreEqual(0 , v2.Value .Count, ' Count should be 0 after copying empty array' );
350+ end ;
351+
324352procedure TSettingVariantTest.TestAddToStrArraySetting ();
325353var
326354 v : IArraySetting;
@@ -389,7 +417,7 @@ procedure TSettingVariantTest.TestWriteToMemIniArrayReversed();
389417 ActualValue := IniFile.ReadString(Section, Format(' Item_%d' , [i]), ' ' );
390418 ExpectedValue := varr[i];
391419 Assert.AreNotEqual(ExpectedValue, ActualValue, Format(' Initialized not saved. Expected %s should be equal to %s' ,
392- [ExpectedValue, ActualValue]));
420+ [ExpectedValue, ActualValue]));
393421 end ;
394422
395423 varr := [' 1' , ' 2' , ' 3' ];
@@ -400,7 +428,7 @@ procedure TSettingVariantTest.TestWriteToMemIniArrayReversed();
400428 ActualValue := IniFile.ReadString(Section, Format(' Item_%d' , [i]), ' ' );
401429 ExpectedValue := varr[i];
402430 Assert.AreEqual(ExpectedValue, ActualValue, Format(' Modified should stored. Expected %s should be equal to %s' ,
403- [ExpectedValue, ActualValue]));
431+ [ExpectedValue, ActualValue]));
404432 end ;
405433
406434end ;
0 commit comments