| 1 |
' This file is part of the LibreOffice project. |
| 2 |
' |
| 3 |
' This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
' License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
' file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 |
|
| 7 |
Option Explicit |
| 8 |
|
| 9 |
Function overflow1 as Integer |
| 10 |
On Error GoTo handler |
| 11 |
Chr(-32769) |
| 12 |
overflow1 = 0 |
| 13 |
Exit Function |
| 14 |
handler: |
| 15 |
if (Err <> 6) Then |
| 16 |
overflow1 = 0 |
| 17 |
Exit Function |
| 18 |
Endif |
| 19 |
overflow1 = 1 |
| 20 |
End Function |
| 21 |
|
| 22 |
Function overflow2 as Integer |
| 23 |
On Error GoTo handler |
| 24 |
Chr(65536) |
| 25 |
overflow2 = 0 |
| 26 |
Exit Function |
| 27 |
handler: |
| 28 |
if (Err <> 6) Then |
| 29 |
overflow2 = 0 |
| 30 |
Exit Function |
| 31 |
Endif |
| 32 |
overflow2 = 1 |
| 33 |
End Function |
| 34 |
|
| 35 |
Function overflow3 as Integer |
| 36 |
On Error GoTo handler |
| 37 |
Chr(&H10000) |
| 38 |
overflow3 = 0 |
| 39 |
Exit Function |
| 40 |
handler: |
| 41 |
if (Err <> 6) Then |
| 42 |
overflow3 = 0 |
| 43 |
Exit Function |
| 44 |
Endif |
| 45 |
overflow3 = 1 |
| 46 |
End Function |
| 47 |
|
| 48 |
Function doUnitTest as String |
| 49 |
Chr(-32768) |
| 50 |
Chr(65535) |
| 51 |
Chr(&H8000) |
| 52 |
Chr(&HFFFF) |
| 53 |
if (overflow1 = 0) Then |
| 54 |
doUnitTest = "FAIL" |
| 55 |
Exit Function |
| 56 |
Endif |
| 57 |
if (overflow2 = 0) Then |
| 58 |
doUnitTest = "FAIL" |
| 59 |
Exit Function |
| 60 |
Endif |
| 61 |
if (overflow3 = 0) Then |
| 62 |
doUnitTest = "FAIL" |
| 63 |
Exit Function |
| 64 |
Endif |
| 65 |
doUnitTest = "OK" |
| 66 |
End Function |