tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / basic / qa / basic_coverage / test_Collection_class.bas
blob06ed6b66588d58eddb8787c69d91374b6979a87f
2 ' This file is part of the LibreOffice project.
4 ' This Source Code Form is subject to the terms of the Mozilla Public
5 ' License, v. 2.0. If a copy of the MPL was not distributed with this
6 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 Option Explicit
11 Function doUnitTest() As String
12 TestUtil.TestInit
13 Call verify_Collection
14 doUnitTest = TestUtil.GetResult()
15 End Function
17 Sub verify_Collection()
18 try: On Error GoTo catch
20 Dim c As New Collection, planet as String, ndx As Integer
22 TestUtil.assertEqual(c.Count, 0,"c.Count")
24 ' Let's collect Solar system planets from closest to SUN,
25 ' ranking them alphabetically using before/after keywords,
26 ' in order to validate various Add() method syntax variations.
27 c.Add("Mercury")
28 c.Add("Venus", "♀")
29 c.Add("Earth", "♁", before:=1)
30 TestUtil.assertEqual(c.Count, 3,"c.Count")
31 TestUtil.assertEqual(c.Item(1), "Earth","c.Item(1)")
32 TestUtil.assertEqual(c.Item("♁"), "Earth","c.Item(""♁"")")
33 TestUtil.assertEqual(c.Item(3), "Venus","c.Item(3)")
34 TestUtil.assertEqual(c.Item("♀"), "Venus","c.Item(""♀"")")
36 c.Add("Mars", "♂", after:="♁")
37 c.Add("Jupiter", after:="♁")
38 c.Add("Saturn", before:=5)
39 TestUtil.assertEqual(c.Count, 6,"c.Count")
40 TestUtil.assertEqual(c.Item(2), "Jupiter","c.Item(2)")
41 TestUtil.assertEqual(c.Item(3), "Mars","c.Item(3)")
42 TestUtil.assertEqual(c.Item("♂"), "Mars","c.Item(""♂"")")
43 TestUtil.assertEqual(c.Item(5), "Saturn","c.Item(5)")
44 TestUtil.assertEqual(c.Item(6), "Venus","c.Item(6)")
46 c.Add("Uranus", before:="♀")
47 c.Add("Neptune", "♆", after:=4)
48 TestUtil.assertEqual(c.Count, 8,"c.Count")
49 TestUtil.assertEqual(c.Item(7), "Uranus","c.Item(7)")
50 TestUtil.assertEqual(c.Item(5), "Neptune","c.Item(5)")
51 TestUtil.assertEqual(c.Item("♆"), "Neptune","c.Item(""♆"")")
52 TestUtil.assertEqual(c.Item(6), "Saturn","c.Item(6)")
54 c.remove(4)
55 c.remove("♁")
57 TestUtil.assertEqual(c.Count, 6,"c.Count")
59 For ndx = c.Count to 1 Step -1
60 c.Remove(ndx)
61 Next ndx
63 TestUtil.assertEqual(c.Count, 0,"c.Count")
65 finally:
66 Exit Sub
68 catch:
69 TestUtil.ReportErrorHandler("verify_Collection", Err, Error$, Erl)
70 Resume Next
71 End Sub