tar-header.scm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ;;; Disarchive
  2. ;;; Copyright © 2021 Timothy Sample <samplet@ngyro.com>
  3. ;;;
  4. ;;; This file is part of Disarchive.
  5. ;;;
  6. ;;; Disarchive is free software: you can redistribute it and/or modify
  7. ;;; it under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation, either version 3 of the License, or
  9. ;;; (at your option) any later version.
  10. ;;;
  11. ;;; Disarchive is distributed in the hope that it will be useful,
  12. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with Disarchive. If not, see <http://www.gnu.org/licenses/>.
  18. (use-modules (disarchive kinds tar-header)
  19. (disarchive serialization)
  20. (quickcheck)
  21. (quickcheck arbitrary)
  22. (quickcheck property)
  23. (rnrs bytevectors)
  24. (srfi srfi-64))
  25. (configure-quickcheck
  26. ;; Perform 1000 tests per property...
  27. (stop? (lambda (success-count _)
  28. (>= success-count 1000)))
  29. ;; ...over the input size 512.
  30. (size (const 512)))
  31. (test-begin "kinds--tar-header")
  32. (test-assert "[prop] Reading is reversible"
  33. (quickcheck
  34. (property ((bv $bytevector))
  35. (equal? bv (tar-header->bytevector (bytevector->tar-header bv))))))
  36. ;; Writing a generator for '<tar-header>' would be pretty difficult, so
  37. ;; this test relies on a working 'bytevector->tar-header' procedure in
  38. ;; order to get a random sample of tar headers.
  39. (test-assert "[prop] Reading and serializing is reversible"
  40. (quickcheck
  41. (property ((bv $bytevector))
  42. (let* ((header (bytevector->tar-header bv))
  43. (sexp (serialize -tar-header- header #f)))
  44. (equal? bv (tar-header->bytevector
  45. (deserialize -tar-header- sexp #f)))))))
  46. (test-end "kinds--tar-header")