RemObjects Software RemObjects Software

ShineOn

ShineOn Commit Details

Date:2010-10-13 11:41:11 (2 years 7 months ago)
Author:Roman Kassebaum
Commit:157
Parents: 156
Message:Fixed a problem in Copy for arrays and wrote a test for it.

File differences

trunk/Source/ShineOn.RTL/System.pas
251251  else
252252  begin
253253    if StartIndex + Length > Source.Length then
254      Result := new TBytes(Source.Length - StartIndex + 1)
254      Result := new TBytes(Source.Length - StartIndex)
255255    else
256256      Result := new TBytes(Length);
257257    Array.Copy(Source, StartIndex, Result, 0, Result.Length);
trunk/Source/NUnit/TestSystem.pas
5555    method Insert;
5656    [Test]
5757    method Copy;
58    [Test]
59    method CopyArray;
5860    [Test, Ignore('Test not implemented')]
5961    method Str;
6062    [Test]
...... 
234236  NUnit.Framework.Assert.AreEqual('Test',ShineOn.RTL.Copy('TestString', 0, 4));
235237end;
236238
239method SystemTests.CopyArray;
240begin
241  var pBuffer := new TBytes(3);
242  pBuffer[0] := 1;
243  pBuffer[1] := 2;
244  pBuffer[2] := 3;
245
246  var pCopy: TBytes;
247  var iCount: Integer;
248
249  pCopy := ShineOn.RTL.Copy(pBuffer, 0, 1);
250  NUnit.Framework.Assert.AreEqual(1, pCopy.Length);
251  NUnit.Framework.Assert.AreEqual(pBuffer[0], pCopy[0]);
252
253  pCopy := ShineOn.RTL.Copy(pBuffer, 1, 1);
254  NUnit.Framework.Assert.AreEqual(1, pCopy.Length);
255  NUnit.Framework.Assert.AreEqual(pBuffer[1], pCopy[0]);
256
257  pCopy := ShineOn.RTL.Copy(pBuffer, 0, 4);
258  NUnit.Framework.Assert.AreEqual(pBuffer.Length, pCopy.Length);
259  for iCount := 0 to pBuffer.Length - 1 do
260    NUnit.Framework.Assert.AreEqual(pBuffer[iCount], pCopy[iCount]);
261
262  pCopy := ShineOn.RTL.Copy(pBuffer, 2, 4);
263  NUnit.Framework.Assert.AreEqual(1, pCopy.Length);
264  NUnit.Framework.Assert.AreEqual(pBuffer[2], pCopy[0]);
265end;
266
237267method SystemTests.Str;
238268begin
239269  NUnit.Framework.Assert.IsTrue(false, 'Not implemented');

Archive Download the corresponding diff file

Revision: 157