Ignore:
Timestamp:
08/26/17 22:31:52 (3 years ago)
Author:
Kon Lovett
Message:

add raw-update to prim, use raw-update for mmapped/in-mem file md

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/message-digest/trunk/tests/run.scm

    r34302 r34373  
    2222
    2323(define digest-length 5)
     24(define context-size 10)
    2425(define block-length 64)
    25 (define context-size 10)
    26 
    27 (define-constant block-length-default 4)
     26
     27(define-constant BLOCK-LENGTH-DEFAULT 4)
     28
     29(define short-test-filename "alpha.txt")
    2830
    2931;;
     
    3537
    3638;Tests defaults
    37 (test-group "Chunk Read"
     39(test-group "Chunk Read (port)"
    3840  (let ((siz (message-digest-chunk-size))
    39         (in (open-input-file "alpha.txt")))
    40     (let ((rdr ((message-digest-chunk-read-maker) in)))
     41        (in (open-input-file short-test-filename)))
     42    (let ((rdr ((message-digest-chunk-port-read-maker) in)))
    4143      (let ((res (rdr)))
    4244        (test-assert "First chunk type" (blob? res))
     
    5961    (test update (message-digest-primitive-update mdp))
    6062    (test final (message-digest-primitive-final mdp))
    61     (test block-length-default (message-digest-primitive-block-length mdp))
     63    (test BLOCK-LENGTH-DEFAULT (message-digest-primitive-block-length mdp))
    6264    (test-assert (symbol? (message-digest-primitive-name mdp))) )
    6365
     
    6567
    6668  (let ((mdp (make-message-digest-primitive context-size digest-length init update final 'foo)))
    67     (test block-length-default (message-digest-primitive-block-length mdp))
     69    (test BLOCK-LENGTH-DEFAULT (message-digest-primitive-block-length mdp))
    6870    (test 'foo (message-digest-primitive-name mdp)) )
    6971
     
    277279)
    278280
     281;
     282(test-group "Chunk Read (fileno)"
     283
     284  (define (init ctx)
     285    ;(printf "  Init Ctx: ~S~%" ctx)
     286    (assert (pointer? ctx)) )
     287
     288  (define (update ctx bytes count)
     289        ;(printf "Update Ctx: ~S Count: ~S Bytes: ~S~%" ctx count bytes)
     290    (assert (pointer? ctx))
     291    (assert (not (not bytes)))
     292    (assert (<= context-size count))
     293    (move-memory! bytes ctx (min context-size count)) )
     294
     295  (define (raw-update ctx bytes count)
     296        ;(printf "Raw-Update Ctx: ~S Count: ~S Bytes: ~S~%" ctx count bytes)
     297    (assert (pointer? ctx))
     298    (assert (not (not bytes)))
     299    (assert (<= context-size count))
     300    (move-memory! bytes ctx (min context-size count)) )
     301
     302  (define (final ctx result)
     303    ;(printf " Final Ctx: ~S Length: ~S Result: ~S~%" ctx digest-length result)
     304    (assert (pointer? ctx))
     305    (assert (not (not result)))
     306    (assert (<= 0 digest-length))
     307    (move-memory! ctx result digest-length) )
     308
     309  (let ((mdp (make-message-digest-primitive context-size digest-length init update final raw-update)))
     310    (test "6162636465" (message-digest-file mdp short-test-filename 'hex-string)) )
     311)
     312
    279313(test-end)
    280314
Note: See TracChangeset for help on using the changeset viewer.