Changeset 18795 in project


Ignore:
Timestamp:
07/11/10 23:06:17 (11 years ago)
Author:
ecloud
Message:

fixed a couple of bugs and added more unit tests

Location:
release/4/endian-port/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/endian-port/trunk/endian-port-test.scm

    r18794 r18795  
    11(load "endian-port.so")
    2 (import endian-port)
     2(import endian-port endian-blob)
    33
    44(let ([outp (port->endian-port (open-output-file "eptest"))])
     
    77        (endian-port-write-ieee-float64 outp +nan.0)
    88        (endian-port-write-ieee-float64 outp 5.25)
     9        (endian-port-write-int1 outp 255)
     10        (endian-port-write-int2 outp 65535)
     11        (endian-port-write-int4 outp 4294967295)
     12        (endian-port-write-byte-vector outp (string->blob "hacking endian-port"))
     13        (endian-port-write-byte-vector outp (blob->u8vector (string->blob "'error: bad argument count'")))
     14        (endian-port-write-byte-vector outp (u8vector->endian-blob (blob->u8vector (string->blob "always one more bug")) LSB))
    915        (close-endian-port outp))
    1016
     
    1420        (print (endian-port-read-ieee-float64 inp))
    1521        (print (endian-port-read-ieee-float64 inp))
     22        (print (endian-port-read-int1 inp))
     23        (print (endian-port-read-int2 inp))
     24        (print (endian-port-read-int4 inp))
     25        (print (blob->string (endian-port-read-byte-vector inp 19)))
     26        (print (blob->string (endian-port-read-byte-vector inp 27)))
     27        (print (blob->string (endian-port-read-byte-vector inp 19)))
    1628        (close-endian-port inp))
     29
     30(exit)
  • release/4/endian-port/trunk/endian-port.scm

    r18794 r18795  
    194194                                [ret (file-read (endian-port-fileno eport) 2 buf)])
    195195                        (and (eq? (cadr ret) 2) (endian-blob->uint2 (byte-blob->endian-blob
    196                                         (blob->byte-blob (car ret) byte-order) 0)) ))))
     196                                        (blob->byte-blob (car ret)) byte-order) ) ))))
    197197
    198198
     
    209209                                [ret (file-read (endian-port-fileno eport) 4 buf)])
    210210                        (and (eq? (cadr ret) 4) (endian-blob->uint4 (byte-blob->endian-blob
    211                                         (blob->byte-blob (car ret) byte-order) 0)) ))))
     211                                        (blob->byte-blob (car ret)) byte-order) ) ))))
    212212
    213213; Procedure:
     
    317317                           (loop (- size 1) (cons b data)))
    318318                         (if (eq? byte-order MSB)
    319                              (u8vector->byte-vector (list->u8vector (reverse data)))
    320                              (u8vector->byte-vector (list->u8vector data))))))))
     319                             (u8vector->blob (list->u8vector (reverse data)))
     320                             (u8vector->blob (list->u8vector data))))))))
    321321
    322322
Note: See TracChangeset for help on using the changeset viewer.