update emoji autocorrect entries from po-files
[LibreOffice.git] / basic / qa / vba_tests / partition.vb
blob770d0b18f61f0d73558f7e2980ab604e24036e82
1 Option VBASupport 1
2 Option Explicit
3 Dim passCount As Integer
4 Dim failCount As Integer
5 Dim result As String
7 Function doUnitTest() As String
8 result = verify_testPartition()
9 If failCount <> 0 And passCount > 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
16 Function verify_testPartition() as String
17 passCount = 0
18 failCount = 0
20 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
23 Dim testName As String
24 Dim retStr As String
25 testName = "Test Partition function"
26 On Error GoTo errorHandler
28 retStr = Partition(20, 0, 98, 5)
29 'MsgBox retStr
30 TestLog_ASSERT retStr = "20:24", "the number 20 occurs in the range:" & retStr
32 retStr = Partition(20, 0, 99, 1)
33 'MsgBox retStr
34 TestLog_ASSERT retStr = " 20: 20", "the number 20 occurs in the range:" & retStr
36 retStr = Partition(120, 0, 99, 5)
37 'MsgBox retStr
38 TestLog_ASSERT retStr = "100: ", "the number 120 occurs in the range:" & retStr
40 retStr = Partition(-5, 0, 99, 5)
41 'MsgBox retStr
42 TestLog_ASSERT retStr = " : -1", "the number -5 occurs in the range:" & retStr
44 retStr = Partition(2, 0, 5, 2)
45 'MsgBox retStr
46 TestLog_ASSERT retStr = " 2: 3", "the number 2 occurs in the range:" & retStr
47 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
48 verify_testPartition = result
49 Exit Function
50 errorHandler:
51 TestLog_ASSERT (false), "vertify_testPartion failed, hit error handler"
52 End Function
54 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
56 If assertion = True Then
57 passCount = passCount + 1
58 Else
59 Dim testMsg As String
60 If Not IsMissing(testId) Then
61 testMsg = testMsg + " : " + testId
62 End If
63 If Not IsMissing(testComment) And Not (testComment = "") Then
64 testMsg = testMsg + " (" + testComment + ")"
65 End If
67 result = result & Chr$(10) & " Failed: " & testMsg
68 failCount = failCount + 1
69 End If
71 End Sub