summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-10-22 21:54:37 +0200
committerLaurent BP <laurent.balland-poirier@laposte.net>2016-11-22 09:30:41 +0000
commit8a50ea54546a51fc7a2a28174031e7351dbed10e (patch)
treed4da3c20be85735a5a24e48c67d19c7b2034b0bc /basic
parentf9f7a4ddaed85427522834597271967ee494b436 (diff)
tdf#102872 Add qa unit test for BASIC methods
Add test if several methods still works Change-Id: I8d26e5e3555dbbc0f07152138e1bc0cd65d90998 Reviewed-on: https://gerrit.libreoffice.org/30166 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org> Tested-by: jan iversen <jani@documentfoundation.org> Reviewed-by: Laurent BP <laurent.balland-poirier@laposte.net>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/basic_coverage/test_array_methods.vb38
-rw-r--r--basic/qa/basic_coverage/test_conversion_methods.vb59
-rw-r--r--basic/qa/basic_coverage/test_datetime_methods.vb77
-rw-r--r--basic/qa/basic_coverage/test_logic_methods.vb56
-rw-r--r--basic/qa/basic_coverage/test_math_methods.vb73
-rw-r--r--basic/qa/basic_coverage/test_string_methods.vb107
-rw-r--r--basic/qa/basic_coverage/test_system_methods.vb29
7 files changed, 439 insertions, 0 deletions
diff --git a/basic/qa/basic_coverage/test_array_methods.vb b/basic/qa/basic_coverage/test_array_methods.vb
new file mode 100644
index 000000000000..093867a85440
--- /dev/null
+++ b/basic/qa/basic_coverage/test_array_methods.vb
@@ -0,0 +1,38 @@
+'
+' 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/.
+'
+
+Function doUnitTest as Integer
+ dim aVector as Variant
+ ' ARRAY
+ aVector = Array( Date(), Time(), "Hello", -3.14)
+ If (aVector(2) <> "Hello") Then
+ doUnitTest = 0
+ ' LBOUND
+ Else If ( LBound( aVector() ) <> 0 ) Then
+ doUnitTest = 0
+ ' TYPELEN
+ Else If ( TypeLen(aVector(2)) <> 5 ) Then
+ doUnitTest = 0
+ ' TYPENAME
+ Else If ( TypeName(aVector(2)) <> "String" ) Then
+ doUnitTest = 0
+ ' UBOUND
+ Else If ( UBound( aVector() ) <> 3 ) Then
+ doUnitTest = 0
+ ' VARTYPE
+ Else If ( VarType(aVector(2)) <> 8 ) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_conversion_methods.vb b/basic/qa/basic_coverage/test_conversion_methods.vb
new file mode 100644
index 000000000000..7790cbc89a83
--- /dev/null
+++ b/basic/qa/basic_coverage/test_conversion_methods.vb
@@ -0,0 +1,59 @@
+'
+' 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/.
+'
+
+Function doUnitTest as Integer
+ Randomize 42
+ dim aVector as Variant
+ aVector = Array( Date(), Time(), "Hello", -3.14)
+ ' CBOOL
+ If (CBool(3) <> True) Then
+ doUnitTest = 0
+ ' CBYTE
+ Else If (CByte("3") <> 3) Then
+ doUnitTest = 0
+ ' CCUR
+ Else If (CCur("100") <> 100) Then
+ doUnitTest = 0
+ ' CDATE
+ Else If (CDate(100) <> 100) Then
+ doUnitTest = 0
+ ' CDEC
+ 'Else If (CDec("100") <> 100) Then
+ ' doUnitTest = 0
+ ' CDBL
+ Else If (CDbl("100") <> 100) Then
+ doUnitTest = 0
+ ' CINT
+ Else If (CInt("100") <> 100) Then
+ doUnitTest = 0
+ ' CLNG
+ Else If (CLng("100") <> 100) Then
+ doUnitTest = 0
+ ' CSNG
+ Else If (CSng("100") <> 100) Then
+ doUnitTest = 0
+ ' CSTR
+ Else If (CStr(100) <> "100") Then
+ doUnitTest = 0
+ ' VAL
+ Else If ( Val("4") <> 4 ) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ 'End If
+End Function
diff --git a/basic/qa/basic_coverage/test_datetime_methods.vb b/basic/qa/basic_coverage/test_datetime_methods.vb
new file mode 100644
index 000000000000..679e1297bac7
--- /dev/null
+++ b/basic/qa/basic_coverage/test_datetime_methods.vb
@@ -0,0 +1,77 @@
+'
+' 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/.
+'
+
+Function doUnitTest as Integer
+ dim aVector as Variant
+ aVector = Array( Date(), Time(), "Hello", -3.14)
+ ' CDateFromUnoDate
+ ' CDateTomUnoDate
+ ' CDateFromUnoTime
+ ' CDateToUnoTime
+ ' CDateFromUnoDateTime
+ ' CDateToUnoDateTime
+ ' CDateFromIso CDateToIso
+ If ( CDateToIso( CDateFromIso("20161016") ) <> "20161016" ) Then
+ doUnitTest = 0
+ ' DATE DATEDIFF DATEADD
+ Else If ( DateDiff( "d", aVector(0), DateAdd("d", 1, aVector(0)) ) <> 1 ) Then
+ doUnitTest = 0
+ ' DATEPART DAY
+ Else If ( DatePart( "d", aVector(0) ) <> Day( aVector(0) ) ) Then
+ doUnitTest = 0
+ ' DATESERIAL DATEVALUE
+ Else If ( DateSerial( 2016, 10, 16 ) <> DateValue("October 16, 2016") ) Then
+ doUnitTest = 0
+ ' FormatDateTime
+ ' HOUR
+ Else If ( Hour(aVector(1)) <> Hour(aVector(1)) ) Then
+ doUnitTest = 0
+ ' MINUTE
+ Else If ( Minute(aVector(1)) <> Minute(aVector(1)) ) Then
+ doUnitTest = 0
+ ' MONTH
+ Else If ( DatePart( "m", aVector(0) ) <> Month( aVector(0) ) ) Then
+ doUnitTest = 0
+ ' MONTHNAME
+ 'Else If ( CDate( MonthName(10)&" 16, 2016" ) <> DateSerial(2016, 10, 16) ) Then
+ ' doUnitTest = 0
+ ' NOW TIMEVALUE
+ Else If ( Now() < aVector(0) + TimeValue(aVector(1)) ) Then
+ doUnitTest = 0
+ ' SECOND
+ Else If ( Second(aVector(1)) <> Second(aVector(1)) ) Then
+ doUnitTest = 0
+ ' TIMER max value = 24*3600
+ Else If ( Timer() > 86400 ) Then
+ doUnitTest = 0
+ ' TIMESERIAL TIMEVALUE
+ Else If ( TimeSerial(13,54,48) <> TImeValue("13:54:48") ) Then
+ doUnitTest = 0
+ ' WEEKDAY WEEKDAYNAME
+ 'Else If ( WeekdayName( Weekday(aVector(0) ) ) <> WeekDayName( DatePart( "w", aVector(0) ) ) ) Then
+ ' doUnitTest = 0
+ ' YEAR
+ Else If ( DatePart( "yyyy", aVector(0) ) <> Year( aVector(0) ) ) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ 'End If
+ 'End If
+End Function
diff --git a/basic/qa/basic_coverage/test_logic_methods.vb b/basic/qa/basic_coverage/test_logic_methods.vb
new file mode 100644
index 000000000000..cc0bbee8ab2b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_logic_methods.vb
@@ -0,0 +1,56 @@
+'
+' 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/.
+'
+
+Function doUnitTest as Integer
+ dim aVector as Variant
+ aVector = Array( Date(), Time(), "Hello", -3.14)
+ ' CHOOSE
+ If (Choose(2, 1, 100, 3) <> 100) Then
+ doUnitTest = 0
+ ' FALSE TRUE
+ Else If (False = True) Then
+ doUnitTest = 0
+ ' IIF
+ Else If ( IIF(True, 10, 12) <> 10 ) Then
+ doUnitTest = 0
+ ' ISARRAY
+ Else If ( IsArray( aVector ) = False ) Then
+ doUnitTest = 0
+ ' ISDATE
+ Else If ( IsDate( aVector(1) ) = False ) Then
+ doUnitTest = 0
+ ' ISEMPTY
+ Else If ( IsEmpty( aVector(2) ) ) Then
+ doUnitTest = 0
+ ' ISERROR
+ ' ISMISSING
+ ' ISNULL
+ Else If ( IsNull( aVector ) ) Then
+ doUnitTest = 0
+ ' ISNUMERIC
+ Else If ( IsNumeric( aVector(3) ) = False ) Then
+ doUnitTest = 0
+ ' IsUnoStruc
+ ' SWITCH
+ Else If ( Switch( False, aVector(0),_
+ True, aVector(1),_
+ False, aVector(2),_
+ True, aVector(3) ) <> aVector(1) ) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_math_methods.vb b/basic/qa/basic_coverage/test_math_methods.vb
new file mode 100644
index 000000000000..28f27b87e9be
--- /dev/null
+++ b/basic/qa/basic_coverage/test_math_methods.vb
@@ -0,0 +1,73 @@
+' 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/.
+'
+
+Function doUnitTest as Integer
+ Randomize 42
+ dim aVector as Variant
+ aVector = Array( Date(), Time(), "Hello", -3.14)
+ ' ABS
+ If (Abs(-3.5) <> 3.5) Then
+ doUnitTest = 0
+ Else If (Abs(3.5) <> 3.5) Then
+ doUnitTest = 0
+ ' ATN
+ Else If (Atn(1) <> PI/4) Then
+ doUnitTest = 0
+ ' COS SIN
+ Else If ( Abs(Cos(PI/3) - Sin(PI/6)) > 1E-6 ) Then
+ doUnitTest = 0
+ ' EXP LOG
+ Else If ( Log( Exp(1) ) <> 1 ) Then
+ doUnitTest = 0
+ ' FIX
+ Else If (Fix(PI) <> 3) Then
+ doUnitTest = 0
+ ' FRAC
+ Else If ( 3+Frac(PI) <> PI) Then
+ doUnitTest = 0
+ ' HEX
+ Else If ( Hex(100) <> "64") Then
+ doUnitTest = 0
+ ' INT
+ Else If ( Int(PI) <> 3 ) Then
+ doUnitTest = 0
+ ' OCT
+ Else If ( Oct(100) <> "144" ) Then
+ doUnitTest = 0
+ ' ROUND
+ ' Else If ( Round( PI, 2 ) <> 3.14 ) Then
+ ' doUnitTest = 0
+ ' RND
+ Else If ( Rnd >= 1 ) Then
+ doUnitTest = 0
+ ' SGN
+ Else If ( Sgn(aVector(3)) <> -1 ) Then
+ doUnitTest = 0
+ ' SQR
+ Else If ( Sqr( 4 ) <> 2 ) Then
+ doUnitTest = 0
+ ' TAN
+ Else If ( Abs( Tan(PI/4) - 1 ) > 1E-6 ) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ 'End If
+End Function
diff --git a/basic/qa/basic_coverage/test_string_methods.vb b/basic/qa/basic_coverage/test_string_methods.vb
new file mode 100644
index 000000000000..cf2499ed5b9d
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_methods.vb
@@ -0,0 +1,107 @@
+'
+' 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/.
+'
+
+Function doUnitTest as Integer
+ dim aVector as Variant
+ aVector = Array( Date(), Time(), "Hello", -3.14)
+ ' ASC
+ If (Asc("€") <> 8364) Then
+ doUnitTest = 0
+ ' ASCw
+ 'Else If (AscW("€") <> 8364) Then
+ ' doUnitTest = 0
+ ' FORMAT
+ Else If (Format(PI, "0") <> "3") Then
+ doUnitTest = 0
+ ' InStr
+ Else If ( InStr( 1, aVector(2), "l", 1) <> 3 ) Then
+ doUnitTest = 0
+ ' InStrRev
+ 'Else If ( InStrRev( aVector(2), "l" ) <> 4 ) Then
+ ' doUnitTest = 0
+ ' LCASE
+ Else If ( LCase( aVector(2) ) <> "hello" ) Then
+ doUnitTest = 0
+ ' LEFT
+ Else If ( Left( aVector(2), 2 ) <> "He" ) Then
+ doUnitTest = 0
+ ' LEN
+ Else If ( Len( aVector(2) ) <> 5 ) Then
+ doUnitTest = 0
+ ' LENB
+ Else If ( LenB( aVector(2) ) <> 5 ) Then
+ doUnitTest = 0
+ ' LTRIM
+ Else If ( LTrim( " Hello" ) <> aVector(2) ) Then
+ doUnitTest = 0
+ ' MID
+ Else If ( Mid( aVector(2), 2, 2 ) <> "el" ) Then
+ doUnitTest = 0
+ ' REPLACE
+ Else If ( Replace ( aVector(2), "l", "jo", 1, 2 ) <> "Hejojoo" ) Then
+ doUnitTest = 0
+ ' RIGHT
+ Else If ( Right( aVector(2), 2 ) <> "lo" ) Then
+ doUnitTest = 0
+ ' RTRIM
+ Else If ( RTrim( "Hello " ) <> aVector(2) ) Then
+ doUnitTest = 0
+ ' SPACE
+ Else If ( Space(3) <> " " ) Then
+ doUnitTest = 0
+ ' SPC
+ Else If ( Spc(3) <> " " ) Then
+ doUnitTest = 0
+ ' SPLIT
+ Else If ( Split( "Hello world" )(1) <> "world" ) Then
+ doUnitTest = 0
+ ' STR TRIM
+ Else If ( Trim( Str( 4 ) ) <> "4" ) Then
+ doUnitTest = 0
+ ' STRCOMP
+ Else If ( StrComp( aVector(2), "Hello" ) <> 0 ) Then
+ doUnitTest = 0
+ ' StrConv
+ ' STRING
+ Else If ( String( 3, "H" ) <> "HHH" ) Then
+ doUnitTest = 0
+ ' STRREVERSE
+ 'Else If ( StrReverse( aVector(2) ) <> "olleH" ) Then
+ ' doUnitTest = 0
+ ' TAB
+ Else If ( "Hello" & Tab(0) & "World" <> "HelloWorld" ) Then
+ doUnitTest = 0
+ ' UCASE
+ Else If ( UCase( aVector(2) ) <> "HELLO" ) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ End If
+ 'End If
+ 'End If
+ 'End If
+End Function
diff --git a/basic/qa/basic_coverage/test_system_methods.vb b/basic/qa/basic_coverage/test_system_methods.vb
new file mode 100644
index 000000000000..1a76c784bd41
--- /dev/null
+++ b/basic/qa/basic_coverage/test_system_methods.vb
@@ -0,0 +1,29 @@
+'
+' 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/.
+'
+
+Function doUnitTest as Integer
+ Wait(0)
+ Beep
+ 'dim aVector as Variant
+ 'aVector = Array( Date(), Time(), "Hello", -3.14)
+ 'WaitUntil( aVector(0) )
+ ' CompatibilityMode
+ If (CompatibilityMode(True) <> True) Then
+ doUnitTest = 0
+ ' ConvertFromUrl ConvertToUrl
+ Else If ( ConvertToUrl( ConvertFromUrl("") ) <> "") Then
+ doUnitTest = 0
+ ' GetSolarVersion
+ Else If ( GetSolarVersion() < 50000) Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+ End If
+ End If
+End Function