Kaydet (Commit) 8a50ea54 authored tarafından Laurent Balland-Poirier's avatar Laurent Balland-Poirier Kaydeden (comit) Laurent BP

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/30166Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarjan iversen <jani@documentfoundation.org>
Tested-by: 's avatarjan iversen <jani@documentfoundation.org>
Reviewed-by: 's avatarLaurent BP <laurent.balland-poirier@laposte.net>
üst f9f7a4dd
'
' 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
'
' 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
'
' 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
'
' 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
' 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
'
' 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
'
' 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment