;;;; -*- mode: Scheme; indent-tabs-mode: nil; fill-column: 80; -*- ;;;; ;;;; Copyright © 2015 Rémi Delrue ;;;; ;;;; This program 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. ;;;; ;;;; This program 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 this program. If not, see . (define-module (test-fs-progress-info) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64) #:use-module (rnrs bytevectors) #:use-module (system foreign) #:use-module (gnu gnunet common) #:use-module (gnu gnunet container metadata) #:use-module (gnu gnunet fs progress-info)) (define-syntax-rule (pi-import name ...) (begin (define name (@@ (gnu gnunet fs progress-info) name)) ...)) (pi-import integer->progress-info-status progress-info-status->integer bytevector-u8-fold u8-bitmap->list) (test-begin "test-fs-progress-info") ;; integer->progress-info-status (test-equal '(#:unindex #:progress) (integer->progress-info-status 33)) (test-error 'invalid-arg (integer->progress-info-status 42)) ;; progress-info-status->integer (test-equal 8 (progress-info-status->integer '(#:download #:resume))) (test-error 'invalid-arg (progress-info-status->integer '(#:beam-me-up #:scotty))) ;; bytevector-u8-fold (let ((bv (make-bytevector 1))) (bytevector-u8-set! bv 0 #b01101010) (test-equal '(1 1 1 1) (bytevector-u8-fold (lambda (acc bool elt) (if bool (cons elt acc) acc)) bv '(1 1 1 1 1 1 1 1) '()))) ;; u8-bitmap->list (let ((bv (make-bytevector 3))) (bytevector-u8-set! bv 0 #b11000001) (bytevector-u8-set! bv 1 #b00010100) (bytevector-u8-set! bv 2 #b00010000) (test-assert (lset= eq? '(#\T #\e #\r #\r #\y #\.) (u8-bitmap->list bv 0 '(#\T #\e #\a #\. #\ #\E #\a #\r #\l #\- #\G #\r #\a #\y #\. #\ #\H #\o #\t #\.))))) (test-end)