File: exceptionclient.F90

package info (click to toggle)
babel 0.10.2-1
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 43,932 kB
  • ctags: 29,707
  • sloc: java: 74,695; ansic: 73,142; cpp: 40,649; sh: 18,411; f90: 10,062; fortran: 6,727; python: 6,406; makefile: 3,866; xml: 118; perl: 48
file content (204 lines) | stat: -rw-r--r-- 5,718 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
!
! File:       exceptionclient.F90
! Copyright:  (c) 2001-2002 The Regents of the University of California
! Revision:   @(#) $Revision: 4434 $
! Date:       $Date: 2005-03-17 09:05:29 -0800 (Thu, 17 Mar 2005) $
! Description:Simple F90 exception test client
!
!
#include "sidl_BaseInterface_fAbbrev.h"
#include "sidl_SIDLException_fAbbrev.h"
#include "ExceptionTest_Fib_fAbbrev.h"
#include "synch_RegOut_fAbbrev.h"

subroutine starttest(number)
  use synch_RegOut
  implicit none
  integer (selected_int_kind(9)) :: number
  type(synch_RegOut_t) :: tracker
  call getInstance(tracker)
  call startPart(tracker, number)
  call deleteRef(tracker)
end subroutine starttest

subroutine reporttest(test, number)
  use synch_RegOut
  use synch_ResultType
  implicit none
  integer (selected_int_kind(9)) :: number
  type(synch_RegOut_t) :: tracker
  logical                        :: test
  call getInstance(tracker)
  if (test) then
     call endPart(tracker, number, PASS)
  else
     call endPart(tracker, number, FAIL)
  endif
  number = number + 1
  call deleteRef(tracker)
end subroutine reporttest

subroutine reportexc(sExcept)
  use sidl_SIDLException
  implicit none
  type(sidl_SIDLException_t)  :: sExcept
  character (len=100)         :: msg
  character (len=1024)        :: trace

  call getNote(sExcept, msg)
  write (6, *) msg
  call getTrace(sExcept, trace)
  write (6, *) trace
end subroutine reportexc

subroutine testnone(fib, test)
  use ExceptionTest_Fib
  use sidl_BaseInterface
  use sidl_SIDLException
  implicit none
  type(ExceptionTest_Fib_t)      :: fib
  type(sidl_BaseInterface_t)     :: iExcept
  type(sidl_SIDLException_t)     :: sExcept
  integer (selected_int_kind(9)) :: test
  integer (selected_int_kind(9)) :: retval

  call starttest(test)
  call getFib(fib, 10, 25, 200, 0, retval, iExcept)
  if (is_null(iExcept)) then
     call reporttest(.true., test)
     write (6, 100) retval
  else
     call reporttest(.false., test)
     call cast(iExcept, sExcept)
     call reportexc(sExcept)
     call deleteRef(sExcept)
  endif
100 format ('fib= ', I4)
end subroutine testnone

subroutine testneg(fib, test)
  use sidl_BaseInterface
  use sidl_SIDLException
  use ExceptionTest_Fib
  implicit none
  type(ExceptionTest_Fib_t)      :: fib
  type(sidl_BaseInterface_t)     :: iExcept
  type(sidl_SIDLException_t)     :: sExcept
  integer (selected_int_kind(9)) :: test
  integer (selected_int_kind(9)) :: retval
  logical                        :: isone

  call starttest(test)
  call getFib(fib, -1, 10, 10, 0, retval, iExcept)
  if (is_null(iExcept)) then
     call reporttest(.false., test)
     write (6, 100) retval
  else
     call isType(iExcept, &
          'ExceptionTest.NegativeValueException', isone)
     if (isone .eqv. .true.) then
        call reporttest(.true., test)
     else
        call reporttest(.false., test)
     endif
     call cast(iExcept, sExcept)
     call reportexc(sExcept)
     call deleteRef(sExcept)
  endif
100 format ('fib= ', I4)
end subroutine testneg

subroutine testdeep(fib, test)
  use sidl_BaseInterface
  use sidl_SIDLException
  use ExceptionTest_Fib
  implicit none
  type(ExceptionTest_Fib_t)      :: fib
  type(sidl_BaseInterface_t)     :: iExcept
  type(sidl_SIDLException_t)     :: sExcept
  integer (selected_int_kind(9)) :: test
  integer (selected_int_kind(9)) :: retval
  logical                        :: isone

  call starttest(test)
  call getFib (fib, 10, 1, 100, 0, retval, iExcept)
  if (is_null(iExcept)) then
     call reporttest(.false., test)
     write (6, 100) retval
  else
     call isType(iExcept, 'ExceptionTest.TooDeepException', &
          isone)
     if (isone .eqv. .true.) then
        call reporttest(.true., test)
     else
        call reporttest(.false., test)
     endif
     call cast(iExcept, sExcept)
     call reportexc(sExcept)
     call deleteRef(sExcept)
  endif
100 format ('fib= ', I4)
end subroutine testdeep

subroutine testbig(fib, test)
  use sidl_BaseInterface
  use sidl_SIDLException
  use ExceptionTest_Fib
  implicit none
  type(ExceptionTest_Fib_t)      :: fib
  type(sidl_BaseInterface_t)     :: iExcept
  type(sidl_SIDLException_t)     :: sExcept
  integer (selected_int_kind(9)) :: test
  integer (selected_int_kind(9)) :: retval
  integer (selected_int_kind(9)), parameter :: n = 10, max_depth = 100, &
       depth = 0, maxvalue = 1
  logical                        :: isone

  call starttest(test)
  call getFib(fib, n, max_depth, depth, maxvalue, retval, iExcept)
  if (is_null(iExcept)) then
     call reporttest(.false., test)
     write (6, 100) retval
  else
     call isType(iExcept, 'ExceptionTest.TooBigException', &
          isone)
     if (isone .eqv. .true.) then
        call reporttest(.true., test)
     else
        call reporttest(.false., test)
     endif
     call cast(iExcept, sExcept)
     call reportexc(sExcept)
     call deleteRef(sExcept)
  endif
100 format ('fib= ', I4)
end subroutine testbig


program exceptionclient
  use ExceptionTest_Fib
  use synch_RegOut
  implicit none
  integer (selected_int_kind(9))  :: test
  type(synch_RegOut_t)            :: tracker
  type(ExceptionTest_Fib_t)       :: fib

  call getInstance(tracker)
  call setExpectations(tracker, 4)
  call new(fib)

  test = 1

  call writeComment(tracker, 'No Exception test            ')
  call testnone(fib, test)
  call writeComment(tracker, 'Negative Value Exception test')
  call testneg(fib, test)
  call writeComment(tracker, 'Too Deep Exception test      ')
  call testdeep(fib, test)
  call writeComment(tracker, 'Too Big Exception test       ')
  call testbig(fib, test)

  call deleteRef(fib)
  call close(tracker)
  call deleteRef(tracker)
end program exceptionclient