Предыдущая серия была тут - http://18delphi.blogspot.com/2013/07/blog-post_3683.html
Теперь выведем из абстрактных контейнеров предыдущей серии - конкретные. Пока - атомарные.
Итак. Как обычно.
Модель:
Код:
IntegerList.pas:
Тесты (взятые "от фонаря", но тем не менее они имеют право на жизнь).
Модель тестов:
Код тестов:
IntegerListTest.pas:
Код тут - http://sourceforge.net/p/rumtmarc/code-0/19/tree/trunk/Blogger/SandBox и http://sourceforge.net/p/rumtmarc/code-0/19/tree/trunk/Blogger/SandBoxTest
Теперь выведем из абстрактных контейнеров предыдущей серии - конкретные. Пока - атомарные.
Итак. Как обычно.
Модель:
Код:
IntegerList.pas:
unit IntegerList;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "SandBox"
// Модуль: "IntegerList.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: SimpleClass::Class Shared Delphi Sand Box::SandBox::FinalContainers::TIntegerList
//
// Список Integer'ов
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
interface
uses
Refcounted,
Classes,
l3PtrLoc
;
type
_ItemType_ = Integer;
_AtomicList_Parent_ = TRefcounted;
{$Include AtomicList.imp.pas}
TIntegerList = class(_AtomicList_)
{* Список Integer'ов }
end;//TIntegerList
implementation
uses
RTLConsts,
l3MemorySizeUtils
;
type _Instance_R_ = TIntegerList;
type _AtomicList_R_ = TIntegerList;
{$Include AtomicList.imp.pas}
end.
ByteList.pas:
unit ByteList;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "SandBox"
// Модуль: "ByteList.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: SimpleClass::Class Shared Delphi Sand Box::SandBox::FinalContainers::TByteList
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
interface
uses
Refcounted,
Classes,
l3PtrLoc
;
type
_ItemType_ = Byte;
_AtomicList_Parent_ = TRefcounted;
{$Include AtomicList.imp.pas}
TByteList = class(_AtomicList_)
end;//TByteList
implementation
uses
RTLConsts,
l3MemorySizeUtils
;
type _Instance_R_ = TByteList;
type _AtomicList_R_ = TByteList;
{$Include AtomicList.imp.pas}
end.
Int64List.pas:
unit Int64List;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "SandBox"
// Модуль: "Int64List.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: SimpleClass::Class Shared Delphi Sand Box::SandBox::FinalContainers::TInt64List
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
interface
uses
Refcounted,
Classes,
l3PtrLoc
;
type
_ItemType_ = Int64;
_AtomicList_Parent_ = TRefcounted;
{$Include AtomicList.imp.pas}
TInt64List = class(_AtomicList_)
end;//TInt64List
implementation
uses
RTLConsts,
l3MemorySizeUtils
;
type _Instance_R_ = TInt64List;
type _AtomicList_R_ = TInt64List;
{$Include AtomicList.imp.pas}
end.
Тесты (взятые "от фонаря", но тем не менее они имеют право на жизнь).
Модель тестов:
Код тестов:
IntegerListTest.pas:
unit IntegerListTest;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "SandBoxTest"
// Модуль: "IntegerListTest.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: TestCase::Class Shared Delphi Sand Box::SandBoxTest::FinalContainersTests::IntegerListTest
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
interface
uses
TestFrameWork
;
type
TIntegerListTest = class(TTestCase)
published
// published methods
procedure DoIt;
procedure TestTwoLists;
end;//TIntegerListTest
implementation
uses
IntegerList,
SysUtils
;
// start class TIntegerListTest
procedure TIntegerListTest.DoIt;
//#UC START# *51DEB319037C_51DEB2FA00B0_var*
const
cCount = 1000;
var
l_List : TIntegerList;
l_Count : IndexType;
l_Index : IndexType;
//#UC END# *51DEB319037C_51DEB2FA00B0_var*
begin
//#UC START# *51DEB319037C_51DEB2FA00B0_impl*
l_List := TIntegerList.Create;
try
l_List.Count := cCount;
Check(l_List.Count = cCount);
Check(l_List.Capacity >= cCount);
for l_Index := 0 to l_List.Count - 1 do
Check(l_List[l_Index] = 0);
l_Count := Random(cCount);
l_List.Count := l_Count;
Check(l_List.Count = l_Count, Format('Выделяли %d элементов. Count = %d', [l_Count, l_List.Count]));
Check(l_List.Capacity >= l_Count, Format('Выделяли %d элементов. Capacity = %d', [l_Count, l_List.Capacity]));
for l_Index := 0 to l_List.Count - 1 do
Check(l_List[l_Index] = 0);
finally
FreeAndNil(l_List);
end;//try..finally
//#UC END# *51DEB319037C_51DEB2FA00B0_impl*
end;//TIntegerListTest.DoIt
procedure TIntegerListTest.TestTwoLists;
//#UC START# *51DED6FC03C1_51DEB2FA00B0_var*
const
cCount = 1000;
var
l_A : TIntegerList;
l_B : TIntegerList;
l_Index : IndexType;
l_Value : Integer;
//#UC END# *51DED6FC03C1_51DEB2FA00B0_var*
begin
//#UC START# *51DED6FC03C1_51DEB2FA00B0_impl*
l_A := TIntegerList.Create;
try
l_B := TIntegerList.Create;
try
l_A.Count := cCount;
for l_Index := 0 to l_A.Count - 1 do
begin
l_Value := Random(1000);
l_A[l_Index] := l_Value;
Check(l_A[l_Index] = l_Value);
end;//for l_Index
l_B.Count := l_A.Count;
for l_Index := 0 to l_A.Count - 1 do
begin
l_B[l_Index] := l_A[l_Index];
end;//for l_Index
for l_Index := 0 to l_A.Count - 1 do
begin
Check(l_B[l_Index] = l_A[l_Index]);
end;//for l_Index
finally
FreeAndNil(l_B);
end;//try..finally
finally
FreeAndNil(l_A);
end;//try..finally
//#UC END# *51DED6FC03C1_51DEB2FA00B0_impl*
end;//TIntegerListTest.TestTwoLists
initialization
TestFramework.RegisterTest(TIntegerListTest.Suite);
end.
ByteListTest.pas:
unit ByteListTest;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "SandBoxTest"
// Модуль: "ByteListTest.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: TestCase::Class Shared Delphi Sand Box::SandBoxTest::FinalContainersTests::ByteListTest
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
interface
uses
TestFrameWork
;
type
TByteListTest = class(TTestCase)
published
// published methods
procedure DoIt;
end;//TByteListTest
implementation
uses
ByteList,
SysUtils
;
// start class TByteListTest
procedure TByteListTest.DoIt;
//#UC START# *51DEE6960378_51DEE67C003A_var*
const
cCount = 1000;
var
l_List : TByteList;
l_Count : IndexType;
l_Index : IndexType;
//#UC END# *51DEE6960378_51DEE67C003A_var*
begin
//#UC START# *51DEE6960378_51DEE67C003A_impl*
l_List := TByteList.Create;
try
l_List.Count := cCount;
Check(l_List.Count = cCount);
Check(l_List.Capacity >= cCount);
for l_Index := 0 to l_List.Count - 1 do
Check(l_List[l_Index] = 0);
l_Count := Random(cCount);
l_List.Count := l_Count;
Check(l_List.Count = l_Count, Format('Выделяли %d элементов. Count = %d', [l_Count, l_List.Count]));
Check(l_List.Capacity >= l_Count, Format('Выделяли %d элементов. Capacity = %d', [l_Count, l_List.Capacity]));
for l_Index := 0 to l_List.Count - 1 do
Check(l_List[l_Index] = 0);
finally
FreeAndNil(l_List);
end;//try..finally
//#UC END# *51DEE6960378_51DEE67C003A_impl*
end;//TByteListTest.DoIt
initialization
TestFramework.RegisterTest(TByteListTest.Suite);
end.
Int64ListTest.pas:
unit Int64ListTest;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "SandBoxTest"
// Модуль: "Int64ListTest.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: TestCase::Class Shared Delphi Sand Box::SandBoxTest::FinalContainersTests::Int64ListTest
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
interface
uses
TestFrameWork
;
type
TInt64ListTest = class(TTestCase)
published
// published methods
procedure DoIt;
end;//TInt64ListTest
implementation
uses
Int64List,
SysUtils
;
// start class TInt64ListTest
procedure TInt64ListTest.DoIt;
//#UC START# *51DEE90202A8_51DEE8E9025A_var*
const
cCount = 1000;
var
l_List : TInt64List;
l_Count : IndexType;
l_Index : IndexType;
//#UC END# *51DEE90202A8_51DEE8E9025A_var*
begin
//#UC START# *51DEE90202A8_51DEE8E9025A_impl*
l_List := TInt64List.Create;
try
l_List.Count := cCount;
Check(l_List.Count = cCount);
Check(l_List.Capacity >= cCount);
for l_Index := 0 to l_List.Count - 1 do
Check(l_List[l_Index] = 0);
l_Count := Random(cCount);
l_List.Count := l_Count;
Check(l_List.Count = l_Count, Format('Выделяли %d элементов. Count = %d', [l_Count, l_List.Count]));
Check(l_List.Capacity >= l_Count, Format('Выделяли %d элементов. Capacity = %d', [l_Count, l_List.Capacity]));
for l_Index := 0 to l_List.Count - 1 do
Check(l_List[l_Index] = 0);
finally
FreeAndNil(l_List);
end;//try..finally
//#UC END# *51DEE90202A8_51DEE8E9025A_impl*
end;//TInt64ListTest.DoIt
initialization
TestFramework.RegisterTest(TInt64ListTest.Suite);
end.
Код тут - http://sourceforge.net/p/rumtmarc/code-0/19/tree/trunk/Blogger/SandBox и http://sourceforge.net/p/rumtmarc/code-0/19/tree/trunk/Blogger/SandBoxTest


Комментариев нет:
Отправить комментарий