@@ 174,7 174,7 @@
(in
(with-output-to-sequence (out)
(write-optional-type
- (read-binary 'u8 (buf #()))
+ (read-optional-type 'u8 (buf #(#x00)))
out)))
(multiple-value-bind (object) (read-optional-type 'u8 in)
(with-slots (value) object
@@ 184,11 184,21 @@
(in
(with-output-to-sequence (out)
(write-optional-type
- (read-binary 'u8 (buf #(#x70)))
+ (read-optional-type 'u8 (buf #(#x01 #x70)))
out)))
(multiple-value-bind (object) (read-optional-type 'u8 in)
(with-slots (value) object
- (ok (equalp value 112)))))))
+ (ok (equalp value 112))))))
+ (testing "reading and writing optional type with more bytes"
+ (with-input-from-sequence
+ (in
+ (with-output-to-sequence (out)
+ (write-optional-type
+ (read-optional-type 'u32 (buf #(#x01 #xEF #xBE #xAD #xDE)))
+ out)))
+ (multiple-value-bind (object) (read-optional-type 'u32 in)
+ (with-slots (value) object
+ (ok (equalp value #xDEADBEEF)))))))
(deftest array-test
(testing "reading and writing array"