1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- ;;; Disarchive
- ;;; Copyright © 2021 Timothy Sample <samplet@ngyro.com>
- ;;;
- ;;; This file is part of Disarchive.
- ;;;
- ;;; Disarchive is free software: you can redistribute it and/or modify
- ;;; it under the terms of the GNU General Public License as published by
- ;;; the Free Software Foundation, either version 3 of the License, or
- ;;; (at your option) any later version.
- ;;;
- ;;; Disarchive is distributed in the hope that it will be useful,
- ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;;; GNU General Public License for more details.
- ;;;
- ;;; You should have received a copy of the GNU General Public License
- ;;; along with Disarchive. If not, see <http://www.gnu.org/licenses/>.
- (use-modules (disarchive kinds tar-header)
- (disarchive serialization)
- (quickcheck)
- (quickcheck arbitrary)
- (quickcheck property)
- (rnrs bytevectors)
- (srfi srfi-64))
- (configure-quickcheck
- ;; Perform 1000 tests per property...
- (stop? (lambda (success-count _)
- (>= success-count 1000)))
- ;; ...over the input size 512.
- (size (const 512)))
- (test-begin "kinds--tar-header")
- (test-assert "[prop] Reading is reversible"
- (quickcheck
- (property ((bv $bytevector))
- (equal? bv (tar-header->bytevector (bytevector->tar-header bv))))))
- ;; Writing a generator for '<tar-header>' would be pretty difficult, so
- ;; this test relies on a working 'bytevector->tar-header' procedure in
- ;; order to get a random sample of tar headers.
- (test-assert "[prop] Reading and serializing is reversible"
- (quickcheck
- (property ((bv $bytevector))
- (let* ((header (bytevector->tar-header bv))
- (sexp (serialize -tar-header- header #f)))
- (equal? bv (tar-header->bytevector
- (deserialize -tar-header- sexp #f)))))))
- (test-end "kinds--tar-header")
|