Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / basic / qa / vba_tests / collection.vb
blob774f3c4c7904379f74c1f0c130ae520607b7e651
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 VBASupport 1
10 Option Explicit
12 Function doUnitTest() As String
13 TestUtil.TestInit
14 verify_testCollection
15 doUnitTest = TestUtil.GetResult()
16 End Function
18 Sub verify_testCollection()
20 Dim a As Collection
21 Dim b As Collection
23 On Error Resume Next
24 Set a = New Collection
25 a.Add 1, "D"
26 a.Add 2, "d"
27 a.Add 3, "Д" ' uppercase Cyrillic script De
28 a.Add 4, "д" ' lowercase Cyrillic script De
29 On Error GoTo 0
31 On Error Resume Next
32 Set b = New Collection
33 b.Add 1, "SS"
34 b.Add 2, "ss"
35 b.Add 3, "ẞ" ' uppercase German Eszett
36 b.Add 4, "ß" ' lowercase German Eszett
37 On Error GoTo 0
39 On Error GoTo errorHandler
41 ' tdf#144245 - case-insensitive operation for non-ASCII characters
42 ' Without the fix in place, this test would have failed with
43 ' - Expected: 2
44 ' - Actual : 3
45 TestUtil.AssertEqual(a.Count, 2, "a.Count")
47 ' tdf#144245 - case-insensitive operation for non-ASCII item access
48 ' Without the fix in place, this test would have failed with
49 ' - Expected: 1 for d, 3 for lowercase Cyrillic script De (д)
50 ' - Actual : 2 for d, 4 for lowercase Cyrillic script De (д)
51 TestUtil.AssertEqual(a.Item("D"), 1, "a.Item(""D"")")
52 TestUtil.AssertEqual(a.Item("d"), 1, "a.Item(""d"")")
53 TestUtil.AssertEqual(a.Item("Д"), 3, "a.Item(""Д"")")
54 TestUtil.AssertEqual(a.Item("д"), 3, "a.Item(""д"")")
56 ' tdf#144245 - German Eszett is uppercased to a two-character 'SS'.
57 ' This test should fail after tdf#110003 has been fixed since the lowercase and the uppercase
58 ' German Eszett should be matched to the same index.
59 ' Before the fix of tdf#110003
60 'TestUtil.AssertEqual(b.Count, 3, "b.Count")
61 ' After the fix of tdf#110003
62 TestUtil.AssertEqual(b.Count, 2, "b.Count")
64 TestUtil.AssertEqual(b.Item("SS"), 1, "b.Item(""SS"")")
65 TestUtil.AssertEqual(b.Item("ss"), 1, "b.Item(""ss"")")
66 TestUtil.AssertEqual(b.Item("ẞ"), 3, "b.Item(""ẞ"")")
67 ' Before the fix of tdf#110003
68 'TestUtil.AssertEqual(b.Item("ß"), 4, "b.Item(""ß"")")
69 ' After the fix of tdf#110003
70 TestUtil.AssertEqual(b.Item("ß"), 3, "b.Item(""ß"")")
72 Exit Sub
73 errorHandler:
74 TestUtil.ReportErrorHandler("verify_testCollection", Err, Error$, Erl)
75 End Sub