basic/qa/basic_coverage/test_converttofromurl_methods.bas |   29 +++++++++++---
 1 file changed, 23 insertions(+), 6 deletions(-)

New commits:
commit 3c7cba927bb5d234d6d72f65e063754590a7b584
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Jan 9 10:05:05 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jan 9 19:08:03 2023 +0000

    tdf#152917: basic_macros: Add unittest
    
    Change-Id: I69050ae0e6607ed4a1d1da0e89b45125e2c06e3b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145190
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/basic/qa/basic_coverage/test_converttofromurl_methods.bas 
b/basic/qa/basic_coverage/test_converttofromurl_methods.bas
index d1dbcfc5ff73..c17d17e631e3 100644
--- a/basic/qa/basic_coverage/test_converttofromurl_methods.bas
+++ b/basic/qa/basic_coverage/test_converttofromurl_methods.bas
@@ -7,11 +7,28 @@
 
 Option Explicit
 
-Function doUnitTest as String
-    ' ConvertFromUrl ConvertToUrl
-    If ( ConvertToUrl( ConvertFromUrl("") ) <> "") Then
-        doUnitTest = "FAIL"
+Function doUnitTest() As String
+    TestUtil.TestInit
+    verify_testConvertToFromUrl
+    doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testConvertToFromUrl
+    On Error GoTo errorHandler
+
+    TestUtil.AssertEqual( ConvertToUrl( ConvertFromUrl("") ), "", 
"ConvertToUrl( ConvertFromUrl("") )")
+
+    ' tdf#152917: Without the fix in place, this test would have failed with
+    ' Failed: ConvertFromUrl("file:///foo/bar/test.txt") returned , expected 
/foo/bar/test.txt
+    If (GetGUIType() <> 1) Then
+        'Linux
+        TestUtil.AssertEqual( ConvertFromUrl("file:///foo/bar/test.txt"), 
"/foo/bar/test.txt", "ConvertFromUrl(""file:///foo/bar/test.txt"")")
     Else
-        doUnitTest = "OK"
+        'Windows
+        TestUtil.AssertEqual( ConvertFromUrl("file://foo/bar/test.txt"), 
"\\foo\bar\test.txt", "ConvertFromUrl(""file://foo/bar/test.txt"")")
     End If
-End Function
+
+    Exit Sub
+errorHandler:
+    TestUtil.ReportErrorHandler("verify_testConvertToFromUrl", Err, Error$, 
Erl)
+End Sub

Reply via email to