Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / strcomp.vb
blob48735835808c6c130664afd98991342096856b13
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_testSTRcomp()
9 If failCount <> 0 or passCount = 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
18 Function verify_testSTRcomp() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim TestStr, TestStr1, TestStr2 As String
27 Dim date1, date2
28 testName = "Test STRcomp function"
29 On Error GoTo errorHandler
30 TestStr1 = "ABCD"
31 TestStr2 = "abcd"
33 date2 = 0
34 date1 = StrComp(TestStr1, TestStr2, vbTextCompare)
35 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
37 date2 = -1
38 date1 = StrComp(TestStr1, TestStr2, vbBinaryCompare)
39 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
41 date2 = -1
42 date1 = StrComp(TestStr1, TestStr2)
43 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
45 date2 = 0
46 date1 = StrComp("text", "text", vbBinaryCompare)
47 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
49 date2 = 1
50 date1 = StrComp("text ", "text", vbBinaryCompare)
51 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
53 date2 = -1
54 date1 = StrComp("Text", "text", vbBinaryCompare)
55 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
57 date2 = 0
58 date1 = StrComp("text", "text", vbTextCompare)
59 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
61 date2 = 1
62 date1 = StrComp("text ", "text", vbTextCompare)
63 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
65 date2 = 0
66 date1 = StrComp("Text", "text", vbTextCompare)
67 TestLog_ASSERT date1 = date2, "the return STRcomp is: " & date1
69 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
70 verify_testSTRcomp = result
72 Exit Function
73 errorHandler:
74 TestLog_ASSERT (False), testName & ": hit error handler"
75 End Function
77 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
79 If assertion = True Then
80 passCount = passCount + 1
81 Else
82 Dim testMsg As String
83 If Not IsMissing(testId) Then
84 testMsg = testMsg + " : " + testId
85 End If
86 If Not IsMissing(testComment) And Not (testComment = "") Then
87 testMsg = testMsg + " (" + testComment + ")"
88 End If
90 result = result & Chr$(10) & " Failed: " & testMsg
91 failCount = failCount + 1
92 End If
94 End Sub