diff options
Diffstat (limited to 'basic/qa/vba_tests')
23 files changed, 264 insertions, 13 deletions
diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb index 914906c342c0..d7714facb3bb 100644 --- a/basic/qa/vba_tests/Err.Raise.vb +++ b/basic/qa/vba_tests/Err.Raise.vb @@ -45,7 +45,7 @@ catch: TestUtil.Assert(Err.Source = CurErrSource, "Err.Source failure", "Err.Source = " & Err.Source) TestUtil.Assert(Err.Description = CurErrDescription, "Err.Description failure", "Err.Description = " & Err.Description) - TestUtil.Assert(Erl = 32, "line# failure", "Erl = " & Erl ' WATCH OUT for HARDCODED LINE # HERE !) + TestUtil.Assert(Erl = 32, "line# failure", "Erl = " & Erl ) ' WATCH OUT for HARDCODED LINE # HERE TestUtil.Assert(Err = CurErrNo, "Err# failure", "Err = " & Err) TestUtil.Assert(Error = CurErrDescription, "Error description failure", "Error$ = " & Error$) diff --git a/basic/qa/vba_tests/cdbl.vb b/basic/qa/vba_tests/cdbl.vb index f29271f082d6..8a7d09cd5a2e 100644 --- a/basic/qa/vba_tests/cdbl.vb +++ b/basic/qa/vba_tests/cdbl.vb @@ -23,6 +23,11 @@ Sub verify_testCdbl() TestUtil.AssertEqual(CDbl(0.005 * 0.01), 0.00005, "CDbl(0.005 * 0.01)") TestUtil.AssertEqual(CDbl("20"), 20, "CDbl(""20"")") + + ' tdf#146672 - skip spaces and tabs at the end of the scanned string + TestUtil.AssertEqual(CDbl("28.8 "), 28.8, "CDbl(""28.8 "")") + TestUtil.AssertEqual(CDbl("28.8 "), 28.8, "CDbl(""28.8 "")") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testCdbl", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/chr.vb b/basic/qa/vba_tests/chr.vb index 5dc85a0c9157..f9bc7ea12aa5 100644 --- a/basic/qa/vba_tests/chr.vb +++ b/basic/qa/vba_tests/chr.vb @@ -21,7 +21,7 @@ Sub verify_testCHR() TestUtil.AssertEqual(Chr(87), "W", "Chr(87)") TestUtil.AssertEqual(Chr(105), "i", "Chr(105)") TestUtil.AssertEqual(Chr(35), "#", "Chr(35)") - + ' tdf#145693 - argument name should be 'charcode' instead of 'string' TestUtil.AssertEqual(Chr(charcode:=35), "#", "Chr(charcode:=35)") diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb index be7add515e83..c31444889fae 100644 --- a/basic/qa/vba_tests/constants.vb +++ b/basic/qa/vba_tests/constants.vb @@ -25,6 +25,15 @@ Sub verify_testConstants() TestUtil.AssertEqual(vbNewLine, vbLf, "vbNewline") End If + ' tdf#153543 - check for vba shell constants + ' See https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-constants + TestUtil.AssertEqual(vbHide, 0, "vbHide") + TestUtil.AssertEqual(vbNormalFocus, 1, "vbNormalFocus") + TestUtil.AssertEqual(vbMinimizedFocus, 2, "vbMinimizedFocus") + TestUtil.AssertEqual(vbMaximizedFocus, 3, "vbMaximizedFocus") + TestUtil.AssertEqual(vbNormalNoFocus, 4, "vbNormalNoFocus") + TestUtil.AssertEqual(vbMinimizedNoFocus, 6, "vbMinimizedNoFocus") + ' tdf#131563 - check for vba color constants ' See https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants TestUtil.AssertEqual(vbBlack, RGB(0, 0, 0), "vbBlack") diff --git a/basic/qa/vba_tests/cstr.vb b/basic/qa/vba_tests/cstr.vb index dfa77b7db1f0..5eb43738f10c 100644 --- a/basic/qa/vba_tests/cstr.vb +++ b/basic/qa/vba_tests/cstr.vb @@ -24,6 +24,7 @@ Sub verify_testCStr() TestUtil.AssertEqual(CStr(500), "500", "CStr(500)") ' tdf#143575 - round string to their nearest double representation + ' N.B.: check also how current conversion rounds a close number ' Without the fix in place, this test would have failed with: ' - Expected: 691.2 ' - Actual : 691.2000000000001 diff --git a/basic/qa/vba_tests/format.vb b/basic/qa/vba_tests/format.vb index 0e997ca824db..67abc5ffe24a 100644 --- a/basic/qa/vba_tests/format.vb +++ b/basic/qa/vba_tests/format.vb @@ -135,7 +135,7 @@ Sub Custom_Number_Format_Sample() TestUtil.AssertEqual(Format(12345.25, "#,###.##"), "12,345.25", "Format(12345.25, ""#,###.##"")") TestUtil.AssertEqual(Format(0.25, "##.00%"), "25.00%", "Format(0.25, ""##.00%"")") TestUtil.AssertEqual(Format(1000000, "#,###"), "1,000,000", "Format(1000000, ""#,###"")") - TestUtil.AssertEqual(Format(1.09837555, "#.#####E+###"), "1.09838E+000", "Format(1.09837555, ""#.#####E+###"")") + TestUtil.AssertEqual(Format(1.09837555, "#.#####E+000"), "1.09838E+000", "Format(1.09837555, ""#.#####E+000"")") TestUtil.AssertEqual(Format(1.09837555, "###.####E#"), "1.0984E0", "Format(1.09837555, ""###.####E#"")") TestUtil.AssertEqual(Format(1098.37555, "###.####E#"), "1.0984E3", "Format(1098.37555, ""###.####E#"")") TestUtil.AssertEqual(Format(1098375.55, "###.####E#"), "1.0984E6", "Format(1098375.55, ""###.####E#"")") @@ -148,7 +148,8 @@ Sub Custom_Number_Format_Sample() TestUtil.AssertEqual(Format(123456, "####E0"), "12E4", "Format(123456, ""####E0"")") TestUtil.AssertEqual(Format(2345.25, "$#,###.##"), "$2,345.25", "Format(2345.25, ""$#,###.##"")") TestUtil.AssertEqual(Format(0.25, "##.###\%"), ".25%", "Format(0.25, ""##.###\%"")") - TestUtil.AssertEqual(Format(12.25, "0.???"), "12.25 ", "Format(12.25, ""0.???"")") + ' tdf#158890 blank replaced by figure blank + TestUtil.AssertEqual(Format(12.25, "0.???"), "12.25 ", "Format(12.25, ""0.???"")") Exit Sub errorHandler: diff --git a/basic/qa/vba_tests/formatpercent.vb b/basic/qa/vba_tests/formatpercent.vb new file mode 100644 index 000000000000..0a8c551c27f1 --- /dev/null +++ b/basic/qa/vba_tests/formatpercent.vb @@ -0,0 +1,31 @@ +' +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + +Option VBASupport 1 +Option Explicit + +Function doUnitTest() As String + TestUtil.TestInit + verify_testFormatPercent + doUnitTest = TestUtil.GetResult() +End Function + +Sub verify_testFormatPercent() + On Error GoTo errorHandler + + TestUtil.AssertEqual(FormatPercent("12.2", 2, vbFalse, vbFalse, vbFalse), "1220.00%", "FormatPercent(""12.2"", 2, vbFalse, vbFalse, vbFalse)") + TestUtil.AssertEqual(FormatPercent("-.2", 2, vbTrue, vbFalse, vbFalse), "-20.00%", "FormatPercent(""-.2"", 20, vbTrue, vbFalse, vbFalse)") + TestUtil.AssertEqual(FormatPercent("-0.2", 2, vbFalse, vbFalse, vbFalse), "-20.00%", "FormatPercent(""-0.2"", 20, vbFalse, vbFalse, vbFalse)") + TestUtil.AssertEqual(FormatPercent("-0.2", -1, vbFalse, vbTrue, vbFalse), "(20.00)%", "FormatPercent(""-0.2"", -1, vbFalse, vbTrue, vbFalse)") + TestUtil.AssertEqual(FormatPercent("-0.2", -1, vbUseDefault, vbTrue, vbFalse), "(20.00)%", "FormatPercent(""-0.2"", -1, vbUseDefault, vbTrue, vbFalse)") + TestUtil.AssertEqual(FormatPercent("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue), "-1,234,567,800.00%", "FormatPercent(""-12345678"", -1, vbUseDefault, vbUseDefault, vbTrue)") + + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testFormatPercent", Err, Error$, Erl) +End Sub diff --git a/basic/qa/vba_tests/instrrev.vb b/basic/qa/vba_tests/instrrev.vb index 7d047fc74aa6..3849d60c5f7e 100644 --- a/basic/qa/vba_tests/instrrev.vb +++ b/basic/qa/vba_tests/instrrev.vb @@ -37,6 +37,13 @@ Sub verify_testInStrRev() ' This test should fail after tdf#110003 has been fixed. TestUtil.AssertEqual(InStrRev("Straße", "s", -1, 1), 5, "InStrRev(""Straße"", ""s"", -1, 1)") + ' tdf#141474 keyword names need to match that of VBA + Const vbBinaryCompare = 0, vbTextCompare = 1 + TestUtil.AssertEqual(InStrRev(stringMatch:="Star", stringCheck:="LibreOffice"), 0, "InStrRev(stringMatch:=""Star"", stringCheck:=""LibreOffice"")") + TestUtil.AssertEqual(InStrRev(Start:=-1, stringMatch:="Libre", stringCheck:="LibreOfficeLibre"), 12, "InStrRev(Start:=-1, stringMatch:=""Libre"", stringCheck:=""LibreOfficeLibre"")") + TestUtil.AssertEqual(InStrRev(Start:=12, stringMatch:="Libre", stringCheck:="LibreOfficeLibre"), 1, "InStrRev(Start:=12, stringMatch:=""Libre"", stringCheck:=""LibreOfficeLibre"")") + TestUtil.AssertEqual(InStrRev(Compare:=vbBinaryCompare, Start:=12, stringMatch:="Libre", stringCheck:="LibreOfficeLibre"), 1, "InStrRev(Compare:=vbBinaryCompare, Start:=12, stringMatch:=""Libre"", stringCheck:=""LibreOfficeLibre"")") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testInStrRev", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/join.vb b/basic/qa/vba_tests/join.vb index c4f568f812e1..8d6dd46dcd65 100644 --- a/basic/qa/vba_tests/join.vb +++ b/basic/qa/vba_tests/join.vb @@ -27,6 +27,11 @@ Sub verify_testJoin() TestUtil.AssertEqual(Join(vaArray, "<>"), "string1<>string2<>string3", "Join(vaArray, ""<>"")") TestUtil.AssertEqual(Join(vaArray, ""), "string1string2string3", "Join(vaArray, """")") + ' tdf#141474 keyword names need to match that of VBA + Dim aList(0 to 7) As String : aList = Array("(", "Star", "|", "Open", "|", "Libre", ")", "Office") + TestUtil.AssertEqual(Join(sourceArray:=aList), "( Star | Open | Libre ) Office", "Join() with 1 keyword name") + TestUtil.AssertEqual(Join(delimiter:="", sourceArray:=aList), "(Star|Open|Libre)Office", "Join() with 2 keyword names") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testJoin", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/left.vb b/basic/qa/vba_tests/left.vb index 047497ef0333..21ce3cefc6e0 100644 --- a/basic/qa/vba_tests/left.vb +++ b/basic/qa/vba_tests/left.vb @@ -22,6 +22,9 @@ Sub verify_testLeft() TestUtil.AssertEqual(Left("sometext", 48), "sometext", "Left(""sometext"", 48)") TestUtil.AssertEqual(Left("", 4), "", "Left("""", 4)") + ' tdf#141474 keyword names need to match that of VBA + TestUtil.AssertEqual(Left(Length:=4, String:="sometext"), "some", "Left(Length:=4, String:=""sometext"")") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testLeft", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/like.vb b/basic/qa/vba_tests/like.vb new file mode 100644 index 000000000000..c3be1e081b16 --- /dev/null +++ b/basic/qa/vba_tests/like.vb @@ -0,0 +1,42 @@ +' +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + +Option VBASupport 1 +Option Explicit + +Function doUnitTest() As String + TestUtil.TestInit + verify_testLike + doUnitTest = TestUtil.GetResult() +End Function + +Sub verify_testLike() + On Error GoTo errorHandler + ' Negation test + TestUtil.AssertEqual("!" Like "[.!?]", True, "Negation1") + TestUtil.AssertEqual("a" Like "[!abc]", False, "Negation2") + TestUtil.AssertEqual("!" Like "[!!?]", False, "Negation3") + TestUtil.AssertEqual("^" Like "[.!?]", False, "Negation4") + TestUtil.AssertEqual("^" Like "[.^?]", True, "Negation5") + ' Like test from microsoft vba + TestUtil.AssertEqual("aBBBa" Like "a*a", True, "Like1") + TestUtil.AssertEqual("F" Like "[A-Z]", True, "Like2") + TestUtil.AssertEqual("F" Like "[!A-Z]", False, "Like3") + TestUtil.AssertEqual("a2a" Like "a#a", True, "Like4") + TestUtil.AssertEqual("aM5b" Like "a[L-P]#[!c-e]", True, "Like5") + TestUtil.AssertEqual("BAT123khg" Like "B?T*", True, "Like6") + TestUtil.AssertEqual("CAT123khg" Like "B?T*", False, "Like7") + TestUtil.AssertEqual("ab" Like "a*b", True, "Like8") + TestUtil.AssertEqual("a*b" Like "a [*]b", False, "Like9") + TestUtil.AssertEqual("axxxxxb" Like "a [*]b", False, "Like10") + TestUtil.AssertEqual("a [xyz" Like "a [[]*", True, "Like11") + + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testLike", Err, Error$, Erl) +End Sub diff --git a/basic/qa/vba_tests/mid.vb b/basic/qa/vba_tests/mid.vb index 863e24784512..ebd326109f5d 100644 --- a/basic/qa/vba_tests/mid.vb +++ b/basic/qa/vba_tests/mid.vb @@ -22,6 +22,10 @@ Sub verify_testMid() TestUtil.AssertEqual(Mid("Mid Function Demo", 14, 4), "Demo", "Mid(""Mid Function Demo"", 14, 4)") TestUtil.AssertEqual(Mid("Mid Function Demo", 5), "Function Demo", "Mid(""Mid Function Demo"", 5)") + ' tdf#141474 keyword names need to match that of VBA + TestUtil.AssertEqual(Mid(start:=6, string:="LibreOffice" ), "Office", "Mid() with 2 keyword names" ) + TestUtil.AssertEqual(Mid(length:=5, start:=1, string:="LibreOffice" ), "Libre", "Mid() with 3 keyword names" ) + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testMid", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb index b1a591b0c94d..9817aa7437dc 100644 --- a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb +++ b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb @@ -1,3 +1,11 @@ +' +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + Option VBASupport 1 Function doUnitTest(TestData as String, Driver as String) as String Rem Ensure object assignment is by reference diff --git a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb index d68664b41b72..9a0a557cdf31 100644 --- a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb +++ b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb @@ -1,3 +1,11 @@ +' +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + Option VBASupport 1 Function doUnitTest(TestData as String, Driver as String) as String Rem Ensure object assignment is by reference diff --git a/basic/qa/vba_tests/right.vb b/basic/qa/vba_tests/right.vb index c7cb583724d1..742fc43c3b79 100644 --- a/basic/qa/vba_tests/right.vb +++ b/basic/qa/vba_tests/right.vb @@ -22,6 +22,9 @@ Sub verify_testRight() TestUtil.AssertEqual(Right("sometext", 48), "sometext", "Right(""sometext"", 48)") TestUtil.AssertEqual(Right("", 4), "", "Right("""", 4)") + ' tdf#141474 keyword names need to match that of VBA + TestUtil.AssertEqual(Right(Length:=4, String:="sometext"), "text", "Right(Length:=4, String:=""sometext"")") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testRight", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/split.vb b/basic/qa/vba_tests/split.vb index 56d4522180b0..13f4d66a9539 100644 --- a/basic/qa/vba_tests/split.vb +++ b/basic/qa/vba_tests/split.vb @@ -51,6 +51,12 @@ Sub verify_testSplit ' - Actual : 8200 (8192 for Array and 8 for String) TestUtil.AssertEqual(VarType(splitArr(0)), 8, "VarType(splitArr(0))") + ' tdf#141474 keyword names need to match that of VBA + TestUtil.AssertEqual(Split(expression:="LibreOffice StarOffice")(1), "StarOffice", "Split with 1 keyword name" ) + Dim txt As String : txt = "Libre_Office_Star_Office" + TestUtil.AssertEqual(Split(delimiter:="_", expression:=txt)(2), "Star", "Split with 2 keyword names" ) + TestUtil.AssertEqual(Split(limit:=3, delimiter:="_", expression:=txt)(2), "Star_Office", "Split with 3 keyword names" ) + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testSplit", Err, Error$, Erl) diff --git a/basic/qa/vba_tests/strconv.vb b/basic/qa/vba_tests/strconv.vb index b0295df428b2..9b7dfaf21866 100644 --- a/basic/qa/vba_tests/strconv.vb +++ b/basic/qa/vba_tests/strconv.vb @@ -18,25 +18,30 @@ End Function Sub verify_testStrConv() On Error GoTo errorHandler - TestUtil.AssertEqual(StrConv("abc EFG hij", vbUpperCase), "ABC EFG HIJ", "StrConv(""abc EFG hij"", vbUpperCase)") - TestUtil.AssertEqual(StrConv("abc EFG hij", vbLowerCase), "abc efg hij", "StrConv(""abc EFG hij"", vbLowerCase)") - TestUtil.AssertEqual(StrConv("abc EFG hij", vbProperCase), "Abc Efg Hij", "StrConv(""abc EFG hij"", vbProperCase)") + TestUtil.AssertEqual(StrConv("abc EFG hij αβγ ΔΕΖ ηθι", vbUpperCase), "ABC EFG HIJ ΑΒΓ ΔΕΖ ΗΘΙ", "StrConv(""abc EFG hij αβγ ΔΕΖ ηθι"", vbUpperCase)") + TestUtil.AssertEqual(StrConv("abc EFG hij αβγ ΔΕΖ ηθι", vbLowerCase), "abc efg hij αβγ δεζ ηθι", "StrConv(""abc EFG hij αβγ ΔΕΖ ηθι"", vbLowerCase)") + TestUtil.AssertEqual(StrConv("abc EFG hij αβγ ΔΕΖ ηθι", vbProperCase), "Abc Efg Hij Αβγ Δεζ Ηθι", "StrConv(""abc EFG hij αβγ ΔΕΖ ηθι"", vbProperCase)") ' Converts narrow (single-byte) characters in string to wide TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥¥å©", vbWide), "ABCDEVB¥ì¥¹¥¥å©", "StrConv(""ABCDEVB¥ì¥¹¥¥å©"", vbWide)") + TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥¥å©", vbWide + vbLowerCase), "abcdevb¥ì¥¹¥¥å©", "StrConv(""ABCDEVB¥ì¥¹¥¥å©"", vbWide + vbLowerCase)") ' Converts wide (double-byte) characters in string to narrow (single-byte) characters TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow), "ABCD@$%23'?EG", "StrConv(""ABCD@$%23'?EG"", vbNarrow)") + TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow + vbLowerCase), "abcd@$%23'?eg", "StrConv(""ABCD@$%23'?EG"", vbNarrow + vbLowerCase)") ' Converts Hiragana characters in string to Katakana characters TestUtil.AssertEqual(StrConv("かたかな", vbKatakana), "カタカナ", "StrConv(""かたかな"", vbKatakana)") + TestUtil.AssertEqual(StrConv("かたかな abc", vbKatakana + vbUpperCase + vbWide), "カタカナ ABC", "StrConv(""かたかな abc"", vbKatakana + vbUpperCase + vbWide)") ' Converts Katakana characters in string to Hiragana characters TestUtil.AssertEqual(StrConv("カタカナ", vbHiragana), "かたかな", "StrConv(""カタカナ"", vbHiragana)") + TestUtil.AssertEqual(StrConv("カタカナ ABC", vbLowerCase + vbNarrow), "カタカナ abc", "StrConv(""カタカナ ABC"", vbLowerCase + vbNarrow)") - ' Assumes CP-1252 encoding associated with en-US locale used in unit tests. Dim x() As Byte - x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode) + Const Cp1252TestString = "ÉϺ£ÊÐABC" + + x = StrConv(Cp1252TestString, vbFromUnicode, &h0409)' CP-1252 encoding associated with en-US locale TestUtil.AssertEqual(UBound(x), 8, "UBound(x)") TestUtil.AssertEqual(x(0), 201, "x(0)") TestUtil.AssertEqual(x(1), 207, "x(1)") @@ -47,7 +52,11 @@ Sub verify_testStrConv() TestUtil.AssertEqual(x(6), 65, "x(6)") TestUtil.AssertEqual(x(7), 66, "x(7)") TestUtil.AssertEqual(x(8), 67, "x(8)") - TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, vbUnicode)") + TestUtil.AssertEqual(StrConv(x, vbUnicode, &h0409), Cp1252TestString, "StrConv(x, vbUnicode, &h0409)") + + x = StrConv(Cp1252TestString, vbUnicode, &h0409) + TestUtil.AssertEqual(UBound(x), 35, "UBound(x)") + TestUtil.AssertEqual(StrConv(x, vbFromUnicode, &h0409), Cp1252TestString, "StrConv(x, vbFromUnicode, &h0409)") Exit Sub errorHandler: diff --git a/basic/qa/vba_tests/string.vb b/basic/qa/vba_tests/string.vb index eca3fce3baec..239141d8173f 100644 --- a/basic/qa/vba_tests/string.vb +++ b/basic/qa/vba_tests/string.vb @@ -11,18 +11,22 @@ Option Explicit Function doUnitTest() As String TestUtil.TestInit - verify_testString + verify_String doUnitTest = TestUtil.GetResult() End Function -Sub verify_testString() +Sub verify_String() On Error GoTo errorHandler TestUtil.AssertEqual(String(5, "P"), "PPPPP", "String(5, ""P"")") TestUtil.AssertEqual(String(5, "a"), "aaaaa", "String(5, ""a"")") TestUtil.AssertEqual(String(0, "P"), "", "String(0, ""P"")") + TestUtil.AssertEqual(String(5.8, "à"), "àààààà", "String(5.8, ""à"")") + TestUtil.AssertEqual(String(Number:=3.45, Character:="test"), "ttt", "String(Number:=3.45, Character:=""test"")") + TestUtil.AssertEqual(String(Character:="☺😎", Number:=7), "☺☺☺☺☺☺☺", "String(Character:=""☺😎"", Number:=7)") + Exit Sub errorHandler: - TestUtil.ReportErrorHandler("verify_testString", Err, Error$, Erl) + TestUtil.ReportErrorHandler("verify_String", Err, Error$, Erl) End Sub diff --git a/basic/qa/vba_tests/tdf147089_idiv.vb b/basic/qa/vba_tests/tdf147089_idiv.vb new file mode 100644 index 000000000000..515f1e00cf63 --- /dev/null +++ b/basic/qa/vba_tests/tdf147089_idiv.vb @@ -0,0 +1,31 @@ +'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+ +Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIDiv
+ doUnitTest = TestUtil.GetResult()
+End Function +
+Sub verify_testIDiv + On Error GoTo errorHandler
+
+ ' tdf#147089 - IDIV operands are rounded to Integer values before the operation is performed
+ TestUtil.AssertEqual(8.4 \ 2, 4, "8.4 \ 2")
+ TestUtil.AssertEqual(9.9 \ 2, 5, "9.9 \ 2")
+ TestUtil.AssertEqual(20 \ 4.9, 4, "20 \ 4.9")
+ TestUtil.AssertEqual(20 \ 4.4, 5, "20 \ 4.4")
+ TestUtil.AssertEqual(16.4 \ 5.9, 2, "16.4 \ 5.9")
+
+ Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testIDiv", Err, Error$, Erl) +End Sub diff --git a/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb new file mode 100644 index 000000000000..e599f46eedf1 --- /dev/null +++ b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb @@ -0,0 +1,37 @@ +'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+ +Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testOptionalParametersMsgBox
+ doUnitTest = TestUtil.GetResult()
+End Function +
+Sub verify_testOptionalParametersMsgBox + On Error GoTo errorHandler
+
+ ' tdf#147529 - check for missing optional parameters
+ TestUtil.AssertEqual(TestOptionalParametersMsgBox(), True, "TestOptionalParametersMsgBox()")
+
+ Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testOptionalParametersMsgBox", Err, Error$, Erl) +End Sub
+
+Function TestOptionalParametersMsgBox(Optional text, Optional dialogType, Optional dialogTitle) As Boolean
+On Error GoTo errorHandler
+ MsgBox text, dialogType, dialogTitle
+ TestOptionalParametersMsgBox = False
+ Exit Function
+errorHandler:
+ TestUtil.AssertEqual(Err, 449, "Argument not optional (Error 449)")
+ TestOptionalParametersMsgBox = True
+End Function
diff --git a/basic/qa/vba_tests/tdf148358_non_ascii_names.vb b/basic/qa/vba_tests/tdf148358_non_ascii_names.vb new file mode 100644 index 000000000000..95e7105407f5 --- /dev/null +++ b/basic/qa/vba_tests/tdf148358_non_ascii_names.vb @@ -0,0 +1,33 @@ +' +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + +Option VBASupport 1 +Option Explicit + +Function doUnitTest as String + TestUtil.TestInit + verify_testNonAsciiNames + doUnitTest = TestUtil.GetResult() +End Function + +Function TestNonAscii as Integer + Dim Абв as Integer + Абв = 10 + TestNonAscii = абв +End Function + +Sub verify_testNonAsciiNames + On Error GoTo errorHandler + + ' tdf#148358 - compare Non-ASCII variable names case-insensitive + TestUtil.AssertEqual(TestNonAscii(), 10, "TestNonAscii()") + + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testNonAsciiNames", Err, Error$, Erl) +End Sub diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb index 98bfd58feda4..b21d34cc4e0e 100644 --- a/basic/qa/vba_tests/typename.vb +++ b/basic/qa/vba_tests/typename.vb @@ -32,6 +32,8 @@ Sub verify_testTypeName() Dim TestCurrSign@ Dim TestStrSign$ + TestUtil.AssertEqual(TypeName(varname:=s1), "String", "TypeName(varname:=s1") + TestUtil.AssertEqual(TypeName(s1), "String", "TypeName(s1)") TestUtil.AssertEqual(TypeName(b1), "Boolean", "TypeName(b1)") TestUtil.AssertEqual(TypeName(c1), "Byte", "TypeName(c1)") diff --git a/basic/qa/vba_tests/vartype.vb b/basic/qa/vba_tests/vartype.vb index 2d8345ed1d86..066255b2b7e3 100644 --- a/basic/qa/vba_tests/vartype.vb +++ b/basic/qa/vba_tests/vartype.vb @@ -42,6 +42,8 @@ Sub verify_testVarType() TestUtil.AssertEqual(vbString, 8, "vbString") TestUtil.AssertEqual(vbBoolean, 11, "vbBoolean") + TestUtil.AssertEqual(VarType(varname:=TestStr), vbString, "VarType(varname:=TestStr)") + TestUtil.AssertEqual(VarType(TestStr), vbString, "VarType(TestStr)") TestUtil.AssertEqual(VarType(TestBoo), vbBoolean, "VarType(TestBoo)") TestUtil.AssertEqual(VarType(TestDouble), vbDouble, "VarType(TestDouble)") |