1 (* Notice
: This test will not be passed on platforms like Win32
!
2 (due to behind
-the
-scenes CR
/LF
<=> LF conversions
). *)
4 val filename
= OS
.FileSys
.tmpName ()
6 fun testRange (start
, length
) =
8 val allChars
= CharVector
.tabulate(length
, fn i
=> chr ((i
+ start
) mod 256))
10 val outStr
= TextIO.openOut filename
11 val _
= TextIO.output (outStr
, allChars
)
12 val _
= TextIO.closeOut outStr
14 val inStr
= TextIO.openIn filename
15 val readChars
= TextIO.inputAll inStr
16 val _
= TextIO.closeIn inStr
18 val _
= OS
.FileSys
.remove filename
20 fun testCharF (c
, cnt
) =
22 val readC
= CharVector
.sub(readChars
, cnt
)
23 val _
= if c
= readC
then
26 print ("Error at index: " ^
(Int.toString cnt
) ^
": " ^
27 (Char.toString c
) ^
" <> " ^
(Char.toString readC
) ^
"\n")
32 val _
= CharVector
.foldl testCharF
0 allChars
37 val _
= testRange (0, 256)
38 val _
= print
"basic test of writing and reading back all characters done\n"
39 val _
= List.tabulate(256, fn i
=> List.tabulate(257, fn i2
=> testRange (i
, i2
)))
40 val _
= print
"test of writing files of all possible characters in strings of lengths 0-256 finished\n"
41 val _
= List.tabulate(6, fn i
=> List.tabulate(5000, fn i2
=> testRange (i
, i2
)))
43 val _
= print
"test finished\n"