
/*
  TESTING O2 CORE STRING FUNCTIONS FOR MEMORY LEAKS

  USE TASK MANAGER TO MONITOR GXO2.EXE
  PRESS ESC TO TERMINATE
*/

includepath "$\inc\"
% filename  "z.exe"
'include     "RTL32.inc"
'include     "console.inc"
include     "minwin.inc"

cr=chr(13,10)

/*
data  "news 16 ##sys@0 bstr 08"
data  "frees 16 ##gstr_#@0 sys 16 ##sys@0 sys 16"
data  "error 16 ##@ bstr 128"
data  "nuls 16 ##sys@0 bstr 08"
data  "compile 16 ##string@0 sys 368"
data  "val 16 ##zstring@1 fpu 192"
data  "valat 16 ##sys@0 fpu 192"
data  "ltrim 16 ##string@0 bstr 2312"
data  "rtrim 16 ##string@0 bstr 2320"
data  "lcase 16 ##string@0 bstr 2328"
data  "ucase 16 ##string@0 bstr 2336"
data  "stringBytes 16 ##sys#sys@00 bstr 2464"
data  "string 16 ##sys#zstring@00 bstr 2472 ##sys#string@00 bstr 2480"
data  "space 16 ##sys@0 bstr 2488"
data  "left 16 ##gstr_#sys@00 bstr 2344 ##cstr_#sys@10 bstr 2400"
data  "mid 16 "+_
      "##gstr_#sys#sys@000 bstr 2360 ##cstr_#sys#sys@100 bstr 2392 "+_
      "##gstr_#sys@00 bstr 2416 ##cstr_#sys@10 bstr 2424 "
      ''mid command
data  "mid_ 16 ##gstr_#sys#gstr_@000 sys 2456 ##cstr_#sys#gstr_@100 sys 2352 "
data  "instr 16 ##string#string@00 sys 2504 ##sys#string#string@000 sys 320"
data  "getfile 16 ##cstr_@1 bstr 336 ##cstr_#gstr_@11 sys 2512"
data  "putfile 16 ##cstr_#gstr_@10 sys 344"
data  "print 16 ##cstr_@1 sys 2496"
data  "asc 16 ##string@0 sys 2432 ##string#sys@00 sys 2368"
data  "unic 16 ##wstring@0 sys 2536 ##wstring#sys@00 sys 2528"
data  "len 16 ##gstr_@0 sys 2376 ##cstr_@1 sys 2408"
data  "chr 16 ##sys@0 bstr 2384"
data  "wchr 16 ##sys@0 wbstring 2544"
data  "str 16 ##fpu@0 bstr 2520 ##fpu#sys@00 bstr 200 "
data  "hex 16 ##fpu#sys@00 bstr 216 ##fpu@0 bstr 208 "
data  "guidval 16 ##guid#bstr@10 sys 352  ##guid#zstring@11 sys 352"
data  "guidtxt 16 ##guid@1 bstr 360"
data  "numberformat 16 ##sys#sys#sys#sys#sys#sys@000000 sys 2552 ##@ sys 2560 "
*/

%sz 1e3

'print "Testing String Functions"+cr+cr+"Start"

type guid byte b[16]

bstring b[1000]
string  s[1000]
guid g
sys  a

'itr local string arrays

function f()
============
sys m
'string s[1000]
s[1]=nuls sz
sys i
for i=1 to 1000
  'b=news sz
  'b=""
  'freememory strptr b
  'freememory b
  'frees b
  'm=getmemory sz
  'freememory m
  '
  's=news sz
  's[i]=nuls sz
  's=space sz
  's+=chr 48
  '
  s[i]=s
  '
  's[i]+=chr  0x30
  's[i]+=wchr 0x130
  's[i]+=" "+" "
  's[i]=str 123
  's[i]=hex 123
  's[i]=ucase sz
  's[i]=lcase sz
  's[i]=ltrim sz
  's[i]=rtrim sz
  's[i]=stringbytes 1000,48 
  's[i]=string 1000,"1"
  'a=asc s[i],i
  'a=unic s[i],i/2
  'a=val s[i]
  'a=instr 1000,s[i]+s[i],s[i]
  'a=valat strptr s[i]
  'a=len s[i]+s[i]
  'guidval g,s[1]
  's[i]=guidtxt g
  's[i]=left s[i]+s[i],1000
  's[i]=mid s[i]+s[i],1001,1000
  'mid s[i],1,s[i]+s[i]
  '
  's[i]=getfile "t.txt"
  'getfile "t.txt",s[i]
  'putfile "t.txt",s[i]
  '
  's[i]=error
  '
  ''compile
  ''print
  ''numberformat
  '
  'if mid(s[i],1,100)<>mid(s[i],101,100)
  'end if
  'dim t=space sz
  'let t=space sz
next
end function


do
  if GetAsyncKeyState(27) then
    exit do
  end if
  f()
  for i=1 to 1000
    s[i]=""
  next
  sleep 100
end do

