Rename LibreOffice Basic test files from .vb to .bas: they are not VBA
[LibreOffice.git] / basic / qa / basic_coverage / test_string_overflow_safe.bas
blobf245e14abc4ead7f6063dd9dc836ee68bcce5295
1 Option Explicit
3 Function doUnitTest As String
4 ' Trying to create too long string should generate proper BASIC overflow error.
5 ' Longest possible string is 2147483638 wchar_t (2G - 10).
6 ' This tries to create string with 2G wchar_t. If it does not overflow, test fails.
7 ' If overflow is not safe, it segfaults.
8 On Error GoTo errorHandler
9 Dim s As String, i As Integer
10 s = "0"
11 For i=1 To 31
12 s = s & s
13 Next i
14 doUnitTest = "FAIL"
15 Exit Function
16 errorHandler:
17 If ( Err <> 6 ) Then
18 doUnitTest = "FAIL"
19 Else
20 doUnitTest = "OK"
21 Endif
22 End Function