diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-11 20:52:03 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-11 20:52:03 +0000 |
commit | 3309f5b6227559456b25bb9e5c4051ccb72b6a13 (patch) | |
tree | 339c0c89d73d0f2106d16ae54e9db44b6dfdf477 /unittests | |
parent | 3ad8ad4117ef86f852b48970cbc2dc1df60aa757 (diff) | |
download | fpGUI-3309f5b6227559456b25bb9e5c4051ccb72b6a13.tar.xz |
* Extended the unit tests for the fpGUI treeview component.
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/fpcunitproject.lpi | 1 | ||||
-rw-r--r-- | unittests/treeview_test.pas | 51 |
2 files changed, 47 insertions, 5 deletions
diff --git a/unittests/fpcunitproject.lpi b/unittests/fpcunitproject.lpi index af7c6d5d..cbfeec27 100644 --- a/unittests/fpcunitproject.lpi +++ b/unittests/fpcunitproject.lpi @@ -9,6 +9,7 @@ </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> + <IconPath Value="./"/> <TargetFileExt Value=""/> </General> <VersionInfo> diff --git a/unittests/treeview_test.pas b/unittests/treeview_test.pas index 78028b5e..9abf5102 100644 --- a/unittests/treeview_test.pas +++ b/unittests/treeview_test.pas @@ -17,8 +17,10 @@ type procedure TearDown; override; published procedure TestCount; + procedure TestCountRecursive; procedure TestNext; procedure TestPrev; + procedure TestAppendText; end; implementation @@ -46,19 +48,58 @@ begin AssertEquals('Failed on 4', 1, FTree.RootNode.Count); end; -procedure TTestTreeview.TestNext; +procedure TTestTreeview.TestCountRecursive; var n: TfpgTreeNode; begin + AssertEquals('Failed on 1', 0, FTree.RootNode.CountRecursive); + FTree.RootNode.AppendText('n1'); + AssertEquals('Failed on 2', 1, FTree.RootNode.CountRecursive); + n := FTree.RootNode.AppendText('n2'); + AssertEquals('Failed on 3', 2, FTree.RootNode.CountRecursive); + n.AppendText('n2.1'); + AssertEquals('Failed on 4', 3, FTree.RootNode.CountRecursive); + n.AppendText('n2.2'); + AssertEquals('Failed on 5', 4, FTree.RootNode.CountRecursive); +// FTree.RootNode.Remove(n); +// AssertEquals('Failed on 6', 1, FTree.RootNode.Count); +end; + +procedure TTestTreeview.TestNext; +var + n1, n2: TfpgTreeNode; +begin AssertTrue('Failed on 1', FTree.RootNode.Next = nil); - n := FTree.RootNode.AppendText('n1'); - AssertTrue('Failed on 2', FTree.RootNode.Next = n); - AssertTrue('Failed on 3', n.Next = nil); + n1 := FTree.RootNode.AppendText('n1'); + n2 := FTree.RootNode.AppendText('n2'); + AssertTrue('Failed on 2', n1.Next = n2); + AssertTrue('Failed on 3', n2.Next = nil); + n1.AppendText('n1.1'); + AssertTrue('Failed on 4', n1.Next = n2); end; procedure TTestTreeview.TestPrev; +var + n1, n2: TfpgTreeNode; begin - raise Exception.Create('Implement this'); + AssertTrue('Failed on 1', FTree.RootNode.Prev = nil); + n1 := FTree.RootNode.AppendText('n1'); + n2 := FTree.RootNode.AppendText('n2'); + AssertTrue('Failed on 2', n2.Prev = n1); + AssertTrue('Failed on 3', n1.Prev = nil); + n1.AppendText('n1.1'); + AssertTrue('Failed on 4', n2.Prev = n1); +end; + +procedure TTestTreeview.TestAppendText; +var + n1, n2: TfpgTreeNode; +begin + n1 := FTree.RootNode.AppendText('n1'); + AssertTrue('Failed on 1', FTree.RootNode.FirstSubNode = n1); + AssertEquals('Failed on 2', 1, FTree.RootNode.Count); + n2 := FTree.RootNode.AppendText('n2'); + AssertEquals('Failed on 3', 2, FTree.RootNode.Count); end; initialization |