1 val filename
= OS
.FileSys
.tmpName ()
3 fun testRange (start
, length
) =
5 val allChars
= Word8Vector
.tabulate(length
, fn i
=> Word8.fromInt ((i
+ start
) mod 256))
7 val outStr
= BinIO.openOut filename
8 val _
= BinIO.output (outStr
, allChars
)
9 val _
= BinIO.closeOut outStr
11 val inStr
= BinIO.openIn filename
12 val readChars
= BinIO.inputAll inStr
13 val _
= BinIO.closeIn inStr
15 val _
= OS
.FileSys
.remove filename
17 fun testCharF (c
, cnt
) =
19 val readC
= Word8Vector
.sub(readChars
, cnt
)
20 val _
= if c
= readC
then
23 print ("Error at index: " ^
(Int.toString cnt
) ^
": " ^
24 (Word8.toString c
) ^
" <> " ^
(Word8.toString readC
) ^
"\n")
29 val _
= Word8Vector
.foldl testCharF
0 allChars
34 val _
= testRange (0, 256)
35 val _
= print
"basic test of writing and reading back all characters done\n"
36 val _
= List.tabulate(256, fn i
=> List.tabulate(257, fn i2
=> testRange (i
, i2
)))
37 val _
= print
"test of writing files of all possible characters in strings of lengths 0-256 finished\n"
38 val _
= List.tabulate(6, fn i
=> List.tabulate(5000, fn i2
=> testRange (i
, i2
)))
40 val _
= print
"test finished\n"