;;;; blob-utils-test.scm -*- Scheme -*- ;;;; Kon Lovett, Jul '18 (import test) (test-begin "Blob Utils") ;;;; (import scheme (chicken base) (chicken blob) blob-set-int) (test-group "Low-Level Set UInt" (let ((blb (make-blob 10))) (blob-set-u16-le! blb #x0606) (let ((str (blob->string blb))) (test "low byte set" (integer->char #x06) (string-ref str 0)) ) ) ) (import blob-hexadecimal) (test-group "-> Hex" (test "414243444546" (blob->hex (string->blob "ABCDEF"))) (test "4243444546" (blob->hex (string->blob "ABCDEF") 1)) (test "4243" (blob->hex (string->blob "ABCDEF") 1 3)) ) (import pack-integer) (test-group "Pack Integer" (let ((res (pack-u8 #x2d))) (test-assert (string? res)) (test "byte set" (integer->char #x2d) (string-ref res 0)) ) (let ((res (pack-integer #x0606 #:kind 'blob #:order 'little-endian))) (test-assert (blob? res)) (let ((str (blob->string res))) (test "low byte set" (integer->char #x06) (string-ref str 0)) ) ) ) (import blob-utils) (test-group "Set Int" (let ((blb (make-blob 10))) (bytes-set-s16! blb 0 #x0606) (let ((str (blob->string blb))) (test "low byte set" (integer->char #x06) (string-ref str 0)) ) ) ) (test-group "-> Hex" (test "414243444546" (bytes->hexstring "ABCDEF")) (test "4243444546" (bytes->hexstring "ABCDEF" 1)) (test "4243" (bytes->hexstring "ABCDEF" 1 3)) ) ;;; (test-end "Blob Utils") (test-exit)