Paste: unit test abstractions?

Author: klazuka
Mode: factor
Date: Wed, 30 Sep 2009 16:00:20
Plain Text |
"vocab:images/testing/pam/rgb1x1.pam" binary file-contents 1quotation
[
    binary <byte-writer> dup [
        "vocab:images/testing/pam/rgb1x1.pam" load-image
        pam-image image>stream
    ] with-output-stream B{ } like
] unit-test

"vocab:images/testing/pam/rgba1x1.pam" binary file-contents 1quotation
[
    binary <byte-writer> dup [
        "vocab:images/testing/pam/rgba1x1.pam" load-image
        pam-image image>stream
    ] with-output-stream B{ } like
] unit-test

Annotation: Answering my own question

Author: klazuka
Mode: factor
Date: Wed, 30 Sep 2009 16:07:46
Plain Text |
! Image encode test abstraction

:: encode-test ( path image-class -- )
    path binary file-contents 1quotation
    [
        binary <byte-writer> dup [
            path load-image image-class image>stream
        ] with-output-stream B{ } like
    ] unit-test ;

! Use it like this in your test

"vocab:images/testing/pam/rgba1x1.pam" pam-image encode-test

New Annotation

Summary:
Author:
Mode:
Body: