source: project/release/4/endian-port/trunk/tests/run.scm @ 27395

Last change on this file since 27395 was 27395, checked in by ecloud, 9 years ago

byte vectors and bit vectors are unsigned

File size: 1.9 KB
Line 
1(require-extension endian-port endian-blob)
2
3(let ([outp (port->endian-port (open-output-file "eptest"))])
4        (endian-port-write-ieee-float32 outp +nan.0)
5        (endian-port-write-ieee-float32 outp 5.25)
6        (endian-port-write-ieee-float64 outp +nan.0)
7        (endian-port-write-ieee-float64 outp 5.25)
8        (endian-port-write-int1 outp (inexact->exact (- (expt 2 7) 1)))
9        (endian-port-write-int2 outp (inexact->exact (- (expt 2 15) 1)))
10        (endian-port-write-int4 outp (inexact->exact (- (expt 2 30) 1)))
11        (endian-port-write-byte-vector outp (string->blob "hacking endian-port"))
12        (endian-port-write-byte-vector outp (blob->u8vector (string->blob "'error: bad argument count'")))
13        (endian-port-write-byte-vector outp (u8vector->endian-blob (blob->u8vector (string->blob "always one more bug")) LSB))
14        (endian-port-write-byte-vector outp (u8vector->endian-blob  (u8vector 256 255 254 128 127 126 125) LSB))
15        (close-endian-port outp))
16
17(let ([inp (port->endian-port (open-input-file "eptest"))])
18        (print "trying to read +nan.0 (32-bit): " (endian-port-read-ieee-float32 inp))
19        (print "trying to read 5.25 (32-bit): "   (endian-port-read-ieee-float32 inp))
20        (print "trying to read +nan.0 (64-bit): " (endian-port-read-ieee-float64 inp))
21        (print "trying to read 5.25 (64-bit): " (endian-port-read-ieee-float64 inp))
22        (print "trying to read " (- (expt 2 7) 1) ": "    (endian-port-read-int1 inp))
23        (print "trying to read " (- (expt 2 15) 1) ": "  (endian-port-read-int2 inp))
24        (print "trying to read " (- (expt 2 30) 1) ": "  (endian-port-read-int4 inp))
25        (print "trying to read u8vector: " (blob->string (endian-port-read-byte-vector inp 19)))
26        (print "trying to read u8vector: " (blob->string (endian-port-read-byte-vector inp 27)))
27        (print "trying to read u8vector: " (blob->string (endian-port-read-byte-vector inp 19)))
28        (print "trying to read u8vector of unsigned bytes: " (blob->u8vector (endian-port-read-byte-vector inp 7)))
29        (close-endian-port inp))
30
31(exit)
Note: See TracBrowser for help on using the repository browser.