From 3c7cba927bb5d234d6d72f65e063754590a7b584 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 9 Jan 2023 10:05:05 +0100 Subject: 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 --- .../test_converttofromurl_methods.bas | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'basic/qa/basic_coverage') 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 -- cgit