File: test_obj_valid.pro

package info (click to toggle)
gnudatalanguage 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80,368 kB
  • sloc: cpp: 189,797; ansic: 46,721; sh: 677; python: 474; makefile: 146; xml: 69; f90: 28
file content (52 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (2)
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
;
; Unknown origin ...
;
; Modifications history :
; -2024-04-15 AC : cleaning (details ...)
;
; -------------------------------------------------

pro TEST_OBJ_VALID, help=help, verbose=verbose, test=test, no_exit=no_exit
;
if KEYWORD_SET(help) then begin
   print, 'TEST_OBJ_VALID, help=help, verbose=verbose, $'
   print, '                test=test, no_exit=no_exit'
   return
endif
;
errors=0
;
llist = LIST(FLTARR(4),"hello",2.)
mlist = LIST("!pi", "goodbye",FINDGEN(3,4),COMPLEX(0))
;
if ~OBJ_VALID(llist) then ERRORS_ADD, errors, 'Not an valid OBJ (1)'
if ~OBJ_VALID(mlist) then ERRORS_ADD, errors, 'Not an valid OBJ (2)'
;
; Particular case for ptr_valid and
; comparison with !NULL that should be the inverse
;
good=[1b,0b]
p=OBJ_NEW('idl_container')
res=[OBJ_VALID(p), p eq !NULL]
if ~ARRAY_EQUAL(res,good, /no_typeconv) then $
   ERRORS_ADD, errors, 'Problem 1 : OBJ_NEW & !null'
;
good=[0b,1b]
OBJ_DESTROY, p
res=[OBJ_VALID(p),!NULL eq p]
if ~ARRAY_EQUAL(res,good,/no_typeconv) then $
   ERRORS_ADD, errors, 'Problem 2 : OBJ_DESTROY & !null'
;
; to prepare any further/future evolution, if any 
;
cumul_errors=errors
;
; ----------------- final message ----------
;
BANNER_FOR_TESTSUITE, 'TEST_OBJ_VALID', cumul_errors, short=short
;
if (cumul_errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1
;
if KEYWORD_SET(test) then STOP
;
end