File: test_ptr_valid.pro

package info (click to toggle)
gnudatalanguage 0.9.9-13
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 17,892 kB
  • sloc: cpp: 167,389; ansic: 9,358; sh: 566; python: 472; makefile: 252; f90: 28
file content (57 lines) | stat: -rw-r--r-- 1,682 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
53
54
55
56
57
pro test_ptr_valid, test=test,verbose=verbose, noexit=noexit
;
;	First, look for pre-existing pointers.
; if there are any, maybe the user doesn't want to run this.
p = ptr_valid()
if size(p,/type) ne 10 then begin
	message,' ptr_valid() did not return even a pointer type '
	exit, status=1
	endif
if(n_elements(p) ne 1) then $
	message,/con,' ptr_valid() indicates multiple pre-existing pointers'

if ptr_valid(p[0]) then $
	message,/con,' ptr_valid() indicates a pre-existing pointer'


; if(keyword_set(verbose)) then print, ' HEAP_GC called will reset pointer indeces'

; closed bug 708: This didn't work.
ab = ptr_new(fltarr(12))
cmp = {a:ab, b:ab}
err=0
pcmp = ptr_new(cmp)
cmp = 0

if ptr_valid(ptr_valid(10001,/cast)) then err++ $
	else if(keyword_set(verbose)) then message,/con,'NullPointer ok'


	p = (ptr_valid())[0] 
	pval = ptr_valid(p,/get_heap)
	if keyword_set(verbose)  then message,/con,' ptr_valid(p,/get_heap) value=',pval

if ~ptr_valid(p) then err++ $
	else if keyword_set(verbose)  then message,/con,' p =ab ok'
	newptr = ptr_valid(pval,/cast)

if newptr ne p then err++ $
	else if keyword_set(verbose)  then message,/con,' ptr=ptr_valid(lval,/cast) passed'

llist = list() & mlist = list()
pps=ptrarr(2)
pps[0] = ptr_new(llist)
pps[1] = ptr_new(mlist)
if total(ptr_valid(pps)) ne 2  then err++ $
else if(keyword_set(verbose)) then message,/con,'2 created pointers are valid"

;
if(keyword_set(test)) then stop,' at end of test routine'
;
;
banner_for_testsuite,' TEST_PTR_VALID',err
if (err gt 0) and ~keyword_set(noexit) then exit, status = 1 $
  else if (err eq 0) then print,'Success!'

return
end